#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() {
  char c, string[30];
  int i = 0;
  while ((c = getchar()) != '\n') {
    string[i++] = c;
  }
  string[i] = '\0';
  puts(string);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     1165 <main+0x45>
mov    -0x5(%rbp),%cl
mov    -0x34(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x34(%rbp)
cltq
mov    %cl,-0x30(%rbp,%rax,1)
jmp    1136 <main+0x16>
movslq -0x34(%rbp),%rax
movb   $0x0,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1154 <main+0x34>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
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)
mov    %rsp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [30 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %9, %0
%6 = call signext i8 (...) @getchar()
store i8 %6, i8* %2
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 10
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = load i8, i8* %2
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %4
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %13
store i8 %10, i8* %14
br label %5
15: ; preds = %5
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %17
store i8 0, i8* %18
%19 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%20 = call i32 @puts(i8* %19)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [30 x i8]
%2 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%3 = tail call signext i8 (...) @getchar()
%4 = icmp eq i8 %3, 10
br i1 %4, label %14, label %5
5: ; preds = %0, %5
%6 = phi i64 [ %8, %5 ], [ 0, %0 ]
%7 = phi i8 [ %10, %5 ], [ %3, %0 ]
%8 = add nuw i64 %6, 1
%9 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %6
store i8 %7, i8* %9
%10 = tail call signext i8 (...) @getchar()
%11 = icmp eq i8 %10, 10
br i1 %11, label %12, label %5
12: ; preds = %5
%13 = and i64 %8, 4294967295
br label %14
14: ; preds = %12, %0
%15 = phi i64 [ 0, %0 ], [ %13, %12 ]
%16 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %15
store i8 0, i8* %16
%17 = call i32 @puts(i8* %2)
ret i32 0
}