Created
August 19, 2015 05:29
-
-
Save swgillespie/ce96985dd16dba501265 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brainfuck: file format mach-o-x86-64 | |
Disassembly of section .text: | |
0000000100000a70 <_branch_stack_new>: | |
stack->capacity = stack->capacity * BRANCH_STACK_SCALING_FACTOR; | |
stack->stack = realloc(stack->stack, sizeof(struct branch_stack_entry) * stack->capacity); | |
} | |
struct branch_stack | |
branch_stack_new() { | |
100000a70: 55 push %rbp | |
100000a71: 48 89 e5 mov %rsp,%rbp | |
100000a74: 48 83 ec 30 sub $0x30,%rsp | |
100000a78: 48 89 f8 mov %rdi,%rax | |
100000a7b: b9 10 00 00 00 mov $0x10,%ecx | |
100000a80: 89 ca mov %ecx,%edx | |
100000a82: b9 00 01 00 00 mov $0x100,%ecx | |
100000a87: 89 ce mov %ecx,%esi | |
struct branch_stack stack; | |
stack.stack = calloc(sizeof(struct branch_stack_entry), BRANCH_STACK_DEFAULT_SIZE); | |
100000a89: 48 89 7d e0 mov %rdi,-0x20(%rbp) | |
100000a8d: 48 89 d7 mov %rdx,%rdi | |
100000a90: 48 89 45 d8 mov %rax,-0x28(%rbp) | |
100000a94: e8 e9 12 00 00 callq 100001d82 <_calloc$stub> | |
100000a99: 48 89 45 e8 mov %rax,-0x18(%rbp) | |
stack.length = 0; | |
100000a9d: 48 c7 45 f0 00 00 00 movq $0x0,-0x10(%rbp) | |
100000aa4: 00 | |
stack.capacity = BRANCH_STACK_DEFAULT_SIZE; | |
100000aa5: 48 c7 45 f8 00 01 00 movq $0x100,-0x8(%rbp) | |
100000aac: 00 | |
return stack; | |
100000aad: 48 8b 45 e8 mov -0x18(%rbp),%rax | |
100000ab1: 48 8b 55 e0 mov -0x20(%rbp),%rdx | |
100000ab5: 48 89 02 mov %rax,(%rdx) | |
100000ab8: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100000abc: 48 89 42 08 mov %rax,0x8(%rdx) | |
100000ac0: 48 8b 45 f8 mov -0x8(%rbp),%rax | |
100000ac4: 48 89 42 10 mov %rax,0x10(%rdx) | |
100000ac8: 48 8b 45 d8 mov -0x28(%rbp),%rax | |
100000acc: 48 83 c4 30 add $0x30,%rsp | |
100000ad0: 5d pop %rbp | |
100000ad1: c3 retq | |
100000ad2: 66 66 66 66 66 2e 0f data16 data16 data16 data16 nopw %cs:0x0(%rax,%rax,1) | |
100000ad9: 1f 84 00 00 00 00 00 | |
0000000100000ae0 <_branch_stack_push>: | |
void | |
branch_stack_push( | |
struct branch_stack *stack, | |
size_t offset, | |
struct brainfuck_op *op) { | |
100000ae0: 55 push %rbp | |
100000ae1: 48 89 e5 mov %rsp,%rbp | |
100000ae4: 48 83 ec 30 sub $0x30,%rsp | |
100000ae8: 48 89 7d f8 mov %rdi,-0x8(%rbp) | |
100000aec: 48 89 75 f0 mov %rsi,-0x10(%rbp) | |
100000af0: 48 89 55 e8 mov %rdx,-0x18(%rbp) | |
if (stack->length == stack->capacity) { | |
100000af4: 48 8b 55 f8 mov -0x8(%rbp),%rdx | |
100000af8: 48 8b 52 08 mov 0x8(%rdx),%rdx | |
100000afc: 48 8b 75 f8 mov -0x8(%rbp),%rsi | |
100000b00: 48 3b 56 10 cmp 0x10(%rsi),%rdx | |
100000b04: 0f 85 09 00 00 00 jne 100000b13 <_branch_stack_push+0x33> | |
branch_stack_resize(stack); | |
100000b0a: 48 8b 7d f8 mov -0x8(%rbp),%rdi | |
100000b0e: e8 4d 00 00 00 callq 100000b60 <_branch_stack_resize> | |
} | |
struct branch_stack_entry entry; | |
entry.branch_offset = offset; | |
100000b13: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100000b17: 48 89 45 d8 mov %rax,-0x28(%rbp) | |
entry.op = op; | |
100000b1b: 48 8b 45 e8 mov -0x18(%rbp),%rax | |
100000b1f: 48 89 45 e0 mov %rax,-0x20(%rbp) | |
stack->stack[stack->length++] = entry; | |
100000b23: 48 8b 45 f8 mov -0x8(%rbp),%rax | |
100000b27: 48 8b 48 08 mov 0x8(%rax),%rcx | |
100000b2b: 48 89 ca mov %rcx,%rdx | |
100000b2e: 48 81 c2 01 00 00 00 add $0x1,%rdx | |
100000b35: 48 89 50 08 mov %rdx,0x8(%rax) | |
100000b39: 48 8b 45 f8 mov -0x8(%rbp),%rax | |
100000b3d: 48 8b 00 mov (%rax),%rax | |
100000b40: 48 c1 e1 04 shl $0x4,%rcx | |
100000b44: 48 01 c8 add %rcx,%rax | |
100000b47: 48 8b 4d d8 mov -0x28(%rbp),%rcx | |
100000b4b: 48 89 08 mov %rcx,(%rax) | |
100000b4e: 48 8b 4d e0 mov -0x20(%rbp),%rcx | |
100000b52: 48 89 48 08 mov %rcx,0x8(%rax) | |
} | |
100000b56: 48 83 c4 30 add $0x30,%rsp | |
100000b5a: 5d pop %rbp | |
100000b5b: c3 retq | |
100000b5c: 0f 1f 40 00 nopl 0x0(%rax) | |
0000000100000b60 <_branch_stack_resize>: | |
#define BRANCH_STACK_DEFAULT_SIZE 256 | |
#define BRANCH_STACK_SCALING_FACTOR 2 | |
static void | |
branch_stack_resize(struct branch_stack *stack) { | |
100000b60: 55 push %rbp | |
100000b61: 48 89 e5 mov %rsp,%rbp | |
100000b64: 48 83 ec 10 sub $0x10,%rsp | |
100000b68: 48 89 7d f8 mov %rdi,-0x8(%rbp) | |
stack->capacity = stack->capacity * BRANCH_STACK_SCALING_FACTOR; | |
100000b6c: 48 8b 7d f8 mov -0x8(%rbp),%rdi | |
100000b70: 48 8b 7f 10 mov 0x10(%rdi),%rdi | |
100000b74: 48 c1 e7 01 shl $0x1,%rdi | |
100000b78: 48 8b 45 f8 mov -0x8(%rbp),%rax | |
100000b7c: 48 89 78 10 mov %rdi,0x10(%rax) | |
stack->stack = realloc(stack->stack, sizeof(struct branch_stack_entry) * stack->capacity); | |
100000b80: 48 8b 45 f8 mov -0x8(%rbp),%rax | |
100000b84: 48 8b 00 mov (%rax),%rax | |
100000b87: 48 8b 7d f8 mov -0x8(%rbp),%rdi | |
100000b8b: 48 8b 7f 10 mov 0x10(%rdi),%rdi | |
100000b8f: 48 c1 e7 04 shl $0x4,%rdi | |
100000b93: 48 89 7d f0 mov %rdi,-0x10(%rbp) | |
100000b97: 48 89 c7 mov %rax,%rdi | |
100000b9a: 48 8b 75 f0 mov -0x10(%rbp),%rsi | |
100000b9e: e8 27 12 00 00 callq 100001dca <_realloc$stub> | |
100000ba3: 48 8b 75 f8 mov -0x8(%rbp),%rsi | |
100000ba7: 48 89 06 mov %rax,(%rsi) | |
} | |
100000baa: 48 83 c4 10 add $0x10,%rsp | |
100000bae: 5d pop %rbp | |
100000baf: c3 retq | |
0000000100000bb0 <_branch_stack_pop>: | |
entry.op = op; | |
stack->stack[stack->length++] = entry; | |
} | |
struct branch_stack_entry | |
branch_stack_pop(struct branch_stack *stack) { | |
100000bb0: 55 push %rbp | |
100000bb1: 48 89 e5 mov %rsp,%rbp | |
100000bb4: 48 83 ec 20 sub $0x20,%rsp | |
100000bb8: 48 89 7d e8 mov %rdi,-0x18(%rbp) | |
if (stack->length == 0) { | |
100000bbc: 48 8b 7d e8 mov -0x18(%rbp),%rdi | |
100000bc0: 48 81 7f 08 00 00 00 cmpq $0x0,0x8(%rdi) | |
100000bc7: 00 | |
100000bc8: 0f 85 20 00 00 00 jne 100000bee <_branch_stack_pop+0x3e> | |
100000bce: 48 8d 35 ab 12 00 00 lea 0x12ab(%rip),%rsi # 100001e80 <_realloc$stub+0xb6> | |
100000bd5: 48 8b 05 3c 14 00 00 mov 0x143c(%rip),%rax # 100002018 <___stderrp$stub> | |
fprintf(stderr, "attempted to pop from empty branch stack"); | |
100000bdc: 48 8b 38 mov (%rax),%rdi | |
100000bdf: b0 00 mov $0x0,%al | |
100000be1: e8 c0 11 00 00 callq 100001da6 <_fprintf$stub> | |
abort(); | |
100000be6: 89 45 e4 mov %eax,-0x1c(%rbp) | |
100000be9: e8 8e 11 00 00 callq 100001d7c <_abort$stub> | |
} | |
return stack->stack[--stack->length]; | |
100000bee: 48 8b 45 e8 mov -0x18(%rbp),%rax | |
100000bf2: 48 8b 48 08 mov 0x8(%rax),%rcx | |
100000bf6: 48 ff c9 dec %rcx | |
100000bf9: 48 89 48 08 mov %rcx,0x8(%rax) | |
100000bfd: 48 8b 45 e8 mov -0x18(%rbp),%rax | |
100000c01: 48 8b 00 mov (%rax),%rax | |
100000c04: 48 c1 e1 04 shl $0x4,%rcx | |
100000c08: 48 8b 14 08 mov (%rax,%rcx,1),%rdx | |
100000c0c: 48 8b 44 08 08 mov 0x8(%rax,%rcx,1),%rax | |
100000c11: 48 89 45 f8 mov %rax,-0x8(%rbp) | |
100000c15: 48 89 55 f0 mov %rdx,-0x10(%rbp) | |
100000c19: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100000c1d: 48 8b 55 f8 mov -0x8(%rbp),%rdx | |
100000c21: 48 83 c4 20 add $0x20,%rsp | |
100000c25: 5d pop %rbp | |
100000c26: c3 retq | |
100000c27: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1) | |
100000c2e: 00 00 | |
0000000100000c30 <_branch_stack_destroy>: | |
} | |
void | |
branch_stack_destroy(struct branch_stack *stack) { | |
100000c30: 55 push %rbp | |
100000c31: 48 89 e5 mov %rsp,%rbp | |
100000c34: 48 83 ec 10 sub $0x10,%rsp | |
100000c38: 48 89 7d f8 mov %rdi,-0x8(%rbp) | |
free(stack->stack); | |
100000c3c: 48 8b 7d f8 mov -0x8(%rbp),%rdi | |
100000c40: 48 8b 3f mov (%rdi),%rdi | |
100000c43: e8 64 11 00 00 callq 100001dac <_free$stub> | |
} | |
100000c48: 48 83 c4 10 add $0x10,%rsp | |
100000c4c: 5d pop %rbp | |
100000c4d: c3 retq | |
100000c4e: 90 nop | |
100000c4f: 90 nop | |
0000000100000c50 <_find_next_branch_right>: | |
size_t find_next_branch_right(struct program*, size_t); | |
void execute(struct program); | |
size_t | |
find_next_branch_right(struct program *prog, size_t pc) { | |
100000c50: 55 push %rbp | |
100000c51: 48 89 e5 mov %rsp,%rbp | |
100000c54: 48 83 ec 20 sub $0x20,%rsp | |
100000c58: 48 89 7d f8 mov %rdi,-0x8(%rbp) | |
100000c5c: 48 89 75 f0 mov %rsi,-0x10(%rbp) | |
for (size_t i = pc; i < prog->length; i++) { | |
100000c60: 48 8b 75 f0 mov -0x10(%rbp),%rsi | |
100000c64: 48 89 75 e8 mov %rsi,-0x18(%rbp) | |
100000c68: 48 8b 45 e8 mov -0x18(%rbp),%rax | |
100000c6c: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
100000c70: 48 3b 41 08 cmp 0x8(%rcx),%rax | |
100000c74: 0f 83 3a 00 00 00 jae 100000cb4 <_find_next_branch_right+0x64> | |
if (prog->ops[i].type == BRANCH_RIGHT) { | |
100000c7a: 48 8b 45 e8 mov -0x18(%rbp),%rax | |
100000c7e: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
100000c82: 48 8b 09 mov (%rcx),%rcx | |
100000c85: 81 3c c1 05 00 00 00 cmpl $0x5,(%rcx,%rax,8) | |
100000c8c: 0f 85 0a 00 00 00 jne 100000c9c <_find_next_branch_right+0x4c> | |
return i; | |
100000c92: 48 8b 45 e8 mov -0x18(%rbp),%rax | |
100000c96: 48 83 c4 20 add $0x20,%rsp | |
100000c9a: 5d pop %rbp | |
100000c9b: c3 retq | |
} | |
} | |
100000c9c: e9 00 00 00 00 jmpq 100000ca1 <_find_next_branch_right+0x51> | |
size_t find_next_branch_right(struct program*, size_t); | |
void execute(struct program); | |
size_t | |
find_next_branch_right(struct program *prog, size_t pc) { | |
for (size_t i = pc; i < prog->length; i++) { | |
100000ca1: 48 8b 45 e8 mov -0x18(%rbp),%rax | |
100000ca5: 48 05 01 00 00 00 add $0x1,%rax | |
100000cab: 48 89 45 e8 mov %rax,-0x18(%rbp) | |
100000caf: e9 b4 ff ff ff jmpq 100000c68 <_find_next_branch_right+0x18> | |
100000cb4: 48 8d 3d ee 11 00 00 lea 0x11ee(%rip),%rdi # 100001ea9 <_realloc$stub+0xdf> | |
return i; | |
} | |
} | |
// if the program is valid, this branch will not be taken. | |
printf("Attempted to execute a non-valid program. Aborting\n"); | |
100000cbb: b0 00 mov $0x0,%al | |
100000cbd: e8 fc 10 00 00 callq 100001dbe <_printf$stub> | |
abort(); | |
100000cc2: 89 45 e4 mov %eax,-0x1c(%rbp) | |
100000cc5: e8 b2 10 00 00 callq 100001d7c <_abort$stub> | |
100000cca: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) | |
0000000100000cd0 <_execute>: | |
} | |
void | |
execute(struct program prog) { | |
100000cd0: 55 push %rbp | |
100000cd1: 48 89 e5 mov %rsp,%rbp | |
100000cd4: 48 81 ec e0 75 00 00 sub $0x75e0,%rsp | |
100000cdb: 48 8d 45 10 lea 0x10(%rbp),%rax | |
100000cdf: 31 f6 xor %esi,%esi | |
100000ce1: b9 30 75 00 00 mov $0x7530,%ecx | |
100000ce6: 89 ca mov %ecx,%edx | |
100000ce8: 48 c7 c1 ff ff ff ff mov $0xffffffffffffffff,%rcx | |
100000cef: 48 8d bd c8 8a ff ff lea -0x7538(%rbp),%rdi | |
100000cf6: 4c 8b 05 13 13 00 00 mov 0x1313(%rip),%r8 # 100002010 <___stack_chk_guard$stub> | |
100000cfd: 4d 8b 00 mov (%r8),%r8 | |
100000d00: 4c 89 45 f8 mov %r8,-0x8(%rbp) | |
size_t new_pc = (pc); \ | |
op_value = (prog).ops[new_pc].op_value; \ | |
goto *dispatch_table[(prog).ops[new_pc].type]; \ | |
} while(0) | |
size_t pc = 0; | |
100000d04: 48 c7 85 b8 8a ff ff movq $0x0,-0x7548(%rbp) | |
100000d0b: 00 00 00 00 | |
char *memory_ptr = alloca(MEMORY_SIZE); | |
100000d0f: 48 89 bd b0 8a ff ff mov %rdi,-0x7550(%rbp) | |
memset(memory_ptr, 0, MEMORY_SIZE); | |
100000d16: 48 8b bd b0 8a ff ff mov -0x7550(%rbp),%rdi | |
100000d1d: 48 89 85 40 8a ff ff mov %rax,-0x75c0(%rbp) | |
100000d24: e8 47 10 00 00 callq 100001d70 <___memset_chk$stub> | |
100000d29: 48 89 85 38 8a ff ff mov %rax,-0x75c8(%rbp) | |
100000d30: 48 8d 05 79 13 00 00 lea 0x1379(%rip),%rax # 1000020b0 <_execute.dispatch_table> | |
DISPATCH(prog, pc); | |
100000d37: 48 8b 8d b8 8a ff ff mov -0x7548(%rbp),%rcx | |
100000d3e: 48 89 8d a8 8a ff ff mov %rcx,-0x7558(%rbp) | |
100000d45: 48 8b 8d a8 8a ff ff mov -0x7558(%rbp),%rcx | |
100000d4c: 48 8b 95 40 8a ff ff mov -0x75c0(%rbp),%rdx | |
100000d53: 48 8b 32 mov (%rdx),%rsi | |
100000d56: 8b 7c ce 04 mov 0x4(%rsi,%rcx,8),%edi | |
100000d5a: 89 bd c4 8a ff ff mov %edi,-0x753c(%rbp) | |
100000d60: 48 8b 8d a8 8a ff ff mov -0x7558(%rbp),%rcx | |
100000d67: 48 8b 32 mov (%rdx),%rsi | |
100000d6a: 8b 3c ce mov (%rsi,%rcx,8),%edi | |
100000d6d: 89 f9 mov %edi,%ecx | |
100000d6f: 48 8b 04 c8 mov (%rax,%rcx,8),%rax | |
100000d73: 48 89 85 30 8a ff ff mov %rax,-0x75d0(%rbp) | |
100000d7a: e9 44 05 00 00 jmpq 1000012c3 <_execute+0x5f3> | |
plus: | |
*memory_ptr += op_value; | |
100000d7f: 8b 85 c4 8a ff ff mov -0x753c(%rbp),%eax | |
100000d85: 48 8b 8d b0 8a ff ff mov -0x7550(%rbp),%rcx | |
100000d8c: 0f be 11 movsbl (%rcx),%edx | |
100000d8f: 01 c2 add %eax,%edx | |
100000d91: 40 88 d6 mov %dl,%sil | |
100000d94: 40 88 31 mov %sil,(%rcx) | |
100000d97: 48 8d 05 12 13 00 00 lea 0x1312(%rip),%rax # 1000020b0 <_execute.dispatch_table> | |
DISPATCH(prog, ++pc); | |
100000d9e: 48 8b 8d b8 8a ff ff mov -0x7548(%rbp),%rcx | |
100000da5: 48 81 c1 01 00 00 00 add $0x1,%rcx | |
100000dac: 48 89 8d b8 8a ff ff mov %rcx,-0x7548(%rbp) | |
100000db3: 48 89 8d a0 8a ff ff mov %rcx,-0x7560(%rbp) | |
100000dba: 48 8b 8d a0 8a ff ff mov -0x7560(%rbp),%rcx | |
100000dc1: 48 8b 95 40 8a ff ff mov -0x75c0(%rbp),%rdx | |
100000dc8: 48 8b 32 mov (%rdx),%rsi | |
100000dcb: 8b 7c ce 04 mov 0x4(%rsi,%rcx,8),%edi | |
100000dcf: 89 bd c4 8a ff ff mov %edi,-0x753c(%rbp) | |
100000dd5: 48 8b 8d a0 8a ff ff mov -0x7560(%rbp),%rcx | |
100000ddc: 48 8b 32 mov (%rdx),%rsi | |
100000ddf: 8b 3c ce mov (%rsi,%rcx,8),%edi | |
100000de2: 89 f9 mov %edi,%ecx | |
100000de4: 48 8b 04 c8 mov (%rax,%rcx,8),%rax | |
100000de8: 48 89 85 30 8a ff ff mov %rax,-0x75d0(%rbp) | |
100000def: e9 cf 04 00 00 jmpq 1000012c3 <_execute+0x5f3> | |
minus: | |
*memory_ptr -= op_value; | |
100000df4: 8b 85 c4 8a ff ff mov -0x753c(%rbp),%eax | |
100000dfa: 48 8b 8d b0 8a ff ff mov -0x7550(%rbp),%rcx | |
100000e01: 0f be 11 movsbl (%rcx),%edx | |
100000e04: 29 c2 sub %eax,%edx | |
100000e06: 40 88 d6 mov %dl,%sil | |
100000e09: 40 88 31 mov %sil,(%rcx) | |
100000e0c: 48 8d 05 9d 12 00 00 lea 0x129d(%rip),%rax # 1000020b0 <_execute.dispatch_table> | |
DISPATCH(prog, ++pc); | |
100000e13: 48 8b 8d b8 8a ff ff mov -0x7548(%rbp),%rcx | |
100000e1a: 48 81 c1 01 00 00 00 add $0x1,%rcx | |
100000e21: 48 89 8d b8 8a ff ff mov %rcx,-0x7548(%rbp) | |
100000e28: 48 89 8d 98 8a ff ff mov %rcx,-0x7568(%rbp) | |
100000e2f: 48 8b 8d 98 8a ff ff mov -0x7568(%rbp),%rcx | |
100000e36: 48 8b 95 40 8a ff ff mov -0x75c0(%rbp),%rdx | |
100000e3d: 48 8b 32 mov (%rdx),%rsi | |
100000e40: 8b 7c ce 04 mov 0x4(%rsi,%rcx,8),%edi | |
100000e44: 89 bd c4 8a ff ff mov %edi,-0x753c(%rbp) | |
100000e4a: 48 8b 8d 98 8a ff ff mov -0x7568(%rbp),%rcx | |
100000e51: 48 8b 32 mov (%rdx),%rsi | |
100000e54: 8b 3c ce mov (%rsi,%rcx,8),%edi | |
100000e57: 89 f9 mov %edi,%ecx | |
100000e59: 48 8b 04 c8 mov (%rax,%rcx,8),%rax | |
100000e5d: 48 89 85 30 8a ff ff mov %rax,-0x75d0(%rbp) | |
100000e64: e9 5a 04 00 00 jmpq 1000012c3 <_execute+0x5f3> | |
100000e69: 31 c0 xor %eax,%eax | |
100000e6b: 89 c1 mov %eax,%ecx | |
shift_left: | |
memory_ptr -= op_value; | |
100000e6d: 8b 85 c4 8a ff ff mov -0x753c(%rbp),%eax | |
100000e73: 48 8b 95 b0 8a ff ff mov -0x7550(%rbp),%rdx | |
100000e7a: 48 63 f0 movslq %eax,%rsi | |
100000e7d: 48 29 f1 sub %rsi,%rcx | |
100000e80: 48 01 ca add %rcx,%rdx | |
100000e83: 48 89 95 b0 8a ff ff mov %rdx,-0x7550(%rbp) | |
100000e8a: 48 8d 05 1f 12 00 00 lea 0x121f(%rip),%rax # 1000020b0 <_execute.dispatch_table> | |
DISPATCH(prog, ++pc); | |
100000e91: 48 8b 8d b8 8a ff ff mov -0x7548(%rbp),%rcx | |
100000e98: 48 81 c1 01 00 00 00 add $0x1,%rcx | |
100000e9f: 48 89 8d b8 8a ff ff mov %rcx,-0x7548(%rbp) | |
100000ea6: 48 89 8d 90 8a ff ff mov %rcx,-0x7570(%rbp) | |
100000ead: 48 8b 8d 90 8a ff ff mov -0x7570(%rbp),%rcx | |
100000eb4: 48 8b 95 40 8a ff ff mov -0x75c0(%rbp),%rdx | |
100000ebb: 48 8b 32 mov (%rdx),%rsi | |
100000ebe: 8b 7c ce 04 mov 0x4(%rsi,%rcx,8),%edi | |
100000ec2: 89 bd c4 8a ff ff mov %edi,-0x753c(%rbp) | |
100000ec8: 48 8b 8d 90 8a ff ff mov -0x7570(%rbp),%rcx | |
100000ecf: 48 8b 32 mov (%rdx),%rsi | |
100000ed2: 8b 3c ce mov (%rsi,%rcx,8),%edi | |
100000ed5: 89 f9 mov %edi,%ecx | |
100000ed7: 48 8b 04 c8 mov (%rax,%rcx,8),%rax | |
100000edb: 48 89 85 30 8a ff ff mov %rax,-0x75d0(%rbp) | |
100000ee2: e9 dc 03 00 00 jmpq 1000012c3 <_execute+0x5f3> | |
shift_right: | |
memory_ptr += op_value; | |
100000ee7: 8b 85 c4 8a ff ff mov -0x753c(%rbp),%eax | |
100000eed: 48 8b 8d b0 8a ff ff mov -0x7550(%rbp),%rcx | |
100000ef4: 48 63 d0 movslq %eax,%rdx | |
100000ef7: 48 01 d1 add %rdx,%rcx | |
100000efa: 48 89 8d b0 8a ff ff mov %rcx,-0x7550(%rbp) | |
100000f01: 48 8d 05 a8 11 00 00 lea 0x11a8(%rip),%rax # 1000020b0 <_execute.dispatch_table> | |
DISPATCH(prog, ++pc); | |
100000f08: 48 8b 8d b8 8a ff ff mov -0x7548(%rbp),%rcx | |
100000f0f: 48 81 c1 01 00 00 00 add $0x1,%rcx | |
100000f16: 48 89 8d b8 8a ff ff mov %rcx,-0x7548(%rbp) | |
100000f1d: 48 89 8d 88 8a ff ff mov %rcx,-0x7578(%rbp) | |
100000f24: 48 8b 8d 88 8a ff ff mov -0x7578(%rbp),%rcx | |
100000f2b: 48 8b 95 40 8a ff ff mov -0x75c0(%rbp),%rdx | |
100000f32: 48 8b 32 mov (%rdx),%rsi | |
100000f35: 8b 7c ce 04 mov 0x4(%rsi,%rcx,8),%edi | |
100000f39: 89 bd c4 8a ff ff mov %edi,-0x753c(%rbp) | |
100000f3f: 48 8b 8d 88 8a ff ff mov -0x7578(%rbp),%rcx | |
100000f46: 48 8b 32 mov (%rdx),%rsi | |
100000f49: 8b 3c ce mov (%rsi,%rcx,8),%edi | |
100000f4c: 89 f9 mov %edi,%ecx | |
100000f4e: 48 8b 04 c8 mov (%rax,%rcx,8),%rax | |
100000f52: 48 89 85 30 8a ff ff mov %rax,-0x75d0(%rbp) | |
100000f59: e9 65 03 00 00 jmpq 1000012c3 <_execute+0x5f3> | |
branch_left: | |
if (*memory_ptr == 0) { | |
100000f5e: 48 8b 85 b0 8a ff ff mov -0x7550(%rbp),%rax | |
100000f65: 0f be 08 movsbl (%rax),%ecx | |
100000f68: 81 f9 00 00 00 00 cmp $0x0,%ecx | |
100000f6e: 0f 85 0e 00 00 00 jne 100000f82 <_execute+0x2b2> | |
pc = op_value; | |
100000f74: 48 63 85 c4 8a ff ff movslq -0x753c(%rbp),%rax | |
100000f7b: 48 89 85 b8 8a ff ff mov %rax,-0x7548(%rbp) | |
} | |
DISPATCH(prog, ++pc); | |
100000f82: e9 00 00 00 00 jmpq 100000f87 <_execute+0x2b7> | |
100000f87: 48 8d 05 22 11 00 00 lea 0x1122(%rip),%rax # 1000020b0 <_execute.dispatch_table> | |
100000f8e: 48 8b 8d b8 8a ff ff mov -0x7548(%rbp),%rcx | |
100000f95: 48 81 c1 01 00 00 00 add $0x1,%rcx | |
100000f9c: 48 89 8d b8 8a ff ff mov %rcx,-0x7548(%rbp) | |
100000fa3: 48 89 8d 80 8a ff ff mov %rcx,-0x7580(%rbp) | |
100000faa: 48 8b 8d 80 8a ff ff mov -0x7580(%rbp),%rcx | |
100000fb1: 48 8b 95 40 8a ff ff mov -0x75c0(%rbp),%rdx | |
100000fb8: 48 8b 32 mov (%rdx),%rsi | |
100000fbb: 8b 7c ce 04 mov 0x4(%rsi,%rcx,8),%edi | |
100000fbf: 89 bd c4 8a ff ff mov %edi,-0x753c(%rbp) | |
100000fc5: 48 8b 8d 80 8a ff ff mov -0x7580(%rbp),%rcx | |
100000fcc: 48 8b 32 mov (%rdx),%rsi | |
100000fcf: 8b 3c ce mov (%rsi,%rcx,8),%edi | |
100000fd2: 89 f9 mov %edi,%ecx | |
100000fd4: 48 8b 04 c8 mov (%rax,%rcx,8),%rax | |
100000fd8: 48 89 85 30 8a ff ff mov %rax,-0x75d0(%rbp) | |
100000fdf: e9 df 02 00 00 jmpq 1000012c3 <_execute+0x5f3> | |
branch_right: | |
if (*memory_ptr != 0) { | |
100000fe4: 48 8b 85 b0 8a ff ff mov -0x7550(%rbp),%rax | |
100000feb: 0f be 08 movsbl (%rax),%ecx | |
100000fee: 81 f9 00 00 00 00 cmp $0x0,%ecx | |
100000ff4: 0f 84 0e 00 00 00 je 100001008 <_execute+0x338> | |
pc = op_value; | |
100000ffa: 48 63 85 c4 8a ff ff movslq -0x753c(%rbp),%rax | |
100001001: 48 89 85 b8 8a ff ff mov %rax,-0x7548(%rbp) | |
} | |
DISPATCH(prog, ++pc); | |
100001008: e9 00 00 00 00 jmpq 10000100d <_execute+0x33d> | |
10000100d: 48 8d 05 9c 10 00 00 lea 0x109c(%rip),%rax # 1000020b0 <_execute.dispatch_table> | |
100001014: 48 8b 8d b8 8a ff ff mov -0x7548(%rbp),%rcx | |
10000101b: 48 81 c1 01 00 00 00 add $0x1,%rcx | |
100001022: 48 89 8d b8 8a ff ff mov %rcx,-0x7548(%rbp) | |
100001029: 48 89 8d 78 8a ff ff mov %rcx,-0x7588(%rbp) | |
100001030: 48 8b 8d 78 8a ff ff mov -0x7588(%rbp),%rcx | |
100001037: 48 8b 95 40 8a ff ff mov -0x75c0(%rbp),%rdx | |
10000103e: 48 8b 32 mov (%rdx),%rsi | |
100001041: 8b 7c ce 04 mov 0x4(%rsi,%rcx,8),%edi | |
100001045: 89 bd c4 8a ff ff mov %edi,-0x753c(%rbp) | |
10000104b: 48 8b 8d 78 8a ff ff mov -0x7588(%rbp),%rcx | |
100001052: 48 8b 32 mov (%rdx),%rsi | |
100001055: 8b 3c ce mov (%rsi,%rcx,8),%edi | |
100001058: 89 f9 mov %edi,%ecx | |
10000105a: 48 8b 04 c8 mov (%rax,%rcx,8),%rax | |
10000105e: 48 89 85 30 8a ff ff mov %rax,-0x75d0(%rbp) | |
100001065: e9 59 02 00 00 jmpq 1000012c3 <_execute+0x5f3> | |
output: | |
for (int i = 0; i < op_value; i++) { | |
10000106a: c7 85 74 8a ff ff 00 movl $0x0,-0x758c(%rbp) | |
100001071: 00 00 00 | |
100001074: 8b 85 74 8a ff ff mov -0x758c(%rbp),%eax | |
10000107a: 3b 85 c4 8a ff ff cmp -0x753c(%rbp),%eax | |
100001080: 0f 8d 40 00 00 00 jge 1000010c6 <_execute+0x3f6> | |
putchar(*memory_ptr); | |
100001086: 48 8b 85 b0 8a ff ff mov -0x7550(%rbp),%rax | |
10000108d: 0f be 38 movsbl (%rax),%edi | |
100001090: e8 2f 0d 00 00 callq 100001dc4 <_putchar$stub> | |
100001095: 48 8b 0d 84 0f 00 00 mov 0xf84(%rip),%rcx # 100002020 <___stdoutp$stub> | |
fflush(stdout); | |
10000109c: 48 8b 39 mov (%rcx),%rdi | |
10000109f: 89 85 2c 8a ff ff mov %eax,-0x75d4(%rbp) | |
1000010a5: e8 ea 0c 00 00 callq 100001d94 <_fflush$stub> | |
1000010aa: 89 85 28 8a ff ff mov %eax,-0x75d8(%rbp) | |
if (*memory_ptr != 0) { | |
pc = op_value; | |
} | |
DISPATCH(prog, ++pc); | |
output: | |
for (int i = 0; i < op_value; i++) { | |
1000010b0: 8b 85 74 8a ff ff mov -0x758c(%rbp),%eax | |
1000010b6: 05 01 00 00 00 add $0x1,%eax | |
1000010bb: 89 85 74 8a ff ff mov %eax,-0x758c(%rbp) | |
1000010c1: e9 ae ff ff ff jmpq 100001074 <_execute+0x3a4> | |
putchar(*memory_ptr); | |
fflush(stdout); | |
} | |
DISPATCH(prog, ++pc); | |
1000010c6: e9 00 00 00 00 jmpq 1000010cb <_execute+0x3fb> | |
1000010cb: 48 8d 05 de 0f 00 00 lea 0xfde(%rip),%rax # 1000020b0 <_execute.dispatch_table> | |
1000010d2: 48 8b 8d b8 8a ff ff mov -0x7548(%rbp),%rcx | |
1000010d9: 48 81 c1 01 00 00 00 add $0x1,%rcx | |
1000010e0: 48 89 8d b8 8a ff ff mov %rcx,-0x7548(%rbp) | |
1000010e7: 48 89 8d 68 8a ff ff mov %rcx,-0x7598(%rbp) | |
1000010ee: 48 8b 8d 68 8a ff ff mov -0x7598(%rbp),%rcx | |
1000010f5: 48 8b 95 40 8a ff ff mov -0x75c0(%rbp),%rdx | |
1000010fc: 48 8b 32 mov (%rdx),%rsi | |
1000010ff: 8b 7c ce 04 mov 0x4(%rsi,%rcx,8),%edi | |
100001103: 89 bd c4 8a ff ff mov %edi,-0x753c(%rbp) | |
100001109: 48 8b 8d 68 8a ff ff mov -0x7598(%rbp),%rcx | |
100001110: 48 8b 32 mov (%rdx),%rsi | |
100001113: 8b 3c ce mov (%rsi,%rcx,8),%edi | |
100001116: 89 f9 mov %edi,%ecx | |
100001118: 48 8b 04 c8 mov (%rax,%rcx,8),%rax | |
10000111c: 48 89 85 30 8a ff ff mov %rax,-0x75d0(%rbp) | |
100001123: e9 9b 01 00 00 jmpq 1000012c3 <_execute+0x5f3> | |
input: | |
for (int i = 0; i < op_value; i++) { | |
100001128: c7 85 64 8a ff ff 00 movl $0x0,-0x759c(%rbp) | |
10000112f: 00 00 00 | |
100001132: 8b 85 64 8a ff ff mov -0x759c(%rbp),%eax | |
100001138: 3b 85 c4 8a ff ff cmp -0x753c(%rbp),%eax | |
10000113e: 0f 8d 26 00 00 00 jge 10000116a <_execute+0x49a> | |
*memory_ptr = getchar(); | |
100001144: e8 69 0c 00 00 callq 100001db2 <_getchar$stub> | |
100001149: 88 c1 mov %al,%cl | |
10000114b: 48 8b 95 b0 8a ff ff mov -0x7550(%rbp),%rdx | |
100001152: 88 0a mov %cl,(%rdx) | |
putchar(*memory_ptr); | |
fflush(stdout); | |
} | |
DISPATCH(prog, ++pc); | |
input: | |
for (int i = 0; i < op_value; i++) { | |
100001154: 8b 85 64 8a ff ff mov -0x759c(%rbp),%eax | |
10000115a: 05 01 00 00 00 add $0x1,%eax | |
10000115f: 89 85 64 8a ff ff mov %eax,-0x759c(%rbp) | |
100001165: e9 c8 ff ff ff jmpq 100001132 <_execute+0x462> | |
*memory_ptr = getchar(); | |
} | |
DISPATCH(prog, ++pc); | |
10000116a: e9 00 00 00 00 jmpq 10000116f <_execute+0x49f> | |
10000116f: 48 8d 05 3a 0f 00 00 lea 0xf3a(%rip),%rax # 1000020b0 <_execute.dispatch_table> | |
100001176: 48 8b 8d b8 8a ff ff mov -0x7548(%rbp),%rcx | |
10000117d: 48 81 c1 01 00 00 00 add $0x1,%rcx | |
100001184: 48 89 8d b8 8a ff ff mov %rcx,-0x7548(%rbp) | |
10000118b: 48 89 8d 58 8a ff ff mov %rcx,-0x75a8(%rbp) | |
100001192: 48 8b 8d 58 8a ff ff mov -0x75a8(%rbp),%rcx | |
100001199: 48 8b 95 40 8a ff ff mov -0x75c0(%rbp),%rdx | |
1000011a0: 48 8b 32 mov (%rdx),%rsi | |
1000011a3: 8b 7c ce 04 mov 0x4(%rsi,%rcx,8),%edi | |
1000011a7: 89 bd c4 8a ff ff mov %edi,-0x753c(%rbp) | |
1000011ad: 48 8b 8d 58 8a ff ff mov -0x75a8(%rbp),%rcx | |
1000011b4: 48 8b 32 mov (%rdx),%rsi | |
1000011b7: 8b 3c ce mov (%rsi,%rcx,8),%edi | |
1000011ba: 89 f9 mov %edi,%ecx | |
1000011bc: 48 8b 04 c8 mov (%rax,%rcx,8),%rax | |
1000011c0: 48 89 85 30 8a ff ff mov %rax,-0x75d0(%rbp) | |
1000011c7: e9 f7 00 00 00 jmpq 1000012c3 <_execute+0x5f3> | |
exit: | |
destroy_program(&prog); | |
1000011cc: 48 8b bd 40 8a ff ff mov -0x75c0(%rbp),%rdi | |
1000011d3: e8 38 09 00 00 callq 100001b10 <_destroy_program> | |
return; | |
1000011d8: e9 c9 00 00 00 jmpq 1000012a6 <_execute+0x5d6> | |
zero: | |
*memory_ptr = 0; | |
1000011dd: 48 8b 85 b0 8a ff ff mov -0x7550(%rbp),%rax | |
1000011e4: c6 00 00 movb $0x0,(%rax) | |
1000011e7: 48 8d 05 c2 0e 00 00 lea 0xec2(%rip),%rax # 1000020b0 <_execute.dispatch_table> | |
DISPATCH(prog, ++pc); | |
1000011ee: 48 8b 8d b8 8a ff ff mov -0x7548(%rbp),%rcx | |
1000011f5: 48 81 c1 01 00 00 00 add $0x1,%rcx | |
1000011fc: 48 89 8d b8 8a ff ff mov %rcx,-0x7548(%rbp) | |
100001203: 48 89 8d 50 8a ff ff mov %rcx,-0x75b0(%rbp) | |
10000120a: 48 8b 8d 50 8a ff ff mov -0x75b0(%rbp),%rcx | |
100001211: 48 8b 95 40 8a ff ff mov -0x75c0(%rbp),%rdx | |
100001218: 48 8b 32 mov (%rdx),%rsi | |
10000121b: 8b 7c ce 04 mov 0x4(%rsi,%rcx,8),%edi | |
10000121f: 89 bd c4 8a ff ff mov %edi,-0x753c(%rbp) | |
100001225: 48 8b 8d 50 8a ff ff mov -0x75b0(%rbp),%rcx | |
10000122c: 48 8b 32 mov (%rdx),%rsi | |
10000122f: 8b 3c ce mov (%rsi,%rcx,8),%edi | |
100001232: 89 f9 mov %edi,%ecx | |
100001234: 48 8b 04 c8 mov (%rax,%rcx,8),%rax | |
100001238: 48 89 85 30 8a ff ff mov %rax,-0x75d0(%rbp) | |
10000123f: e9 7f 00 00 00 jmpq 1000012c3 <_execute+0x5f3> | |
nop: | |
DISPATCH(prog, ++pc); | |
100001244: e9 00 00 00 00 jmpq 100001249 <_execute+0x579> | |
100001249: 48 8d 05 60 0e 00 00 lea 0xe60(%rip),%rax # 1000020b0 <_execute.dispatch_table> | |
100001250: 48 8b 8d b8 8a ff ff mov -0x7548(%rbp),%rcx | |
100001257: 48 81 c1 01 00 00 00 add $0x1,%rcx | |
10000125e: 48 89 8d b8 8a ff ff mov %rcx,-0x7548(%rbp) | |
100001265: 48 89 8d 48 8a ff ff mov %rcx,-0x75b8(%rbp) | |
10000126c: 48 8b 8d 48 8a ff ff mov -0x75b8(%rbp),%rcx | |
100001273: 48 8b 95 40 8a ff ff mov -0x75c0(%rbp),%rdx | |
10000127a: 48 8b 32 mov (%rdx),%rsi | |
10000127d: 8b 7c ce 04 mov 0x4(%rsi,%rcx,8),%edi | |
100001281: 89 bd c4 8a ff ff mov %edi,-0x753c(%rbp) | |
100001287: 48 8b 8d 48 8a ff ff mov -0x75b8(%rbp),%rcx | |
10000128e: 48 8b 32 mov (%rdx),%rsi | |
100001291: 8b 3c ce mov (%rsi,%rcx,8),%edi | |
100001294: 89 f9 mov %edi,%ecx | |
100001296: 48 8b 04 c8 mov (%rax,%rcx,8),%rax | |
10000129a: 48 89 85 30 8a ff ff mov %rax,-0x75d0(%rbp) | |
1000012a1: e9 1d 00 00 00 jmpq 1000012c3 <_execute+0x5f3> | |
1000012a6: 48 8b 05 63 0d 00 00 mov 0xd63(%rip),%rax # 100002010 <___stack_chk_guard$stub> | |
1000012ad: 48 8b 00 mov (%rax),%rax | |
1000012b0: 48 3b 45 f8 cmp -0x8(%rbp),%rax | |
1000012b4: 0f 85 12 00 00 00 jne 1000012cc <_execute+0x5fc> | |
#undef DISPATCH | |
} | |
1000012ba: 48 81 c4 e0 75 00 00 add $0x75e0,%rsp | |
1000012c1: 5d pop %rbp | |
1000012c2: c3 retq | |
1000012c3: 48 8b 85 30 8a ff ff mov -0x75d0(%rbp),%rax | |
1000012ca: ff e0 jmpq *%rax | |
1000012cc: e8 a5 0a 00 00 callq 100001d76 <___stack_chk_fail$stub> | |
1000012d1: 66 66 66 66 66 66 2e data16 data16 data16 data16 data16 nopw %cs:0x0(%rax,%rax,1) | |
1000012d8: 0f 1f 84 00 00 00 00 | |
1000012df: 00 | |
00000001000012e0 <_main>: | |
int | |
main(int argc, char **argv) | |
{ | |
1000012e0: 55 push %rbp | |
1000012e1: 48 89 e5 mov %rsp,%rbp | |
1000012e4: 48 83 ec 70 sub $0x70,%rsp | |
1000012e8: 89 7d fc mov %edi,-0x4(%rbp) | |
1000012eb: 48 89 75 f0 mov %rsi,-0x10(%rbp) | |
// first - read the program from standard in | |
// struct program prog = read_program(stdin); | |
if (argc != 2) { | |
1000012ef: 81 7d fc 02 00 00 00 cmpl $0x2,-0x4(%rbp) | |
1000012f6: 0f 84 22 00 00 00 je 10000131e <_main+0x3e> | |
1000012fc: 48 8d 3d da 0b 00 00 lea 0xbda(%rip),%rdi # 100001edd <_realloc$stub+0x113> | |
printf("usage: %s <filename>\n", argv[0]); | |
100001303: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001307: 48 8b 30 mov (%rax),%rsi | |
10000130a: b0 00 mov $0x0,%al | |
10000130c: e8 ad 0a 00 00 callq 100001dbe <_printf$stub> | |
100001311: bf 01 00 00 00 mov $0x1,%edi | |
exit(1); | |
100001316: 89 45 b4 mov %eax,-0x4c(%rbp) | |
100001319: e8 6a 0a 00 00 callq 100001d88 <_exit$stub> | |
10000131e: 48 8d 35 ce 0b 00 00 lea 0xbce(%rip),%rsi # 100001ef3 <_realloc$stub+0x129> | |
} | |
FILE *f = fopen(argv[1], "r"); | |
100001325: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001329: 48 8b 78 08 mov 0x8(%rax),%rdi | |
10000132d: e8 6e 0a 00 00 callq 100001da0 <_fopen$stub> | |
100001332: 48 89 45 e8 mov %rax,-0x18(%rbp) | |
if (f == NULL) { | |
100001336: 48 81 7d e8 00 00 00 cmpq $0x0,-0x18(%rbp) | |
10000133d: 00 | |
10000133e: 0f 85 16 00 00 00 jne 10000135a <_main+0x7a> | |
100001344: 48 8d 3d aa 0b 00 00 lea 0xbaa(%rip),%rdi # 100001ef5 <_realloc$stub+0x12b> | |
perror("failed to open file"); | |
10000134b: e8 68 0a 00 00 callq 100001db8 <_perror$stub> | |
100001350: bf 01 00 00 00 mov $0x1,%edi | |
exit(1); | |
100001355: e8 2e 0a 00 00 callq 100001d88 <_exit$stub> | |
10000135a: 48 8d 7d d0 lea -0x30(%rbp),%rdi | |
} | |
struct program prog = read_program(f); | |
10000135e: 48 8b 75 e8 mov -0x18(%rbp),%rsi | |
100001362: e8 89 03 00 00 callq 1000016f0 <_read_program> | |
100001367: 48 8d 7d b8 lea -0x48(%rbp),%rdi | |
10000136b: 48 8d 75 d0 lea -0x30(%rbp),%rsi | |
prog = aggregate_ops(&prog); | |
10000136f: e8 0c 06 00 00 callq 100001980 <_aggregate_ops> | |
100001374: 48 8d 7d d0 lea -0x30(%rbp),%rdi | |
100001378: 48 8b 75 b8 mov -0x48(%rbp),%rsi | |
10000137c: 48 89 75 d0 mov %rsi,-0x30(%rbp) | |
100001380: 48 8b 75 c0 mov -0x40(%rbp),%rsi | |
100001384: 48 89 75 d8 mov %rsi,-0x28(%rbp) | |
100001388: 48 8b 75 c8 mov -0x38(%rbp),%rsi | |
10000138c: 48 89 75 e0 mov %rsi,-0x20(%rbp) | |
if (!mark_branches(&prog)) { | |
100001390: e8 9b 07 00 00 callq 100001b30 <_mark_branches> | |
100001395: a8 01 test $0x1,%al | |
100001397: 0f 85 1b 00 00 00 jne 1000013b8 <_main+0xd8> | |
10000139d: 48 8d 3d 65 0b 00 00 lea 0xb65(%rip),%rdi # 100001f09 <_realloc$stub+0x13f> | |
printf("Invalid branches\n"); | |
1000013a4: b0 00 mov $0x0,%al | |
1000013a6: e8 13 0a 00 00 callq 100001dbe <_printf$stub> | |
1000013ab: bf 01 00 00 00 mov $0x1,%edi | |
exit(1); | |
1000013b0: 89 45 b0 mov %eax,-0x50(%rbp) | |
1000013b3: e8 d0 09 00 00 callq 100001d88 <_exit$stub> | |
1000013b8: 48 8d 7d d0 lea -0x30(%rbp),%rdi | |
} | |
zero_cell_optimization(&prog); | |
1000013bc: e8 7f 08 00 00 callq 100001c40 <_zero_cell_optimization> | |
1000013c1: 48 8d 7d d0 lea -0x30(%rbp),%rdi | |
// next, execute it. | |
execute(prog); | |
1000013c5: 48 8b 07 mov (%rdi),%rax | |
1000013c8: 48 89 04 24 mov %rax,(%rsp) | |
1000013cc: 48 8b 47 08 mov 0x8(%rdi),%rax | |
1000013d0: 48 89 44 24 08 mov %rax,0x8(%rsp) | |
1000013d5: 48 8b 47 10 mov 0x10(%rdi),%rax | |
1000013d9: 48 89 44 24 10 mov %rax,0x10(%rsp) | |
1000013de: e8 ed f8 ff ff callq 100000cd0 <_execute> | |
fclose(f); | |
1000013e3: 48 8b 7d e8 mov -0x18(%rbp),%rdi | |
1000013e7: e8 a2 09 00 00 callq 100001d8e <_fclose$stub> | |
1000013ec: 31 c9 xor %ecx,%ecx | |
} | |
1000013ee: 89 45 ac mov %eax,-0x54(%rbp) | |
1000013f1: 89 c8 mov %ecx,%eax | |
1000013f3: 48 83 c4 70 add $0x70,%rsp | |
1000013f7: 5d pop %rbp | |
1000013f8: c3 retq | |
1000013f9: 90 nop | |
1000013fa: 90 nop | |
1000013fb: 90 nop | |
1000013fc: 90 nop | |
1000013fd: 90 nop | |
1000013fe: 90 nop | |
1000013ff: 90 nop | |
0000000100001400 <_debug_dump_program>: | |
#define INITIAL_PROGRAM_SIZE 1 << 8 | |
#define SCALING_FACTOR 2 | |
#define BRANCH_STACK_SIZE 256 | |
void | |
debug_dump_program(struct program *prog) { | |
100001400: 55 push %rbp | |
100001401: 48 89 e5 mov %rsp,%rbp | |
100001404: 48 81 ec 80 00 00 00 sub $0x80,%rsp | |
10000140b: 48 89 7d f8 mov %rdi,-0x8(%rbp) | |
for (size_t i = 0; i < prog->length; i++) { | |
10000140f: 48 c7 45 f0 00 00 00 movq $0x0,-0x10(%rbp) | |
100001416: 00 | |
100001417: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
10000141b: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
10000141f: 48 3b 41 08 cmp 0x8(%rcx),%rax | |
100001423: 0f 83 76 02 00 00 jae 10000169f <_debug_dump_program+0x29f> | |
struct brainfuck_op op = prog->ops[i]; | |
100001429: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
10000142d: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
100001431: 48 8b 09 mov (%rcx),%rcx | |
100001434: 48 8b 04 c1 mov (%rcx,%rax,8),%rax | |
100001438: 48 89 45 e8 mov %rax,-0x18(%rbp) | |
switch(op.type) { | |
10000143c: 8b 55 e8 mov -0x18(%rbp),%edx | |
10000143f: 89 d0 mov %edx,%eax | |
100001441: 48 89 c1 mov %rax,%rcx | |
100001444: 48 83 e9 0a sub $0xa,%rcx | |
100001448: 48 89 45 e0 mov %rax,-0x20(%rbp) | |
10000144c: 48 89 4d d8 mov %rcx,-0x28(%rbp) | |
100001450: 0f 87 31 02 00 00 ja 100001687 <_debug_dump_program+0x287> | |
100001456: 48 8d 05 5f 02 00 00 lea 0x25f(%rip),%rax # 1000016bc <_debug_dump_program+0x2bc> | |
10000145d: 48 8b 4d e0 mov -0x20(%rbp),%rcx | |
100001461: 48 63 14 88 movslq (%rax,%rcx,4),%rdx | |
100001465: 48 01 c2 add %rax,%rdx | |
100001468: ff e2 jmpq *%rdx | |
case PLUS: | |
if (op.op_value != 0) | |
10000146a: 81 7d ec 00 00 00 00 cmpl $0x0,-0x14(%rbp) | |
100001471: 0f 84 19 00 00 00 je 100001490 <_debug_dump_program+0x90> | |
100001477: 48 8d 3d 9d 0a 00 00 lea 0xa9d(%rip),%rdi # 100001f1b <_realloc$stub+0x151> | |
printf("+(%d)", op.op_value); | |
10000147e: 8b 75 ec mov -0x14(%rbp),%esi | |
100001481: b0 00 mov $0x0,%al | |
100001483: e8 36 09 00 00 callq 100001dbe <_printf$stub> | |
100001488: 89 45 d4 mov %eax,-0x2c(%rbp) | |
10000148b: e9 11 00 00 00 jmpq 1000014a1 <_debug_dump_program+0xa1> | |
100001490: 48 8d 3d 8a 0a 00 00 lea 0xa8a(%rip),%rdi # 100001f21 <_realloc$stub+0x157> | |
else | |
printf("+"); | |
100001497: b0 00 mov $0x0,%al | |
100001499: e8 20 09 00 00 callq 100001dbe <_printf$stub> | |
10000149e: 89 45 d0 mov %eax,-0x30(%rbp) | |
break; | |
1000014a1: e9 e1 01 00 00 jmpq 100001687 <_debug_dump_program+0x287> | |
case MINUS: | |
if (op.op_value != 0) | |
1000014a6: 81 7d ec 00 00 00 00 cmpl $0x0,-0x14(%rbp) | |
1000014ad: 0f 84 19 00 00 00 je 1000014cc <_debug_dump_program+0xcc> | |
1000014b3: 48 8d 3d 69 0a 00 00 lea 0xa69(%rip),%rdi # 100001f23 <_realloc$stub+0x159> | |
printf("-(%d)", op.op_value); | |
1000014ba: 8b 75 ec mov -0x14(%rbp),%esi | |
1000014bd: b0 00 mov $0x0,%al | |
1000014bf: e8 fa 08 00 00 callq 100001dbe <_printf$stub> | |
1000014c4: 89 45 cc mov %eax,-0x34(%rbp) | |
1000014c7: e9 11 00 00 00 jmpq 1000014dd <_debug_dump_program+0xdd> | |
1000014cc: 48 8d 3d 56 0a 00 00 lea 0xa56(%rip),%rdi # 100001f29 <_realloc$stub+0x15f> | |
else | |
printf("-"); | |
1000014d3: b0 00 mov $0x0,%al | |
1000014d5: e8 e4 08 00 00 callq 100001dbe <_printf$stub> | |
1000014da: 89 45 c8 mov %eax,-0x38(%rbp) | |
break; | |
1000014dd: e9 a5 01 00 00 jmpq 100001687 <_debug_dump_program+0x287> | |
case SHIFT_LEFT: | |
if (op.op_value != 0) | |
1000014e2: 81 7d ec 00 00 00 00 cmpl $0x0,-0x14(%rbp) | |
1000014e9: 0f 84 19 00 00 00 je 100001508 <_debug_dump_program+0x108> | |
1000014ef: 48 8d 3d 35 0a 00 00 lea 0xa35(%rip),%rdi # 100001f2b <_realloc$stub+0x161> | |
printf("<(%d)", op.op_value); | |
1000014f6: 8b 75 ec mov -0x14(%rbp),%esi | |
1000014f9: b0 00 mov $0x0,%al | |
1000014fb: e8 be 08 00 00 callq 100001dbe <_printf$stub> | |
100001500: 89 45 c4 mov %eax,-0x3c(%rbp) | |
100001503: e9 11 00 00 00 jmpq 100001519 <_debug_dump_program+0x119> | |
100001508: 48 8d 3d 22 0a 00 00 lea 0xa22(%rip),%rdi # 100001f31 <_realloc$stub+0x167> | |
else | |
printf("<"); | |
10000150f: b0 00 mov $0x0,%al | |
100001511: e8 a8 08 00 00 callq 100001dbe <_printf$stub> | |
100001516: 89 45 c0 mov %eax,-0x40(%rbp) | |
break; | |
100001519: e9 69 01 00 00 jmpq 100001687 <_debug_dump_program+0x287> | |
case SHIFT_RIGHT: | |
if (op.op_value != 0) | |
10000151e: 81 7d ec 00 00 00 00 cmpl $0x0,-0x14(%rbp) | |
100001525: 0f 84 19 00 00 00 je 100001544 <_debug_dump_program+0x144> | |
10000152b: 48 8d 3d 01 0a 00 00 lea 0xa01(%rip),%rdi # 100001f33 <_realloc$stub+0x169> | |
printf(">(%d)", op.op_value); | |
100001532: 8b 75 ec mov -0x14(%rbp),%esi | |
100001535: b0 00 mov $0x0,%al | |
100001537: e8 82 08 00 00 callq 100001dbe <_printf$stub> | |
10000153c: 89 45 bc mov %eax,-0x44(%rbp) | |
10000153f: e9 11 00 00 00 jmpq 100001555 <_debug_dump_program+0x155> | |
100001544: 48 8d 3d ee 09 00 00 lea 0x9ee(%rip),%rdi # 100001f39 <_realloc$stub+0x16f> | |
else | |
printf(">"); | |
10000154b: b0 00 mov $0x0,%al | |
10000154d: e8 6c 08 00 00 callq 100001dbe <_printf$stub> | |
100001552: 89 45 b8 mov %eax,-0x48(%rbp) | |
break; | |
100001555: e9 2d 01 00 00 jmpq 100001687 <_debug_dump_program+0x287> | |
case BRANCH_LEFT: | |
if (op.op_value != 0) | |
10000155a: 81 7d ec 00 00 00 00 cmpl $0x0,-0x14(%rbp) | |
100001561: 0f 84 19 00 00 00 je 100001580 <_debug_dump_program+0x180> | |
100001567: 48 8d 3d cd 09 00 00 lea 0x9cd(%rip),%rdi # 100001f3b <_realloc$stub+0x171> | |
printf("[(%d)", op.op_value); | |
10000156e: 8b 75 ec mov -0x14(%rbp),%esi | |
100001571: b0 00 mov $0x0,%al | |
100001573: e8 46 08 00 00 callq 100001dbe <_printf$stub> | |
100001578: 89 45 b4 mov %eax,-0x4c(%rbp) | |
10000157b: e9 11 00 00 00 jmpq 100001591 <_debug_dump_program+0x191> | |
100001580: 48 8d 3d ba 09 00 00 lea 0x9ba(%rip),%rdi # 100001f41 <_realloc$stub+0x177> | |
else | |
printf("["); | |
100001587: b0 00 mov $0x0,%al | |
100001589: e8 30 08 00 00 callq 100001dbe <_printf$stub> | |
10000158e: 89 45 b0 mov %eax,-0x50(%rbp) | |
break; | |
100001591: e9 f1 00 00 00 jmpq 100001687 <_debug_dump_program+0x287> | |
case BRANCH_RIGHT: | |
if (op.op_value != 0) | |
100001596: 81 7d ec 00 00 00 00 cmpl $0x0,-0x14(%rbp) | |
10000159d: 0f 84 19 00 00 00 je 1000015bc <_debug_dump_program+0x1bc> | |
1000015a3: 48 8d 3d 99 09 00 00 lea 0x999(%rip),%rdi # 100001f43 <_realloc$stub+0x179> | |
printf("](%d)", op.op_value); | |
1000015aa: 8b 75 ec mov -0x14(%rbp),%esi | |
1000015ad: b0 00 mov $0x0,%al | |
1000015af: e8 0a 08 00 00 callq 100001dbe <_printf$stub> | |
1000015b4: 89 45 ac mov %eax,-0x54(%rbp) | |
1000015b7: e9 11 00 00 00 jmpq 1000015cd <_debug_dump_program+0x1cd> | |
1000015bc: 48 8d 3d 86 09 00 00 lea 0x986(%rip),%rdi # 100001f49 <_realloc$stub+0x17f> | |
else | |
printf("]"); | |
1000015c3: b0 00 mov $0x0,%al | |
1000015c5: e8 f4 07 00 00 callq 100001dbe <_printf$stub> | |
1000015ca: 89 45 a8 mov %eax,-0x58(%rbp) | |
break; | |
1000015cd: e9 b5 00 00 00 jmpq 100001687 <_debug_dump_program+0x287> | |
case INPUT: | |
if (op.op_value != 0) | |
1000015d2: 81 7d ec 00 00 00 00 cmpl $0x0,-0x14(%rbp) | |
1000015d9: 0f 84 19 00 00 00 je 1000015f8 <_debug_dump_program+0x1f8> | |
1000015df: 48 8d 3d 65 09 00 00 lea 0x965(%rip),%rdi # 100001f4b <_realloc$stub+0x181> | |
printf(",(%d)", op.op_value); | |
1000015e6: 8b 75 ec mov -0x14(%rbp),%esi | |
1000015e9: b0 00 mov $0x0,%al | |
1000015eb: e8 ce 07 00 00 callq 100001dbe <_printf$stub> | |
1000015f0: 89 45 a4 mov %eax,-0x5c(%rbp) | |
1000015f3: e9 11 00 00 00 jmpq 100001609 <_debug_dump_program+0x209> | |
1000015f8: 48 8d 3d 52 09 00 00 lea 0x952(%rip),%rdi # 100001f51 <_realloc$stub+0x187> | |
else | |
printf(","); | |
1000015ff: b0 00 mov $0x0,%al | |
100001601: e8 b8 07 00 00 callq 100001dbe <_printf$stub> | |
100001606: 89 45 a0 mov %eax,-0x60(%rbp) | |
break; | |
100001609: e9 79 00 00 00 jmpq 100001687 <_debug_dump_program+0x287> | |
case OUTPUT: | |
if (op.op_value != 0) | |
10000160e: 81 7d ec 00 00 00 00 cmpl $0x0,-0x14(%rbp) | |
100001615: 0f 84 19 00 00 00 je 100001634 <_debug_dump_program+0x234> | |
10000161b: 48 8d 3d 31 09 00 00 lea 0x931(%rip),%rdi # 100001f53 <_realloc$stub+0x189> | |
printf(".(%d)", op.op_value); | |
100001622: 8b 75 ec mov -0x14(%rbp),%esi | |
100001625: b0 00 mov $0x0,%al | |
100001627: e8 92 07 00 00 callq 100001dbe <_printf$stub> | |
10000162c: 89 45 9c mov %eax,-0x64(%rbp) | |
10000162f: e9 11 00 00 00 jmpq 100001645 <_debug_dump_program+0x245> | |
100001634: 48 8d 3d 1e 09 00 00 lea 0x91e(%rip),%rdi # 100001f59 <_realloc$stub+0x18f> | |
else | |
printf("."); | |
10000163b: b0 00 mov $0x0,%al | |
10000163d: e8 7c 07 00 00 callq 100001dbe <_printf$stub> | |
100001642: 89 45 98 mov %eax,-0x68(%rbp) | |
break; | |
100001645: e9 3d 00 00 00 jmpq 100001687 <_debug_dump_program+0x287> | |
10000164a: 48 8d 3d 0a 09 00 00 lea 0x90a(%rip),%rdi # 100001f5b <_realloc$stub+0x191> | |
case EXIT: | |
printf("<END>"); | |
100001651: b0 00 mov $0x0,%al | |
100001653: e8 66 07 00 00 callq 100001dbe <_printf$stub> | |
break; | |
100001658: 89 45 94 mov %eax,-0x6c(%rbp) | |
10000165b: e9 27 00 00 00 jmpq 100001687 <_debug_dump_program+0x287> | |
100001660: 48 8d 3d fa 08 00 00 lea 0x8fa(%rip),%rdi # 100001f61 <_realloc$stub+0x197> | |
case NOP: | |
printf("<NOP>"); | |
100001667: b0 00 mov $0x0,%al | |
100001669: e8 50 07 00 00 callq 100001dbe <_printf$stub> | |
break; | |
10000166e: 89 45 90 mov %eax,-0x70(%rbp) | |
100001671: e9 11 00 00 00 jmpq 100001687 <_debug_dump_program+0x287> | |
100001676: 48 8d 3d ea 08 00 00 lea 0x8ea(%rip),%rdi # 100001f67 <_realloc$stub+0x19d> | |
case ZERO: | |
printf("<ZERO>"); | |
10000167d: b0 00 mov $0x0,%al | |
10000167f: e8 3a 07 00 00 callq 100001dbe <_printf$stub> | |
100001684: 89 45 8c mov %eax,-0x74(%rbp) | |
break; | |
} | |
} | |
100001687: e9 00 00 00 00 jmpq 10000168c <_debug_dump_program+0x28c> | |
#define SCALING_FACTOR 2 | |
#define BRANCH_STACK_SIZE 256 | |
void | |
debug_dump_program(struct program *prog) { | |
for (size_t i = 0; i < prog->length; i++) { | |
10000168c: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001690: 48 05 01 00 00 00 add $0x1,%rax | |
100001696: 48 89 45 f0 mov %rax,-0x10(%rbp) | |
10000169a: e9 78 fd ff ff jmpq 100001417 <_debug_dump_program+0x17> | |
10000169f: 48 8d 3d c8 08 00 00 lea 0x8c8(%rip),%rdi # 100001f6e <_realloc$stub+0x1a4> | |
case ZERO: | |
printf("<ZERO>"); | |
break; | |
} | |
} | |
printf("\n"); | |
1000016a6: b0 00 mov $0x0,%al | |
1000016a8: e8 11 07 00 00 callq 100001dbe <_printf$stub> | |
} | |
1000016ad: 89 45 88 mov %eax,-0x78(%rbp) | |
1000016b0: 48 81 c4 80 00 00 00 add $0x80,%rsp | |
1000016b7: 5d pop %rbp | |
1000016b8: c3 retq | |
1000016b9: 0f 1f 00 nopl (%rax) | |
1000016bc: ae scas %es:(%rdi),%al | |
1000016bd: fd std | |
1000016be: ff (bad) | |
1000016bf: ff (bad) | |
1000016c0: ea (bad) | |
1000016c1: fd std | |
1000016c2: ff (bad) | |
1000016c3: ff 26 jmpq *(%rsi) | |
1000016c5: fe (bad) | |
1000016c6: ff (bad) | |
1000016c7: ff 62 fe jmpq *-0x2(%rdx) | |
1000016ca: ff (bad) | |
1000016cb: ff 9e fe ff ff da lcallq *-0x25000002(%rsi) | |
1000016d1: fe (bad) | |
1000016d2: ff (bad) | |
1000016d3: ff 16 callq *(%rsi) | |
1000016d5: ff (bad) | |
1000016d6: ff (bad) | |
1000016d7: ff 52 ff callq *-0x1(%rdx) | |
1000016da: ff (bad) | |
1000016db: ff 8e ff ff ff ba decl -0x45000001(%rsi) | |
1000016e1: ff (bad) | |
1000016e2: ff (bad) | |
1000016e3: ff a4 ff ff ff 0f 1f jmpq *0x1f0fffff(%rdi,%rdi,8) | |
1000016ea: 84 00 test %al,(%rax) | |
1000016ec: 00 00 add %al,(%rax) | |
... | |
00000001000016f0 <_read_program>: | |
prog->ops[prog->length++] = op; | |
} | |
struct program | |
read_program(FILE *stream) { | |
1000016f0: 55 push %rbp | |
1000016f1: 48 89 e5 mov %rsp,%rbp | |
1000016f4: 48 81 ec 80 00 00 00 sub $0x80,%rsp | |
1000016fb: 48 89 f8 mov %rdi,%rax | |
1000016fe: b9 08 00 00 00 mov $0x8,%ecx | |
100001703: 89 ca mov %ecx,%edx | |
100001705: b9 00 01 00 00 mov $0x100,%ecx | |
10000170a: 41 89 c8 mov %ecx,%r8d | |
10000170d: 48 89 75 f8 mov %rsi,-0x8(%rbp) | |
struct program scanned_program; | |
scanned_program.ops = calloc(sizeof(struct brainfuck_op), INITIAL_PROGRAM_SIZE); | |
100001711: 48 89 7d c0 mov %rdi,-0x40(%rbp) | |
100001715: 48 89 d7 mov %rdx,%rdi | |
100001718: 4c 89 c6 mov %r8,%rsi | |
10000171b: 48 89 45 b8 mov %rax,-0x48(%rbp) | |
10000171f: e8 5e 06 00 00 callq 100001d82 <_calloc$stub> | |
100001724: 48 89 45 e0 mov %rax,-0x20(%rbp) | |
scanned_program.length = 0; | |
100001728: 48 c7 45 e8 00 00 00 movq $0x0,-0x18(%rbp) | |
10000172f: 00 | |
scanned_program.capacity = INITIAL_PROGRAM_SIZE; | |
100001730: 48 c7 45 f0 00 01 00 movq $0x100,-0x10(%rbp) | |
100001737: 00 | |
int scanned_char; | |
while ((scanned_char = fgetc(stream)) != EOF) { | |
100001738: 48 8b 7d f8 mov -0x8(%rbp),%rdi | |
10000173c: e8 59 06 00 00 callq 100001d9a <_fgetc$stub> | |
100001741: 89 45 dc mov %eax,-0x24(%rbp) | |
100001744: 3d ff ff ff ff cmp $0xffffffff,%eax | |
100001749: 0f 84 78 01 00 00 je 1000018c7 <_read_program+0x1d7> | |
struct brainfuck_op op; | |
op.op_value = 0; | |
10000174f: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%rbp) | |
switch (scanned_char) { | |
100001756: 8b 45 dc mov -0x24(%rbp),%eax | |
100001759: 89 c1 mov %eax,%ecx | |
10000175b: 83 e9 5a sub $0x5a,%ecx | |
10000175e: 89 45 b4 mov %eax,-0x4c(%rbp) | |
100001761: 89 4d b0 mov %ecx,-0x50(%rbp) | |
100001764: 0f 8f 6d 00 00 00 jg 1000017d7 <_read_program+0xe7> | |
10000176a: e9 00 00 00 00 jmpq 10000176f <_read_program+0x7f> | |
10000176f: 8b 45 b4 mov -0x4c(%rbp),%eax | |
100001772: 83 e8 3b sub $0x3b,%eax | |
100001775: 89 45 ac mov %eax,-0x54(%rbp) | |
100001778: 0f 8f 31 00 00 00 jg 1000017af <_read_program+0xbf> | |
10000177e: e9 00 00 00 00 jmpq 100001783 <_read_program+0x93> | |
100001783: 8b 45 b4 mov -0x4c(%rbp),%eax | |
100001786: 83 c0 d5 add $0xffffffd5,%eax | |
100001789: 89 c1 mov %eax,%ecx | |
10000178b: 83 e8 03 sub $0x3,%eax | |
10000178e: 48 89 4d a0 mov %rcx,-0x60(%rbp) | |
100001792: 89 45 9c mov %eax,-0x64(%rbp) | |
100001795: 0f 87 27 01 00 00 ja 1000018c2 <_read_program+0x1d2> | |
10000179b: 48 8d 05 62 01 00 00 lea 0x162(%rip),%rax # 100001904 <_read_program+0x214> | |
1000017a2: 48 8b 4d a0 mov -0x60(%rbp),%rcx | |
1000017a6: 48 63 14 88 movslq (%rax,%rcx,4),%rdx | |
1000017aa: 48 01 c2 add %rax,%rdx | |
1000017ad: ff e2 jmpq *%rdx | |
1000017af: 8b 45 b4 mov -0x4c(%rbp),%eax | |
1000017b2: 83 e8 3c sub $0x3c,%eax | |
1000017b5: 89 45 98 mov %eax,-0x68(%rbp) | |
1000017b8: 0f 84 73 00 00 00 je 100001831 <_read_program+0x141> | |
1000017be: e9 00 00 00 00 jmpq 1000017c3 <_read_program+0xd3> | |
1000017c3: 8b 45 b4 mov -0x4c(%rbp),%eax | |
1000017c6: 83 e8 3e sub $0x3e,%eax | |
1000017c9: 89 45 94 mov %eax,-0x6c(%rbp) | |
1000017cc: 0f 84 78 00 00 00 je 10000184a <_read_program+0x15a> | |
1000017d2: e9 eb 00 00 00 jmpq 1000018c2 <_read_program+0x1d2> | |
1000017d7: 8b 45 b4 mov -0x4c(%rbp),%eax | |
1000017da: 83 e8 5b sub $0x5b,%eax | |
1000017dd: 89 45 90 mov %eax,-0x70(%rbp) | |
1000017e0: 0f 84 7d 00 00 00 je 100001863 <_read_program+0x173> | |
1000017e6: e9 00 00 00 00 jmpq 1000017eb <_read_program+0xfb> | |
1000017eb: 8b 45 b4 mov -0x4c(%rbp),%eax | |
1000017ee: 83 e8 5d sub $0x5d,%eax | |
1000017f1: 89 45 8c mov %eax,-0x74(%rbp) | |
1000017f4: 0f 84 82 00 00 00 je 10000187c <_read_program+0x18c> | |
1000017fa: e9 c3 00 00 00 jmpq 1000018c2 <_read_program+0x1d2> | |
1000017ff: 48 8d 7d e0 lea -0x20(%rbp),%rdi | |
case '+': | |
op.type = PLUS; | |
100001803: c7 45 d0 00 00 00 00 movl $0x0,-0x30(%rbp) | |
insert_op(&scanned_program, op); | |
10000180a: 48 8b 75 d0 mov -0x30(%rbp),%rsi | |
10000180e: e8 0d 01 00 00 callq 100001920 <_insert_op> | |
break; | |
100001813: e9 aa 00 00 00 jmpq 1000018c2 <_read_program+0x1d2> | |
100001818: 48 8d 7d e0 lea -0x20(%rbp),%rdi | |
case '-': | |
op.type = MINUS; | |
10000181c: c7 45 d0 01 00 00 00 movl $0x1,-0x30(%rbp) | |
insert_op(&scanned_program, op); | |
100001823: 48 8b 75 d0 mov -0x30(%rbp),%rsi | |
100001827: e8 f4 00 00 00 callq 100001920 <_insert_op> | |
break; | |
10000182c: e9 91 00 00 00 jmpq 1000018c2 <_read_program+0x1d2> | |
100001831: 48 8d 7d e0 lea -0x20(%rbp),%rdi | |
case '<': | |
op.type = SHIFT_LEFT; | |
100001835: c7 45 d0 02 00 00 00 movl $0x2,-0x30(%rbp) | |
insert_op(&scanned_program, op); | |
10000183c: 48 8b 75 d0 mov -0x30(%rbp),%rsi | |
100001840: e8 db 00 00 00 callq 100001920 <_insert_op> | |
break; | |
100001845: e9 78 00 00 00 jmpq 1000018c2 <_read_program+0x1d2> | |
10000184a: 48 8d 7d e0 lea -0x20(%rbp),%rdi | |
case '>': | |
op.type = SHIFT_RIGHT; | |
10000184e: c7 45 d0 03 00 00 00 movl $0x3,-0x30(%rbp) | |
insert_op(&scanned_program, op); | |
100001855: 48 8b 75 d0 mov -0x30(%rbp),%rsi | |
100001859: e8 c2 00 00 00 callq 100001920 <_insert_op> | |
break; | |
10000185e: e9 5f 00 00 00 jmpq 1000018c2 <_read_program+0x1d2> | |
100001863: 48 8d 7d e0 lea -0x20(%rbp),%rdi | |
case '[': | |
op.type = BRANCH_LEFT; | |
100001867: c7 45 d0 04 00 00 00 movl $0x4,-0x30(%rbp) | |
insert_op(&scanned_program, op); | |
10000186e: 48 8b 75 d0 mov -0x30(%rbp),%rsi | |
100001872: e8 a9 00 00 00 callq 100001920 <_insert_op> | |
break; | |
100001877: e9 46 00 00 00 jmpq 1000018c2 <_read_program+0x1d2> | |
10000187c: 48 8d 7d e0 lea -0x20(%rbp),%rdi | |
case ']': | |
op.type = BRANCH_RIGHT; | |
100001880: c7 45 d0 05 00 00 00 movl $0x5,-0x30(%rbp) | |
insert_op(&scanned_program, op); | |
100001887: 48 8b 75 d0 mov -0x30(%rbp),%rsi | |
10000188b: e8 90 00 00 00 callq 100001920 <_insert_op> | |
break; | |
100001890: e9 2d 00 00 00 jmpq 1000018c2 <_read_program+0x1d2> | |
100001895: 48 8d 7d e0 lea -0x20(%rbp),%rdi | |
case '.': | |
op.type = OUTPUT; | |
100001899: c7 45 d0 07 00 00 00 movl $0x7,-0x30(%rbp) | |
insert_op(&scanned_program, op); | |
1000018a0: 48 8b 75 d0 mov -0x30(%rbp),%rsi | |
1000018a4: e8 77 00 00 00 callq 100001920 <_insert_op> | |
break; | |
1000018a9: e9 14 00 00 00 jmpq 1000018c2 <_read_program+0x1d2> | |
1000018ae: 48 8d 7d e0 lea -0x20(%rbp),%rdi | |
case ',': | |
op.type = INPUT; | |
1000018b2: c7 45 d0 06 00 00 00 movl $0x6,-0x30(%rbp) | |
insert_op(&scanned_program, op); | |
1000018b9: 48 8b 75 d0 mov -0x30(%rbp),%rsi | |
1000018bd: e8 5e 00 00 00 callq 100001920 <_insert_op> | |
struct program scanned_program; | |
scanned_program.ops = calloc(sizeof(struct brainfuck_op), INITIAL_PROGRAM_SIZE); | |
scanned_program.length = 0; | |
scanned_program.capacity = INITIAL_PROGRAM_SIZE; | |
int scanned_char; | |
while ((scanned_char = fgetc(stream)) != EOF) { | |
1000018c2: e9 71 fe ff ff jmpq 100001738 <_read_program+0x48> | |
1000018c7: 48 8d 7d e0 lea -0x20(%rbp),%rdi | |
break; | |
} | |
} | |
struct brainfuck_op op; | |
op.type = EXIT; | |
1000018cb: c7 45 c8 08 00 00 00 movl $0x8,-0x38(%rbp) | |
insert_op(&scanned_program, op); | |
1000018d2: 48 8b 75 c8 mov -0x38(%rbp),%rsi | |
1000018d6: e8 45 00 00 00 callq 100001920 <_insert_op> | |
return scanned_program; | |
1000018db: 48 8b 75 e0 mov -0x20(%rbp),%rsi | |
1000018df: 48 8b 7d c0 mov -0x40(%rbp),%rdi | |
1000018e3: 48 89 37 mov %rsi,(%rdi) | |
1000018e6: 48 8b 75 e8 mov -0x18(%rbp),%rsi | |
1000018ea: 48 89 77 08 mov %rsi,0x8(%rdi) | |
1000018ee: 48 8b 75 f0 mov -0x10(%rbp),%rsi | |
1000018f2: 48 89 77 10 mov %rsi,0x10(%rdi) | |
1000018f6: 48 8b 45 b8 mov -0x48(%rbp),%rax | |
1000018fa: 48 81 c4 80 00 00 00 add $0x80,%rsp | |
100001901: 5d pop %rbp | |
100001902: c3 retq | |
100001903: 90 nop | |
100001904: fb sti | |
100001905: fe (bad) | |
100001906: ff (bad) | |
100001907: ff aa ff ff ff 14 ljmpq *0x14ffffff(%rdx) | |
10000190d: ff (bad) | |
10000190e: ff (bad) | |
10000190f: ff 91 ff ff ff 66 callq *0x66ffffff(%rcx) | |
100001915: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) | |
10000191c: 00 00 00 00 | |
0000000100001920 <_insert_op>: | |
prog->capacity = prog->capacity * SCALING_FACTOR; | |
prog->ops = realloc(prog->ops, sizeof(struct brainfuck_op) * prog->capacity); | |
} | |
static inline void | |
insert_op(struct program *prog, struct brainfuck_op op) { | |
100001920: 55 push %rbp | |
100001921: 48 89 e5 mov %rsp,%rbp | |
100001924: 48 83 ec 10 sub $0x10,%rsp | |
100001928: 48 89 75 f8 mov %rsi,-0x8(%rbp) | |
10000192c: 48 89 7d f0 mov %rdi,-0x10(%rbp) | |
if (prog->capacity == prog->length) { | |
100001930: 48 8b 75 f0 mov -0x10(%rbp),%rsi | |
100001934: 48 8b 76 10 mov 0x10(%rsi),%rsi | |
100001938: 48 8b 7d f0 mov -0x10(%rbp),%rdi | |
10000193c: 48 3b 77 08 cmp 0x8(%rdi),%rsi | |
100001940: 0f 85 09 00 00 00 jne 10000194f <_insert_op+0x2f> | |
resize_program(prog); | |
100001946: 48 8b 7d f0 mov -0x10(%rbp),%rdi | |
10000194a: e8 d1 03 00 00 callq 100001d20 <_resize_program> | |
} | |
prog->ops[prog->length++] = op; | |
10000194f: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001953: 48 8b 48 08 mov 0x8(%rax),%rcx | |
100001957: 48 89 ca mov %rcx,%rdx | |
10000195a: 48 81 c2 01 00 00 00 add $0x1,%rdx | |
100001961: 48 89 50 08 mov %rdx,0x8(%rax) | |
100001965: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001969: 48 8b 00 mov (%rax),%rax | |
10000196c: 48 8b 55 f8 mov -0x8(%rbp),%rdx | |
100001970: 48 89 14 c8 mov %rdx,(%rax,%rcx,8) | |
} | |
100001974: 48 83 c4 10 add $0x10,%rsp | |
100001978: 5d pop %rbp | |
100001979: c3 retq | |
10000197a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) | |
0000000100001980 <_aggregate_ops>: | |
insert_op(&scanned_program, op); | |
return scanned_program; | |
} | |
struct program | |
aggregate_ops(struct program *prog) { | |
100001980: 55 push %rbp | |
100001981: 48 89 e5 mov %rsp,%rbp | |
100001984: 48 83 ec 60 sub $0x60,%rsp | |
100001988: 48 89 f8 mov %rdi,%rax | |
10000198b: b9 08 00 00 00 mov $0x8,%ecx | |
100001990: 89 ca mov %ecx,%edx | |
100001992: b9 00 01 00 00 mov $0x100,%ecx | |
100001997: 41 89 c8 mov %ecx,%r8d | |
10000199a: 48 89 75 f8 mov %rsi,-0x8(%rbp) | |
struct program aggregated_program; | |
aggregated_program.ops = calloc(sizeof(struct brainfuck_op), INITIAL_PROGRAM_SIZE); | |
10000199e: 48 89 7d a8 mov %rdi,-0x58(%rbp) | |
1000019a2: 48 89 d7 mov %rdx,%rdi | |
1000019a5: 4c 89 c6 mov %r8,%rsi | |
1000019a8: 48 89 45 a0 mov %rax,-0x60(%rbp) | |
1000019ac: e8 d1 03 00 00 callq 100001d82 <_calloc$stub> | |
1000019b1: 48 89 45 e0 mov %rax,-0x20(%rbp) | |
aggregated_program.length = 0; | |
1000019b5: 48 c7 45 e8 00 00 00 movq $0x0,-0x18(%rbp) | |
1000019bc: 00 | |
aggregated_program.capacity = INITIAL_PROGRAM_SIZE; | |
1000019bd: 48 c7 45 f0 00 01 00 movq $0x100,-0x10(%rbp) | |
1000019c4: 00 | |
enum brainfuck_op_type last_seen_type = NOP; | |
1000019c5: c7 45 dc 0a 00 00 00 movl $0xa,-0x24(%rbp) | |
int count = 1; | |
1000019cc: c7 45 d8 01 00 00 00 movl $0x1,-0x28(%rbp) | |
for (size_t i = 0; i < prog->length; i++) { | |
1000019d3: 48 c7 45 d0 00 00 00 movq $0x0,-0x30(%rbp) | |
1000019da: 00 | |
1000019db: 48 8b 45 d0 mov -0x30(%rbp),%rax | |
1000019df: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
1000019e3: 48 3b 41 08 cmp 0x8(%rcx),%rax | |
1000019e7: 0f 83 b6 00 00 00 jae 100001aa3 <_aggregate_ops+0x123> | |
if (prog->ops[i].type == last_seen_type) { | |
1000019ed: 48 8b 45 d0 mov -0x30(%rbp),%rax | |
1000019f1: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
1000019f5: 48 8b 09 mov (%rcx),%rcx | |
1000019f8: 8b 14 c1 mov (%rcx,%rax,8),%edx | |
1000019fb: 3b 55 dc cmp -0x24(%rbp),%edx | |
1000019fe: 0f 85 49 00 00 00 jne 100001a4d <_aggregate_ops+0xcd> | |
// if the type we're looking at is the same as the last one, | |
// increase the count and continue. | |
if (last_seen_type == BRANCH_LEFT || last_seen_type == BRANCH_RIGHT) { | |
100001a04: 81 7d dc 04 00 00 00 cmpl $0x4,-0x24(%rbp) | |
100001a0b: 0f 84 0d 00 00 00 je 100001a1e <_aggregate_ops+0x9e> | |
100001a11: 81 7d dc 05 00 00 00 cmpl $0x5,-0x24(%rbp) | |
100001a18: 0f 85 1f 00 00 00 jne 100001a3d <_aggregate_ops+0xbd> | |
100001a1e: 48 8d 7d e0 lea -0x20(%rbp),%rdi | |
// if the previous type was a branch and this one was as well, do not | |
// combine them. | |
struct brainfuck_op op; | |
op.type = last_seen_type; | |
100001a22: 8b 45 dc mov -0x24(%rbp),%eax | |
100001a25: 89 45 c8 mov %eax,-0x38(%rbp) | |
op.op_value = 0; | |
100001a28: c7 45 cc 00 00 00 00 movl $0x0,-0x34(%rbp) | |
insert_op(&aggregated_program, op); | |
100001a2f: 48 8b 75 c8 mov -0x38(%rbp),%rsi | |
100001a33: e8 e8 fe ff ff callq 100001920 <_insert_op> | |
continue; | |
100001a38: e9 53 00 00 00 jmpq 100001a90 <_aggregate_ops+0x110> | |
} | |
count++; | |
100001a3d: 8b 45 d8 mov -0x28(%rbp),%eax | |
100001a40: 05 01 00 00 00 add $0x1,%eax | |
100001a45: 89 45 d8 mov %eax,-0x28(%rbp) | |
} else { | |
100001a48: e9 3e 00 00 00 jmpq 100001a8b <_aggregate_ops+0x10b> | |
// if we're looking at a type that's not the same as the last type | |
// that we observed, we need to "finish" off the last type. | |
struct brainfuck_op op; | |
if (last_seen_type != NOP) { | |
100001a4d: 81 7d dc 0a 00 00 00 cmpl $0xa,-0x24(%rbp) | |
100001a54: 0f 84 19 00 00 00 je 100001a73 <_aggregate_ops+0xf3> | |
100001a5a: 48 8d 7d e0 lea -0x20(%rbp),%rdi | |
op.type = last_seen_type; | |
100001a5e: 8b 45 dc mov -0x24(%rbp),%eax | |
100001a61: 89 45 c0 mov %eax,-0x40(%rbp) | |
op.op_value = count; | |
100001a64: 8b 45 d8 mov -0x28(%rbp),%eax | |
100001a67: 89 45 c4 mov %eax,-0x3c(%rbp) | |
insert_op(&aggregated_program, op); | |
100001a6a: 48 8b 75 c0 mov -0x40(%rbp),%rsi | |
100001a6e: e8 ad fe ff ff callq 100001920 <_insert_op> | |
} | |
last_seen_type = prog->ops[i].type; | |
100001a73: 48 8b 45 d0 mov -0x30(%rbp),%rax | |
100001a77: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
100001a7b: 48 8b 09 mov (%rcx),%rcx | |
100001a7e: 8b 14 c1 mov (%rcx,%rax,8),%edx | |
100001a81: 89 55 dc mov %edx,-0x24(%rbp) | |
count = 1; | |
100001a84: c7 45 d8 01 00 00 00 movl $0x1,-0x28(%rbp) | |
} | |
} | |
100001a8b: e9 00 00 00 00 jmpq 100001a90 <_aggregate_ops+0x110> | |
aggregated_program.length = 0; | |
aggregated_program.capacity = INITIAL_PROGRAM_SIZE; | |
enum brainfuck_op_type last_seen_type = NOP; | |
int count = 1; | |
for (size_t i = 0; i < prog->length; i++) { | |
100001a90: 48 8b 45 d0 mov -0x30(%rbp),%rax | |
100001a94: 48 05 01 00 00 00 add $0x1,%rax | |
100001a9a: 48 89 45 d0 mov %rax,-0x30(%rbp) | |
100001a9e: e9 38 ff ff ff jmpq 1000019db <_aggregate_ops+0x5b> | |
last_seen_type = prog->ops[i].type; | |
count = 1; | |
} | |
} | |
if (count != 1) { | |
100001aa3: 81 7d d8 01 00 00 00 cmpl $0x1,-0x28(%rbp) | |
100001aaa: 0f 84 0c 00 00 00 je 100001abc <_aggregate_ops+0x13c> | |
struct brainfuck_op op; | |
op.type = last_seen_type; | |
100001ab0: 8b 45 dc mov -0x24(%rbp),%eax | |
100001ab3: 89 45 b8 mov %eax,-0x48(%rbp) | |
op.op_value = count; | |
100001ab6: 8b 45 d8 mov -0x28(%rbp),%eax | |
100001ab9: 89 45 bc mov %eax,-0x44(%rbp) | |
100001abc: 48 8d 7d e0 lea -0x20(%rbp),%rdi | |
} | |
// stick a terminator onto the new program | |
struct brainfuck_op exit_op; | |
exit_op.type = EXIT; | |
100001ac0: c7 45 b0 08 00 00 00 movl $0x8,-0x50(%rbp) | |
exit_op.op_value = 0; | |
100001ac7: c7 45 b4 00 00 00 00 movl $0x0,-0x4c(%rbp) | |
insert_op(&aggregated_program, exit_op); | |
100001ace: 48 8b 75 b0 mov -0x50(%rbp),%rsi | |
100001ad2: e8 49 fe ff ff callq 100001920 <_insert_op> | |
destroy_program(prog); | |
100001ad7: 48 8b 7d f8 mov -0x8(%rbp),%rdi | |
100001adb: e8 30 00 00 00 callq 100001b10 <_destroy_program> | |
return aggregated_program; | |
100001ae0: 48 8b 75 e0 mov -0x20(%rbp),%rsi | |
100001ae4: 48 8b 7d a8 mov -0x58(%rbp),%rdi | |
100001ae8: 48 89 37 mov %rsi,(%rdi) | |
100001aeb: 48 8b 75 e8 mov -0x18(%rbp),%rsi | |
100001aef: 48 89 77 08 mov %rsi,0x8(%rdi) | |
100001af3: 48 8b 75 f0 mov -0x10(%rbp),%rsi | |
100001af7: 48 89 77 10 mov %rsi,0x10(%rdi) | |
100001afb: 48 8b 45 a0 mov -0x60(%rbp),%rax | |
100001aff: 48 83 c4 60 add $0x60,%rsp | |
100001b03: 5d pop %rbp | |
100001b04: c3 retq | |
100001b05: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) | |
100001b0c: 00 00 00 00 | |
0000000100001b10 <_destroy_program>: | |
prog->ops[i+1].type = NOP; | |
} | |
} | |
} | |
void destroy_program(struct program *prog) { | |
100001b10: 55 push %rbp | |
100001b11: 48 89 e5 mov %rsp,%rbp | |
100001b14: 48 83 ec 10 sub $0x10,%rsp | |
100001b18: 48 89 7d f8 mov %rdi,-0x8(%rbp) | |
free(prog->ops); | |
100001b1c: 48 8b 7d f8 mov -0x8(%rbp),%rdi | |
100001b20: 48 8b 3f mov (%rdi),%rdi | |
100001b23: e8 84 02 00 00 callq 100001dac <_free$stub> | |
} | |
100001b28: 48 83 c4 10 add $0x10,%rsp | |
100001b2c: 5d pop %rbp | |
100001b2d: c3 retq | |
100001b2e: 66 90 xchg %ax,%ax | |
0000000100001b30 <_mark_branches>: | |
destroy_program(prog); | |
return aggregated_program; | |
} | |
bool | |
mark_branches(struct program *prog) { | |
100001b30: 55 push %rbp | |
100001b31: 48 89 e5 mov %rsp,%rbp | |
100001b34: 48 83 ec 60 sub $0x60,%rsp | |
100001b38: 48 8d 45 d8 lea -0x28(%rbp),%rax | |
100001b3c: 48 89 7d f0 mov %rdi,-0x10(%rbp) | |
struct stack_entry { | |
size_t branch_offset; | |
struct brainfuck_op *op; | |
}; | |
struct branch_stack stack = branch_stack_new(); | |
100001b40: 48 89 c7 mov %rax,%rdi | |
100001b43: e8 28 ef ff ff callq 100000a70 <_branch_stack_new> | |
for (size_t i = 0; i < prog->length; i++) { | |
100001b48: 48 c7 45 d0 00 00 00 movq $0x0,-0x30(%rbp) | |
100001b4f: 00 | |
100001b50: 48 8b 45 d0 mov -0x30(%rbp),%rax | |
100001b54: 48 8b 4d f0 mov -0x10(%rbp),%rcx | |
100001b58: 48 3b 41 08 cmp 0x8(%rcx),%rax | |
100001b5c: 0f 83 c3 00 00 00 jae 100001c25 <_mark_branches+0xf5> | |
struct brainfuck_op *op = &prog->ops[i]; | |
100001b62: 48 8b 45 d0 mov -0x30(%rbp),%rax | |
100001b66: 48 8b 4d f0 mov -0x10(%rbp),%rcx | |
100001b6a: 48 8b 09 mov (%rcx),%rcx | |
100001b6d: 48 8d 14 c1 lea (%rcx,%rax,8),%rdx | |
100001b71: 48 89 55 c8 mov %rdx,-0x38(%rbp) | |
switch (op->type) { | |
100001b75: 8b 34 c1 mov (%rcx,%rax,8),%esi | |
100001b78: 89 f7 mov %esi,%edi | |
100001b7a: 83 ef 05 sub $0x5,%edi | |
100001b7d: 89 75 b4 mov %esi,-0x4c(%rbp) | |
100001b80: 89 7d b0 mov %edi,-0x50(%rbp) | |
100001b83: 0f 84 2f 00 00 00 je 100001bb8 <_mark_branches+0x88> | |
100001b89: e9 00 00 00 00 jmpq 100001b8e <_mark_branches+0x5e> | |
100001b8e: 8b 45 b4 mov -0x4c(%rbp),%eax | |
100001b91: 83 e8 04 sub $0x4,%eax | |
100001b94: 89 45 ac mov %eax,-0x54(%rbp) | |
100001b97: 0f 85 6b 00 00 00 jne 100001c08 <_mark_branches+0xd8> | |
100001b9d: e9 00 00 00 00 jmpq 100001ba2 <_mark_branches+0x72> | |
100001ba2: 48 8d 7d d8 lea -0x28(%rbp),%rdi | |
case BRANCH_LEFT: | |
branch_stack_push(&stack, i, op); | |
100001ba6: 48 8b 75 d0 mov -0x30(%rbp),%rsi | |
100001baa: 48 8b 55 c8 mov -0x38(%rbp),%rdx | |
100001bae: e8 2d ef ff ff callq 100000ae0 <_branch_stack_push> | |
break; | |
100001bb3: e9 55 00 00 00 jmpq 100001c0d <_mark_branches+0xdd> | |
case BRANCH_RIGHT: | |
if (stack.length == 0) { | |
100001bb8: 48 81 7d e0 00 00 00 cmpq $0x0,-0x20(%rbp) | |
100001bbf: 00 | |
100001bc0: 0f 85 12 00 00 00 jne 100001bd8 <_mark_branches+0xa8> | |
100001bc6: 48 8d 7d d8 lea -0x28(%rbp),%rdi | |
branch_stack_destroy(&stack); | |
100001bca: e8 61 f0 ff ff callq 100000c30 <_branch_stack_destroy> | |
return false; | |
100001bcf: c6 45 ff 00 movb $0x0,-0x1(%rbp) | |
100001bd3: e9 5a 00 00 00 jmpq 100001c32 <_mark_branches+0x102> | |
100001bd8: 48 8d 7d d8 lea -0x28(%rbp),%rdi | |
} | |
struct branch_stack_entry source_branch = branch_stack_pop(&stack); | |
100001bdc: e8 cf ef ff ff callq 100000bb0 <_branch_stack_pop> | |
100001be1: 48 89 45 b8 mov %rax,-0x48(%rbp) | |
100001be5: 48 89 55 c0 mov %rdx,-0x40(%rbp) | |
// for this branch_right, we want the branch offset to point to | |
// the next instruction after the branch_left that is at the top | |
// of the stack. | |
op->op_value = source_branch.branch_offset; | |
100001be9: 48 8b 45 b8 mov -0x48(%rbp),%rax | |
100001bed: 89 c1 mov %eax,%ecx | |
100001bef: 48 8b 45 c8 mov -0x38(%rbp),%rax | |
100001bf3: 89 48 04 mov %ecx,0x4(%rax) | |
// we also want the branch_left to point to the instruction | |
// after this branch_right | |
source_branch.op->op_value = i; | |
100001bf6: 48 8b 45 d0 mov -0x30(%rbp),%rax | |
100001bfa: 89 c1 mov %eax,%ecx | |
100001bfc: 48 8b 45 c0 mov -0x40(%rbp),%rax | |
100001c00: 89 48 04 mov %ecx,0x4(%rax) | |
break; | |
100001c03: e9 05 00 00 00 jmpq 100001c0d <_mark_branches+0xdd> | |
default: | |
continue; | |
100001c08: e9 05 00 00 00 jmpq 100001c12 <_mark_branches+0xe2> | |
} | |
} | |
100001c0d: e9 00 00 00 00 jmpq 100001c12 <_mark_branches+0xe2> | |
size_t branch_offset; | |
struct brainfuck_op *op; | |
}; | |
struct branch_stack stack = branch_stack_new(); | |
for (size_t i = 0; i < prog->length; i++) { | |
100001c12: 48 8b 45 d0 mov -0x30(%rbp),%rax | |
100001c16: 48 05 01 00 00 00 add $0x1,%rax | |
100001c1c: 48 89 45 d0 mov %rax,-0x30(%rbp) | |
100001c20: e9 2b ff ff ff jmpq 100001b50 <_mark_branches+0x20> | |
100001c25: 48 8d 7d d8 lea -0x28(%rbp),%rdi | |
default: | |
continue; | |
} | |
} | |
branch_stack_destroy(&stack); | |
100001c29: e8 02 f0 ff ff callq 100000c30 <_branch_stack_destroy> | |
return true; | |
100001c2e: c6 45 ff 01 movb $0x1,-0x1(%rbp) | |
} | |
100001c32: 8a 45 ff mov -0x1(%rbp),%al | |
100001c35: 24 01 and $0x1,%al | |
100001c37: 0f b6 c0 movzbl %al,%eax | |
100001c3a: 48 83 c4 60 add $0x60,%rsp | |
100001c3e: 5d pop %rbp | |
100001c3f: c3 retq | |
0000000100001c40 <_zero_cell_optimization>: | |
void | |
zero_cell_optimization(struct program *prog) { | |
100001c40: 55 push %rbp | |
100001c41: 48 89 e5 mov %rsp,%rbp | |
100001c44: 48 89 7d f8 mov %rdi,-0x8(%rbp) | |
for (size_t i = 1; i < prog->length - 1; i++) { | |
100001c48: 48 c7 45 f0 01 00 00 movq $0x1,-0x10(%rbp) | |
100001c4f: 00 | |
100001c50: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001c54: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
100001c58: 48 8b 49 08 mov 0x8(%rcx),%rcx | |
100001c5c: 48 81 e9 01 00 00 00 sub $0x1,%rcx | |
100001c63: 48 39 c8 cmp %rcx,%rax | |
100001c66: 0f 83 a4 00 00 00 jae 100001d10 <_zero_cell_optimization+0xd0> | |
if (prog->ops[i-1].type == BRANCH_LEFT && | |
100001c6c: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001c70: 48 2d 01 00 00 00 sub $0x1,%rax | |
100001c76: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
100001c7a: 48 8b 09 mov (%rcx),%rcx | |
100001c7d: 81 3c c1 04 00 00 00 cmpl $0x4,(%rcx,%rax,8) | |
100001c84: 0f 85 6e 00 00 00 jne 100001cf8 <_zero_cell_optimization+0xb8> | |
100001c8a: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001c8e: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
100001c92: 48 8b 09 mov (%rcx),%rcx | |
100001c95: 81 3c c1 01 00 00 00 cmpl $0x1,(%rcx,%rax,8) | |
100001c9c: 0f 85 56 00 00 00 jne 100001cf8 <_zero_cell_optimization+0xb8> | |
100001ca2: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001ca6: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
100001caa: 48 8b 09 mov (%rcx),%rcx | |
100001cad: 81 7c c1 08 05 00 00 cmpl $0x5,0x8(%rcx,%rax,8) | |
100001cb4: 00 | |
100001cb5: 0f 85 3d 00 00 00 jne 100001cf8 <_zero_cell_optimization+0xb8> | |
prog->ops[i].type == MINUS && | |
prog->ops[i+1].type == BRANCH_RIGHT) { | |
prog->ops[i-1].type = NOP; | |
100001cbb: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001cbf: 48 2d 01 00 00 00 sub $0x1,%rax | |
100001cc5: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
100001cc9: 48 8b 09 mov (%rcx),%rcx | |
100001ccc: c7 04 c1 0a 00 00 00 movl $0xa,(%rcx,%rax,8) | |
prog->ops[i].type = ZERO; | |
100001cd3: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001cd7: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
100001cdb: 48 8b 09 mov (%rcx),%rcx | |
100001cde: c7 04 c1 09 00 00 00 movl $0x9,(%rcx,%rax,8) | |
prog->ops[i+1].type = NOP; | |
100001ce5: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001ce9: 48 8b 4d f8 mov -0x8(%rbp),%rcx | |
100001ced: 48 8b 09 mov (%rcx),%rcx | |
100001cf0: c7 44 c1 08 0a 00 00 movl $0xa,0x8(%rcx,%rax,8) | |
100001cf7: 00 | |
} | |
} | |
100001cf8: e9 00 00 00 00 jmpq 100001cfd <_zero_cell_optimization+0xbd> | |
return true; | |
} | |
void | |
zero_cell_optimization(struct program *prog) { | |
for (size_t i = 1; i < prog->length - 1; i++) { | |
100001cfd: 48 8b 45 f0 mov -0x10(%rbp),%rax | |
100001d01: 48 05 01 00 00 00 add $0x1,%rax | |
100001d07: 48 89 45 f0 mov %rax,-0x10(%rbp) | |
100001d0b: e9 40 ff ff ff jmpq 100001c50 <_zero_cell_optimization+0x10> | |
prog->ops[i-1].type = NOP; | |
prog->ops[i].type = ZERO; | |
prog->ops[i+1].type = NOP; | |
} | |
} | |
} | |
100001d10: 5d pop %rbp | |
100001d11: c3 retq | |
100001d12: 66 66 66 66 66 2e 0f data16 data16 data16 data16 nopw %cs:0x0(%rax,%rax,1) | |
100001d19: 1f 84 00 00 00 00 00 | |
0000000100001d20 <_resize_program>: | |
} | |
printf("\n"); | |
} | |
static void | |
resize_program(struct program *prog) { | |
100001d20: 55 push %rbp | |
100001d21: 48 89 e5 mov %rsp,%rbp | |
100001d24: 48 83 ec 10 sub $0x10,%rsp | |
100001d28: 48 89 7d f8 mov %rdi,-0x8(%rbp) | |
prog->capacity = prog->capacity * SCALING_FACTOR; | |
100001d2c: 48 8b 7d f8 mov -0x8(%rbp),%rdi | |
100001d30: 48 8b 7f 10 mov 0x10(%rdi),%rdi | |
100001d34: 48 c1 e7 01 shl $0x1,%rdi | |
100001d38: 48 8b 45 f8 mov -0x8(%rbp),%rax | |
100001d3c: 48 89 78 10 mov %rdi,0x10(%rax) | |
prog->ops = realloc(prog->ops, sizeof(struct brainfuck_op) * prog->capacity); | |
100001d40: 48 8b 45 f8 mov -0x8(%rbp),%rax | |
100001d44: 48 8b 00 mov (%rax),%rax | |
100001d47: 48 8b 7d f8 mov -0x8(%rbp),%rdi | |
100001d4b: 48 8b 7f 10 mov 0x10(%rdi),%rdi | |
100001d4f: 48 c1 e7 03 shl $0x3,%rdi | |
100001d53: 48 89 7d f0 mov %rdi,-0x10(%rbp) | |
100001d57: 48 89 c7 mov %rax,%rdi | |
100001d5a: 48 8b 75 f0 mov -0x10(%rbp),%rsi | |
100001d5e: e8 67 00 00 00 callq 100001dca <_realloc$stub> | |
100001d63: 48 8b 75 f8 mov -0x8(%rbp),%rsi | |
100001d67: 48 89 06 mov %rax,(%rsi) | |
} | |
100001d6a: 48 83 c4 10 add $0x10,%rsp | |
100001d6e: 5d pop %rbp | |
100001d6f: c3 retq | |
Disassembly of section __TEXT.__stubs: | |
0000000100001d70 <___memset_chk$stub>: | |
100001d70: ff 25 b2 02 00 00 jmpq *0x2b2(%rip) # 100002028 <___memset_chk$stub> | |
0000000100001d76 <___stack_chk_fail$stub>: | |
100001d76: ff 25 b4 02 00 00 jmpq *0x2b4(%rip) # 100002030 <___stack_chk_fail$stub> | |
0000000100001d7c <_abort$stub>: | |
100001d7c: ff 25 b6 02 00 00 jmpq *0x2b6(%rip) # 100002038 <_abort$stub> | |
0000000100001d82 <_calloc$stub>: | |
100001d82: ff 25 b8 02 00 00 jmpq *0x2b8(%rip) # 100002040 <_calloc$stub> | |
0000000100001d88 <_exit$stub>: | |
100001d88: ff 25 ba 02 00 00 jmpq *0x2ba(%rip) # 100002048 <_exit$stub> | |
0000000100001d8e <_fclose$stub>: | |
100001d8e: ff 25 bc 02 00 00 jmpq *0x2bc(%rip) # 100002050 <_fclose$stub> | |
0000000100001d94 <_fflush$stub>: | |
100001d94: ff 25 be 02 00 00 jmpq *0x2be(%rip) # 100002058 <_fflush$stub> | |
0000000100001d9a <_fgetc$stub>: | |
100001d9a: ff 25 c0 02 00 00 jmpq *0x2c0(%rip) # 100002060 <_fgetc$stub> | |
0000000100001da0 <_fopen$stub>: | |
100001da0: ff 25 c2 02 00 00 jmpq *0x2c2(%rip) # 100002068 <_fopen$stub> | |
0000000100001da6 <_fprintf$stub>: | |
100001da6: ff 25 c4 02 00 00 jmpq *0x2c4(%rip) # 100002070 <_fprintf$stub> | |
0000000100001dac <_free$stub>: | |
100001dac: ff 25 c6 02 00 00 jmpq *0x2c6(%rip) # 100002078 <_free$stub> | |
0000000100001db2 <_getchar$stub>: | |
100001db2: ff 25 c8 02 00 00 jmpq *0x2c8(%rip) # 100002080 <_getchar$stub> | |
0000000100001db8 <_perror$stub>: | |
100001db8: ff 25 ca 02 00 00 jmpq *0x2ca(%rip) # 100002088 <_perror$stub> | |
0000000100001dbe <_printf$stub>: | |
100001dbe: ff 25 cc 02 00 00 jmpq *0x2cc(%rip) # 100002090 <_printf$stub> | |
0000000100001dc4 <_putchar$stub>: | |
100001dc4: ff 25 ce 02 00 00 jmpq *0x2ce(%rip) # 100002098 <_putchar$stub> | |
0000000100001dca <_realloc$stub>: | |
100001dca: ff 25 d0 02 00 00 jmpq *0x2d0(%rip) # 1000020a0 <_realloc$stub> | |
Disassembly of section __TEXT.__stub_helper: | |
0000000100001dd0 <__TEXT.__stub_helper>: | |
100001dd0: 4c 8d 1d 31 02 00 00 lea 0x231(%rip),%r11 # 100002008 <> | |
100001dd7: 41 53 push %r11 | |
100001dd9: ff 25 21 02 00 00 jmpq *0x221(%rip) # 100002000 <dyld_stub_binder$stub> | |
100001ddf: 90 nop | |
100001de0: 68 00 00 00 00 pushq $0x0 | |
100001de5: e9 e6 ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001dea: 68 14 00 00 00 pushq $0x14 | |
100001def: e9 dc ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001df4: 68 2c 00 00 00 pushq $0x2c | |
100001df9: e9 d2 ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001dfe: 68 39 00 00 00 pushq $0x39 | |
100001e03: e9 c8 ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001e08: 68 47 00 00 00 pushq $0x47 | |
100001e0d: e9 be ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001e12: 68 53 00 00 00 pushq $0x53 | |
100001e17: e9 b4 ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001e1c: 68 61 00 00 00 pushq $0x61 | |
100001e21: e9 aa ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001e26: 68 6f 00 00 00 pushq $0x6f | |
100001e2b: e9 a0 ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001e30: 68 7c 00 00 00 pushq $0x7c | |
100001e35: e9 96 ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001e3a: 68 89 00 00 00 pushq $0x89 | |
100001e3f: e9 8c ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001e44: 68 98 00 00 00 pushq $0x98 | |
100001e49: e9 82 ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001e4e: 68 a4 00 00 00 pushq $0xa4 | |
100001e53: e9 78 ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001e58: 68 b4 00 00 00 pushq $0xb4 | |
100001e5d: e9 6e ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001e62: 68 c3 00 00 00 pushq $0xc3 | |
100001e67: e9 64 ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001e6c: 68 d2 00 00 00 pushq $0xd2 | |
100001e71: e9 5a ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
100001e76: 68 e2 00 00 00 pushq $0xe2 | |
100001e7b: e9 50 ff ff ff jmpq 100001dd0 <_realloc$stub+0x6> | |
Disassembly of section __TEXT.__unwind_info: | |
0000000100001f70 <__TEXT.__unwind_info>: | |
100001f70: 01 00 add %eax,(%rax) | |
100001f72: 00 00 add %al,(%rax) | |
100001f74: 1c 00 sbb $0x0,%al | |
100001f76: 00 00 add %al,(%rax) | |
100001f78: 00 00 add %al,(%rax) | |
100001f7a: 00 00 add %al,(%rax) | |
100001f7c: 1c 00 sbb $0x0,%al | |
100001f7e: 00 00 add %al,(%rax) | |
100001f80: 00 00 add %al,(%rax) | |
100001f82: 00 00 add %al,(%rax) | |
100001f84: 1c 00 sbb $0x0,%al | |
100001f86: 00 00 add %al,(%rax) | |
100001f88: 02 00 add (%rax),%al | |
100001f8a: 00 00 add %al,(%rax) | |
100001f8c: 70 0a jo 100001f98 <_realloc$stub+0x1ce> | |
100001f8e: 00 00 add %al,(%rax) | |
100001f90: 34 00 xor $0x0,%al | |
100001f92: 00 00 add %al,(%rax) | |
100001f94: 34 00 xor $0x0,%al | |
100001f96: 00 00 add %al,(%rax) | |
100001f98: 71 1d jno 100001fb7 <_realloc$stub+0x1ed> | |
100001f9a: 00 00 add %al,(%rax) | |
100001f9c: 00 00 add %al,(%rax) | |
100001f9e: 00 00 add %al,(%rax) | |
100001fa0: 34 00 xor $0x0,%al | |
100001fa2: 00 00 add %al,(%rax) | |
100001fa4: 03 00 add (%rax),%eax | |
100001fa6: 00 00 add %al,(%rax) | |
100001fa8: 0c 00 or $0x0,%al | |
100001faa: 01 00 add %eax,(%rax) | |
100001fac: 10 00 adc %al,(%rax) | |
100001fae: 01 00 add %eax,(%rax) | |
100001fb0: 00 00 add %al,(%rax) | |
100001fb2: 00 00 add %al,(%rax) | |
100001fb4: 00 00 add %al,(%rax) | |
100001fb6: 00 01 add %al,(%rcx) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment