Last active
August 29, 2015 14:07
-
-
Save ramntry/68ab1d5be4481d211309 to your computer and use it in GitHub Desktop.
LanguageL Reverse
This file contains hidden or 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
| program7: runtime.o program7.o | |
| gcc $^ -o $@ |
This file contains hidden or 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
| .globl main | |
| .comm var_x, 8 | |
| .comm var_not_found_yet, 8 | |
| .comm var_divider, 8 | |
| .comm var_factor, 8 | |
| .comm var_acc, 8 | |
| main: xorq %rbx, %rbx | |
| .L0: call runtime_read | |
| .L1: movq %rax, %r12 | |
| .L2: movq $1, %r13 | |
| .L4: movq $1, %r14 | |
| .L6: movq %r12, %r15 | |
| .L8: jmp .L80 | |
| .L9: call runtime_read | |
| .L10: movq %rax, var_x | |
| .L11: movq $1, var_not_found_yet | |
| .L13: jmp .L46 | |
| .L14: pushq %r14 | |
| .L15: movq $1, %rcx | |
| addq %rcx, (%rsp) | |
| .L17: popq %r14 | |
| .L18: movq $0, var_not_found_yet | |
| .L20: movq $2, var_divider | |
| .L22: jmp .L36 | |
| .L23: pushq %r14 | |
| .L24: movq var_divider, %rcx | |
| popq %rax | |
| cqto | |
| idivq %rcx | |
| pushq %rdx | |
| .L26: xorq %rcx, %rcx | |
| popq %rax | |
| cmpq %rcx, %rax | |
| .L28: jne .L32 | |
| .L29: movq $1, var_not_found_yet | |
| .L31: jmp .L36 | |
| .L32: pushq var_divider | |
| .L33: movq $1, %rcx | |
| addq %rcx, (%rsp) | |
| .L35: popq var_divider | |
| .L36: pushq var_divider | |
| .L37: movq var_divider, %rax | |
| imulq (%rsp) | |
| movq %rax, (%rsp) | |
| .L39: movq %r14, %rcx | |
| popq %rax | |
| cmpq %rcx, %rax | |
| setle %bl | |
| pushq %rbx | |
| .L41: pushq $1 | |
| .L42: movq var_not_found_yet, %rcx | |
| subq %rcx, (%rsp) | |
| .L44: popq %rcx | |
| andq %rcx, (%rsp) | |
| .L45: popq %rax | |
| orq %rax, %rax | |
| jnz .L23 | |
| .L46: movq var_not_found_yet, %rax | |
| orq %rax, %rax | |
| jnz .L14 | |
| .L48: movq %r14, var_factor | |
| .L50: movq $1, var_acc | |
| .L52: jmp .L70 | |
| .L53: pushq var_x | |
| .L54: movq $2, %rcx | |
| popq %rax | |
| cqto | |
| idivq %rcx | |
| .L56: movq %rdx, %rax | |
| orq %rax, %rax | |
| jz .L62 | |
| .L57: pushq var_acc | |
| .L58: movq var_factor, %rax | |
| imulq (%rsp) | |
| movq %rax, var_acc | |
| .L60: addq $8, %rsp | |
| .L62: pushq var_factor | |
| .L63: movq var_factor, %rax | |
| imulq (%rsp) | |
| movq %rax, var_factor | |
| .L65: addq $8, %rsp | |
| .L66: pushq var_x | |
| .L67: movq $2, %rcx | |
| popq %rax | |
| cqto | |
| idivq %rcx | |
| .L69: movq %rax, var_x | |
| .L70: pushq var_x | |
| .L71: xorq %rcx, %rcx | |
| popq %rax | |
| cmpq %rcx, %rax | |
| .L73: jg .L53 | |
| .L74: pushq var_acc | |
| .L75: popq var_factor | |
| .L76: pushq %r13 | |
| .L77: movq var_factor, %rax | |
| imulq (%rsp) | |
| movq %rax, %r13 | |
| .L79: addq $8, %rsp | |
| .L80: pushq %r15 | |
| .L81: pushq %r15 | |
| .L82: movq $1, %rcx | |
| subq %rcx, (%rsp) | |
| .L84: popq %r15 | |
| .L85: xorq %rcx, %rcx | |
| popq %rax | |
| cmpq %rcx, %rax | |
| .L87: jg .L9 | |
| .L88: movq %r12, %rdi | |
| call runtime_write | |
| .L90: movq %r12, %r15 | |
| .L92: jmp .L149 | |
| .L93: movq $0, var_x | |
| .L95: jmp .L104 | |
| .L96: pushq var_x | |
| .L97: movq $1, %rcx | |
| addq %rcx, (%rsp) | |
| .L99: popq var_x | |
| .L100: pushq %r13 | |
| .L101: movq %r14, %rcx | |
| popq %rax | |
| cqto | |
| idivq %rcx | |
| .L103: movq %rax, %r13 | |
| .L104: pushq %r13 | |
| .L105: movq %r14, %rcx | |
| popq %rax | |
| cqto | |
| idivq %rcx | |
| pushq %rdx | |
| .L107: xorq %rcx, %rcx | |
| popq %rax | |
| cmpq %rcx, %rax | |
| .L109: je .L96 | |
| .L110: movq $1, var_not_found_yet | |
| .L112: jmp .L145 | |
| .L113: pushq %r14 | |
| .L114: movq $1, %rcx | |
| subq %rcx, (%rsp) | |
| .L116: popq %r14 | |
| .L117: movq $0, var_not_found_yet | |
| .L119: movq $2, var_divider | |
| .L121: jmp .L135 | |
| .L122: pushq %r14 | |
| .L123: movq var_divider, %rcx | |
| popq %rax | |
| cqto | |
| idivq %rcx | |
| pushq %rdx | |
| .L125: xorq %rcx, %rcx | |
| popq %rax | |
| cmpq %rcx, %rax | |
| .L127: jne .L131 | |
| .L128: movq $1, var_not_found_yet | |
| .L130: jmp .L135 | |
| .L131: pushq var_divider | |
| .L132: movq $1, %rcx | |
| addq %rcx, (%rsp) | |
| .L134: popq var_divider | |
| .L135: pushq var_divider | |
| .L136: movq var_divider, %rax | |
| imulq (%rsp) | |
| movq %rax, (%rsp) | |
| .L138: movq %r14, %rcx | |
| popq %rax | |
| cmpq %rcx, %rax | |
| setle %bl | |
| pushq %rbx | |
| .L140: pushq $1 | |
| .L141: movq var_not_found_yet, %rcx | |
| subq %rcx, (%rsp) | |
| .L143: popq %rcx | |
| andq %rcx, (%rsp) | |
| .L144: popq %rax | |
| orq %rax, %rax | |
| jnz .L122 | |
| .L145: movq var_not_found_yet, %rax | |
| orq %rax, %rax | |
| jnz .L113 | |
| .L147: movq var_x, %rdi | |
| call runtime_write | |
| .L149: pushq %r15 | |
| .L150: pushq %r15 | |
| .L151: movq $1, %rcx | |
| subq %rcx, (%rsp) | |
| .L153: popq %r15 | |
| .L154: xorq %rcx, %rcx | |
| popq %rax | |
| cmpq %rcx, %rax | |
| .L156: jg .L93 | |
| .L157: xorq %rdi, %rdi | |
| call exit |
This file contains hidden or 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
| read(n); | |
| list := 1; | |
| last_prime := 1; | |
| i := n; | |
| while i-- > 0 do | |
| read(x); | |
| not_found_yet := 1; | |
| while not_found_yet do | |
| last_prime := last_prime + 1; | |
| not_found_yet := 0; | |
| divider := 2; | |
| while divider * divider <= last_prime && 1 - not_found_yet do | |
| if last_prime % divider == 0 then | |
| not_found_yet := 1 | |
| else | |
| divider := divider + 1; | |
| factor := last_prime; | |
| acc := 1; | |
| while x > 0 do | |
| if x % 2 then | |
| acc := acc * factor | |
| else | |
| skip; | |
| factor := factor * factor; | |
| x := x / 2; | |
| factor := acc; | |
| list := list * factor; | |
| write(n); | |
| i := n; | |
| while i-- > 0 do | |
| x := 0; | |
| while list % last_prime == 0 do | |
| x := x + 1; | |
| list := list / last_prime; | |
| not_found_yet := 1; | |
| while not_found_yet do | |
| last_prime := last_prime - 1; | |
| not_found_yet := 0; | |
| divider := 2; | |
| while divider * divider <= last_prime && 1 - not_found_yet do | |
| if last_prime % divider == 0 then | |
| not_found_yet := 1 | |
| else | |
| divider := divider + 1; | |
| write(x) |
This file contains hidden or 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
| 0: Read | |
| 1: Store n | |
| 2: Const 1 | |
| 3: Store list | |
| 4: Const 1 | |
| 5: Store last_prime | |
| 6: Load n | |
| 7: Store i | |
| 8: Jump :80 | |
| 9: Read | |
| 10: Store x | |
| 11: Const 1 | |
| 12: Store not_found_yet | |
| 13: Jump :46 | |
| 14: Load last_prime | |
| 15: Const 1 | |
| 16: ( + ) | |
| 17: Store last_prime | |
| 18: Const 0 | |
| 19: Store not_found_yet | |
| 20: Const 2 | |
| 21: Store divider | |
| 22: Jump :36 | |
| 23: Load last_prime | |
| 24: Load divider | |
| 25: ( % ) | |
| 26: Const 0 | |
| 27: ( == ) | |
| 28: JumpIf0 :32 | |
| 29: Const 1 | |
| 30: Store not_found_yet | |
| 31: Jump :36 | |
| 32: Load divider | |
| 33: Const 1 | |
| 34: ( + ) | |
| 35: Store divider | |
| 36: Load divider | |
| 37: Load divider | |
| 38: ( * ) | |
| 39: Load last_prime | |
| 40: ( <= ) | |
| 41: Const 1 | |
| 42: Load not_found_yet | |
| 43: ( - ) | |
| 44: ( && ) | |
| 45: JumpIf1 :23 | |
| 46: Load not_found_yet | |
| 47: JumpIf1 :14 | |
| 48: Load last_prime | |
| 49: Store factor | |
| 50: Const 1 | |
| 51: Store acc | |
| 52: Jump :70 | |
| 53: Load x | |
| 54: Const 2 | |
| 55: ( % ) | |
| 56: JumpIf0 :62 | |
| 57: Load acc | |
| 58: Load factor | |
| 59: ( * ) | |
| 60: Store acc | |
| 61: Jump :62 | |
| 62: Load factor | |
| 63: Load factor | |
| 64: ( * ) | |
| 65: Store factor | |
| 66: Load x | |
| 67: Const 2 | |
| 68: ( / ) | |
| 69: Store x | |
| 70: Load x | |
| 71: Const 0 | |
| 72: ( > ) | |
| 73: JumpIf1 :53 | |
| 74: Load acc | |
| 75: Store factor | |
| 76: Load list | |
| 77: Load factor | |
| 78: ( * ) | |
| 79: Store list | |
| 80: Load i | |
| 81: Load i | |
| 82: Const 1 | |
| 83: ( - ) | |
| 84: Store i | |
| 85: Const 0 | |
| 86: ( > ) | |
| 87: JumpIf1 :9 | |
| 88: Load n | |
| 89: Write | |
| 90: Load n | |
| 91: Store i | |
| 92: Jump :149 | |
| 93: Const 0 | |
| 94: Store x | |
| 95: Jump :104 | |
| 96: Load x | |
| 97: Const 1 | |
| 98: ( + ) | |
| 99: Store x | |
| 100: Load list | |
| 101: Load last_prime | |
| 102: ( / ) | |
| 103: Store list | |
| 104: Load list | |
| 105: Load last_prime | |
| 106: ( % ) | |
| 107: Const 0 | |
| 108: ( == ) | |
| 109: JumpIf1 :96 | |
| 110: Const 1 | |
| 111: Store not_found_yet | |
| 112: Jump :145 | |
| 113: Load last_prime | |
| 114: Const 1 | |
| 115: ( - ) | |
| 116: Store last_prime | |
| 117: Const 0 | |
| 118: Store not_found_yet | |
| 119: Const 2 | |
| 120: Store divider | |
| 121: Jump :135 | |
| 122: Load last_prime | |
| 123: Load divider | |
| 124: ( % ) | |
| 125: Const 0 | |
| 126: ( == ) | |
| 127: JumpIf0 :131 | |
| 128: Const 1 | |
| 129: Store not_found_yet | |
| 130: Jump :135 | |
| 131: Load divider | |
| 132: Const 1 | |
| 133: ( + ) | |
| 134: Store divider | |
| 135: Load divider | |
| 136: Load divider | |
| 137: ( * ) | |
| 138: Load last_prime | |
| 139: ( <= ) | |
| 140: Const 1 | |
| 141: Load not_found_yet | |
| 142: ( - ) | |
| 143: ( && ) | |
| 144: JumpIf1 :122 | |
| 145: Load not_found_yet | |
| 146: JumpIf1 :113 | |
| 147: Load x | |
| 148: Write | |
| 149: Load i | |
| 150: Load i | |
| 151: Const 1 | |
| 152: ( - ) | |
| 153: Store i | |
| 154: Const 0 | |
| 155: ( > ) | |
| 156: JumpIf1 :93 | |
| 157: End |
This file contains hidden or 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
| #include <stdio.h> | |
| long long runtime_read() { | |
| long long value = 0; | |
| scanf("%lld", &value); | |
| return value; | |
| } | |
| void runtime_write(long long value) { | |
| printf("%lld\n", value); | |
| } |
ramntry
commented
Oct 12, 2014
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment