int main(void) {
  printf("Please enter a sentence: ");
  char sentence[50];
  gets(sentence);
  getchar();
  printf("\nYou entered this sentence: %s", sentence);
  getchar();
  printf("\nThe sentence is %u characters long\n", strlen(sentence));
  char start[] = "My sentence is : ";
  strcat(start, sentence);
  printf("\n%s", sentence);
  getchar();
  printf("\n%s", start);
  flushall();
  return 0;
  getchar();
  flushall();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x0,%al
call   1070 <gets@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    -0x40(%rbp),%rsi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0xea7(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xea1(%rip),%ax
mov    %ax,-0x50(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x40(%rbp),%rsi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    -0x60(%rbp),%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <flushall@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <gets@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xe86(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xe85(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movaps 0xeab(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x20,0x10(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
lea    0xe79(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Please enter a sentence: \00"
@.str.1 = [31 x i8] c"\0AYou entered this sentence: %s\00"
@.str.2 = [37 x i8] c"\0AThe sentence is %u characters long\0A\00"
@__const.main.start = [18 x i8] c"My sentence is : \00"
@.str.3 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [18 x i8]
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @gets to i32 (i8*, ...)*)(i8* %5)
%7 = call i32 (...) @getchar()
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i32 (...) @getchar()
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%12 = call i64 @strlen(i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i64 %12)
%14 = bitcast [18 x i8]* %3 to i8*
%15 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%17 = call i8* @strcat(i8* %15, i8* %16)
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = call i32 (...) @getchar()
%21 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = call i32 (...) @flushall()
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Please enter a sentence: \00"
@.str.1 = [31 x i8] c"\0AYou entered this sentence: %s\00"
@.str.2 = [37 x i8] c"\0AThe sentence is %u characters long\0A\00"
@__const.main.start = [18 x i8] c"My sentence is : \00"
@.str.3 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [18 x i8]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @gets to i32 (i8*, ...)*)(i8* %4)
%6 = call i32 (...) @getchar()
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%8 = call i32 (...) @getchar()
%9 = call i64 @strlen(i8* %4)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i64 %9)
%11 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%12 = call i8* @strcat(i8* %11, i8* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%14 = call i32 (...) @getchar()
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%16 = call i32 (...) @flushall()
ret i32 0
}