#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 EOF;
char getchar();
int /*<<< orphan*/ puts(char *);
int main() {
  char str[100];
  int pos;
  char c;
  pos = 0;
  while (pos < 100) {
    c = getchar();
    if (c == EOF) {
      break;
    }
    if (c == '\n') {
      break;
    }
    str[pos++] = c;
  }
  str[pos] = '\0';
  puts(str);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x74(%rbp)
cmpl   $0x64,-0x74(%rbp)
jge    1193 <main+0x73>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x75(%rbp)
movsbl -0x75(%rbp),%eax
mov    0x2e90(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1168 <main+0x48>
jmp    1193 <main+0x73>
movsbl -0x75(%rbp),%eax
cmp    $0xa,%eax
jne    117a <main+0x5a>
jmp    1193 <main+0x73>
mov    -0x75(%rbp),%cl
mov    -0x74(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x74(%rbp)
cltq
mov    %cl,-0x70(%rbp,%rax,1)
jmp    1139 <main+0x19>
movslq -0x74(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    0x2eba(%rip),%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1152 <main+0x32>
cmp    (%r14),%al
je     1152 <main+0x32>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1130 <main+0x10>
mov    $0x64,%ebx
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %21, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 100
br i1 %7, label %8, label %27
8: ; preds = %5
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %4
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
%12 = load i8, i8* @EOF
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %11, %13
br i1 %14, label %15, label %16
15: ; preds = %8
br label %27
16: ; preds = %8
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %21
20: ; preds = %16
br label %27
21: ; preds = %16
%22 = load i8, i8* %4
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %25
store i8 %22, i8* %26
br label %5
27: ; preds = %20, %15, %5
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %29
store i8 0, i8* %30
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%32 = call i32 @puts(i8* %31)
%33 = load i32, i32* %1
ret i32 %33
}

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