#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 */
int EOF;
int getchar();
int main(void) {
  int i = 0, lim = 100, c;
  char s[100];
  while (i < (lim - 1)) {
    c = getchar();
    if (c == EOF)
      break;
    else if (c == '\n')
      break;
    s[i++] = c;
  }
  s[i] = '\0';
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x64,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1191 <main+0x81>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%eax
jne    1162 <main+0x52>
jmp    1191 <main+0x81>
cmpl   $0xa,-0x10(%rbp)
jne    1171 <main+0x61>
jmp    1191 <main+0x81>
jmp    1176 <main+0x66>
mov    -0x10(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
cltq
mov    %cl,-0x80(%rbp,%rax,1)
jmp    1130 <main+0x20>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x62,%ebx
mov    0x2ec8(%rip),%r14
xor    %eax,%eax
call   1030 <getchar@plt>
sub    $0x1,%ebx
setb   %cl
cmp    $0xa,%eax
je     113b <main+0x2b>
cmp    (%r14),%eax
je     113b <main+0x2b>
test   %cl,%cl
je     1120 <main+0x10>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@EOF = global i32 0
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 0, %0 ], [ %8, %1 ]
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
%6 = icmp eq i32 %3, 10
%7 = or i1 %6, %5
%8 = add nuw nsw i32 %2, 1
%9 = icmp eq i32 %8, 99
%10 = select i1 %7, i1 true, i1 %9
br i1 %10, label %11, label %1
11: ; preds = %1
ret i32 0
}