I am really bad at understanding assembly code and the way it works. I have little problems given to me in Assembly code and I have to reverse engineer it to C, but I have been doing really bad job at it so far. Can someone tell me what this code translates to in C.

    .file   "hw4.c"
    .p2align 4,,15
    .globl  p1
    .type   p1, @function

    movl    (%rdi), %eax
    addl    (%rsi), %eax
    .size   p1, .-p1
    .p2align 4,,15
    .globl  p2
    .type   p2, @function

closed as off-topic by usr2564301, perror, 0xec, 0xC0000022L Oct 29 '18 at 12:03

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking for help reverse-engineering a specific system are off-topic unless they demonstrate an understanding of the concepts involved and clearly identify a specific problem." – usr2564301, perror, 0xec, 0xC0000022L
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 5
    Welcome to RE.SE. Is this your homework? Translating asm to pseudo C is not actually reverse engineering. Start by reading on the directives in your code, flags, registers and instructions. You can't offload your homework to SE unless you show some research done/understanding. – sudhackar Oct 29 '18 at 6:06

It is just a function that perform a simple addition:

int add(int *i, int *j)
  return *i + *j;
  • rdi and rsi are addresses to the actual numbers being added. – sudhackar Oct 30 '18 at 7:20
  • RIght. I fixed this on the code,my bad. – perror Oct 30 '18 at 9:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.