Advertisement
Marionumber1

C Weirdness

Jan 25th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. /* C code, which should return 250000 but returns 16 */
  2. void test()
  3. {
  4.     int ret = pow(500,2);
  5.     printf("500^2 is %d\n", ret);
  6.     return ret;
  7. }
  8.  
  9. /* ASM code, which returns printf()'s return value */
  10. 800026e4 <test>:
  11. 800026e4:   83 ec 1c                sub    $0x1c,%esp
  12. 800026e7:   c7 44 24 04 02 00 00    movl   $0x2,0x4(%esp)
  13. 800026ee:   00
  14. 800026ef:   c7 04 24 f4 01 00 00    movl   $0x1f4,(%esp)
  15. 800026f6:   e8 1f 29 00 00          call   8000501a <pow>
  16. 800026fb:   89 44 24 04             mov    %eax,0x4(%esp)
  17. 800026ff:   c7 04 24 80 75 00 80    movl   $0x80007580,(%esp)
  18. 80002706:   e8 c8 2f 00 00          call   800056d3 <printf>
  19. 8000270b:   83 c4 1c                add    $0x1c,%esp
  20. 8000270e:   c3                      ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement