#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
char getchar();
int /*<<< orphan*/ puts(char *);
int main(void) {
  char c;
  char sentence[80];
  int i = 0;
  puts("Enter a line of text:");
  while ((c = getchar()) != '\n') {
    sentence[i++] = c;
  }
  sentence[i] = '\0';
  puts("\nThe line entered was:");
  puts(sentence);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x64(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     1171 <main+0x51>
mov    -0x5(%rbp),%cl
mov    -0x64(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x64(%rbp)
cltq
mov    %cl,-0x60(%rbp,%rax,1)
jmp    1142 <main+0x22>
movslq -0x64(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
lea    -0x60(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1154 <main+0x34>
xor    %ebx,%ebx
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1140 <main+0x20>
mov    %ebx,%ebx
movb   $0x0,(%rsp,%rbx,1)
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter a line of text:\00"
@.str.1 = [23 x i8] c"\0AThe line entered was:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [80 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %10, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 10
br i1 %9, label %10, label %16
10: ; preds = %6
%11 = load i8, i8* %2
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 1
store i32 %13, i32* %4
%14 = sext i32 %12 to i64
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %14
store i8 %11, i8* %15
br label %6
16: ; preds = %6
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %18
store i8 0, i8* %19
%20 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%22 = call i32 @puts(i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Enter a line of text:\00"
@.str.1 = [23 x i8] c"\0AThe line entered was:\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = tail call signext i8 (...) @getchar()
%5 = icmp eq i8 %4, 10
br i1 %5, label %15, label %6
6: ; preds = %0, %6
%7 = phi i64 [ %9, %6 ], [ 0, %0 ]
%8 = phi i8 [ %11, %6 ], [ %4, %0 ]
%9 = add nuw i64 %7, 1
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %7
store i8 %8, i8* %10
%11 = tail call signext i8 (...) @getchar()
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %6
13: ; preds = %6
%14 = and i64 %9, 4294967295
br label %15
15: ; preds = %13, %0
%16 = phi i64 [ 0, %0 ], [ %14, %13 ]
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %16
store i8 0, i8* %17
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @puts(i8* %2)
ret i32 0
}