二进制炸弹实验 BinaryBombs( 五 )

  1. 现在从最终返回值5倒推一下:
  • \(5 = 2 * 2 + 1\),\(res = (14 - 0) / 2 + 0 = 7\)当前func4(a, 0, 14, 7)   则递归func4(a, 8, 14, 7)
  • \(2 = 2 * 1\),   \(res = (14 - 8) / 2 + 8 = 11\)       当前func4(a, 8, 14, 11) 则递归func4(a, 8, 10, 11)
  • \(1 = 2 * 0 + 1\),\(res = (10 - 8) / 2 + 8 = 9\)当前func4(a, 8, 10, 9)   则递归func4(a, 10, 10, 9)
  • \(0 = 0\),递归终止条件,此时$ res = (10 - 10) / 2 + 10 = 10$
好,那么可以得出 a = 10
  1. 则答案为 10, 5
汇编代码:
点击查看代码0000000000401518 <func4>:  401518: 55                    push   %rbp  401519: 48 89 e5              mov    %rsp,%rbp  40151c: 89 d1                 mov    %edx,%ecx  40151e: 29 f1                 sub    %esi,%ecx  401520: 89 c8                 mov    %ecx,%eax  401522: c1 e8 1f              shr    $0x1f,%eax  401525: 01 c8                 add    %ecx,%eax  401527: d1 f8                 sar    %eax  401529: 01 f0                 add    %esi,%eax  40152b: 39 f8                 cmp    %edi,%eax  40152d: 7f 09                 jg     401538 <func4+0x20>  40152f: 7c 13                 jl     401544 <func4+0x2c>  401531: b8 00 00 00 00        mov    $0x0,%eax  401536: 5d                    pop    %rbp  401537: c3                    retq  401538: 8d 50 ff              lea    -0x1(%rax),%edx  40153b: e8 d8 ff ff ff        callq  401518 <func4>  401540: 01 c0                 add    %eax,%eax  401542: eb f2                 jmp    401536 <func4+0x1e>  401544: 8d 70 01              lea    0x1(%rax),%esi  401547: e8 cc ff ff ff        callq  401518 <func4>  40154c: 8d 44 00 01           lea    0x1(%rax,%rax,1),%eax  401550: eb e4                 jmp    401536 <func4+0x1e>0000000000401552 <phase_4>:  401552: 55                    push   %rbp  401553: 48 89 e5              mov    %rsp,%rbp  401556: 48 83 ec 10           sub    $0x10,%rsp  40155a: 48 8d 4d f8           lea    -0x8(%rbp),%rcx  40155e: 48 8d 55 fc           lea    -0x4(%rbp),%rdx  401562: be 1f 33 40 00        mov    $0x40331f,%esi  401567: b8 00 00 00 00        mov    $0x0,%eax  40156c: e8 9f fb ff ff        callq  401110 <__isoc99_sscanf@plt>  401571: 83 f8 02              cmp    $0x2,%eax  401574: 75 0c                 jne    401582 <phase_4+0x30>  401576: 8b 45 fc              mov    -0x4(%rbp),%eax  401579: 85 c0                 test   %eax,%eax  40157b: 78 05                 js     401582 <phase_4+0x30>  40157d: 83 f8 0e              cmp    $0xe,%eax  401580: 7e 05                 jle    401587 <phase_4+0x35>  401582: e8 b9 03 00 00        callq  401940 <explode_bomb>  401587: ba 0e 00 00 00        mov    $0xe,%edx  40158c: be 00 00 00 00        mov    $0x0,%esi  401591: 8b 7d fc              mov    -0x4(%rbp),%edi  401594: e8 7f ff ff ff        callq  401518 <func4>  401599: 83 f8 05              cmp    $0x5,%eax  40159c: 75 06                 jne    4015a4 <phase_4+0x52>  40159e: 83 7d f8 05           cmpl   $0x5,-0x8(%rbp)  4015a2: 74 05                 je     4015a9 <phase_4+0x57>  4015a4: e8 97 03 00 00        callq  401940 <explode_bomb>  4015a9: c9                    leaveq  4015aa: c3                    retq

经验总结扩展阅读