Created
July 23, 2014 06:51
-
-
Save nrubin/811c27000adffcd3328b 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
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int main (void){ | |
int n = 10000; | |
char* s1 = (char *) malloc(sizeof(char) * n); | |
char* s2 = (char *) malloc(sizeof(char) * n); | |
strcpy(s1,"Hello World!"); | |
strcpy(s2,strcat(s1,s1+1)); | |
printf("%s",s2); | |
return 0; | |
} |
nlintz
commented
Jul 23, 2014
Original version
.section __TEXT,__text,regular,pure_instructions
.globl _main
.align 4, 0x90
_main: ## @main
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp2:
.cfi_def_cfa_offset 16
Ltmp3:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp4:
.cfi_def_cfa_register %rbp
subq $64, %rsp
movl $0, -4(%rbp)
movl $10000, -8(%rbp) ## imm = 0x2710
movslq -8(%rbp), %rax
shlq $0, %rax
movq %rax, %rdi
callq _malloc
movq %rax, -16(%rbp)
movslq -8(%rbp), %rax
shlq $0, %rax
movq %rax, %rdi
callq _malloc
leaq L_.str(%rip), %rsi
movabsq $-1, %rdx
movq %rax, -24(%rbp)
movq -16(%rbp), %rdi
callq ___strcpy_chk
movabsq $-1, %rdx
movq -24(%rbp), %rdi
movq -16(%rbp), %rsi
movq -16(%rbp), %rcx
addq $1, %rcx
movq %rdi, -32(%rbp) ## 8-byte Spill
movq %rsi, %rdi
movq %rcx, %rsi
movq %rax, -40(%rbp) ## 8-byte Spill
callq ___strcat_chk
movabsq $-1, %rdx
movq -32(%rbp), %rdi ## 8-byte Reload
movq %rax, %rsi
callq ___strcpy_chk
leaq L_.str1(%rip), %rdi
movq -24(%rbp), %rsi
movq %rax, -48(%rbp) ## 8-byte Spill
movb $0, %al
callq _printf
movl $0, %r8d
movl %eax, -52(%rbp) ## 4-byte Spill
movl %r8d, %eax
addq $64, %rsp
popq %rbp
ret
.cfi_endproc
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "Hello World!"
L_.str1: ## @.str1
.asciz "%s"
.subsections_via_symbols
Nathan's Version
.section __TEXT,__text,regular,pure_instructions
.globl _main
.align 4, 0x90
_main: ## @main
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp2:
.cfi_def_cfa_offset 16
Ltmp3:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp4:
.cfi_def_cfa_register %rbp
subq $64, %rsp
movl $0, -4(%rbp)
movl $10000, -8(%rbp) ## imm = 0x2710
movslq -8(%rbp), %rax
shlq $0, %rax
movq %rax, %rdi
callq _malloc
movq %rax, -16(%rbp)
movslq -8(%rbp), %rax
shlq $0, %rax
movq %rax, %rdi
callq _malloc
leaq L_.str(%rip), %rsi
movabsq $-1, %rdx
movq %rax, -24(%rbp)
movq -16(%rbp), %rdi
callq ___strcpy_chk
movq -24(%rbp), %rdi
movq -16(%rbp), %rdx
movq %rdi, -32(%rbp) ## 8-byte Spill
movq %rdx, %rdi
movq %rax, -40(%rbp) ## 8-byte Spill
callq _strdup
movabsq $-1, %rdx
movq -16(%rbp), %rsi
addq $1, %rsi
movq %rax, %rdi
callq ___strcat_chk
movabsq $-1, %rdx
movq -32(%rbp), %rdi ## 8-byte Reload
movq %rax, %rsi
callq ___strcpy_chk
leaq L_.str1(%rip), %rdi
movq -24(%rbp), %rsi
movq %rax, -48(%rbp) ## 8-byte Spill
movb $0, %al
callq _printf
movl $0, %ecx
movl %eax, -52(%rbp) ## 4-byte Spill
movl %ecx, %eax
addq $64, %rsp
popq %rbp
ret
.cfi_endproc
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "Hello World!"
L_.str1: ## @.str1
.asciz "%s"
.subsections_via_symbols
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment