#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
#define EOF 128
int getc(int /*<<< orphan*/ *);
int getLine(FILE *filein, char *line) {
  int i = 0;
  int c;
  while (1) {
    c = getc(filein);
    switch (c) {
    case EOF:
    case '\n':
      line[i] = '\0';
      return c;
      break;
    default:
      line[i++] = c;
      break;
    }
    if (i >= 100) {
      line[i] = '\0';
      return c;
    }
  }
}


x86 assembly (clang, -O0):
<getLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0xa,%eax
je     115a <getLine+0x4a>
jmp    1147 <getLine+0x37>
mov    -0x24(%rbp),%eax
sub    $0x80,%eax
jne    1171 <getLine+0x61>
jmp    115a <getLine+0x4a>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b1 <getLine+0xa1>
mov    -0x20(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
cmpl   $0x64,-0x1c(%rbp)
jl     11ac <getLine+0x9c>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b1 <getLine+0xa1>
jmp    1127 <getLine+0x17>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLine>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   (%rax)
mov    %r15,%rdi
call   1030 <getc@plt>
cmp    $0x80,%eax
je     1147 <getLine+0x37>
cmp    $0xa,%eax
je     1147 <getLine+0x37>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1120 <getLine+0x10>
mov    $0x64,%ebx
movb   $0x0,(%r14,%rbx,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @getLine(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %8
8: ; preds = %2, %35
%9 = load i32*, i32** %4
%10 = call i32 @getc(i32* %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
switch i32 %11, label %18 [
i32 128, label %12
i32 10, label %12
]
12: ; preds = %8, %8
%13 = load i8*, i8** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
store i8 0, i8* %16
%17 = load i32, i32* %7
store i32 %17, i32* %3
br label %36
18: ; preds = %8
%19 = load i32, i32* %7
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %5
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
store i8 %20, i8* %25
br label %26
26: ; preds = %18
%27 = load i32, i32* %6
%28 = icmp sge i32 %27, 100
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i8*, i8** %5
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 0, i8* %33
%34 = load i32, i32* %7
store i32 %34, i32* %3
br label %36
35: ; preds = %26
br label %8
36: ; preds = %29, %12
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
define i32 @getLine(i32* nocapture %0, i8* nocapture writeonly %1) {
br label %3
3: ; preds = %8, %2
%4 = phi i64 [ %10, %8 ], [ 0, %2 ]
%5 = tail call i32 @getc(i32* %0)
switch i32 %5, label %8 [
i32 128, label %6
i32 10, label %6
]
6: ; preds = %3, %3
%7 = and i64 %4, 4294967295
br label %13
8: ; preds = %3
%9 = trunc i32 %5 to i8
%10 = add nuw nsw i64 %4, 1
%11 = getelementptr inbounds i8, i8* %1, i64 %4
store i8 %9, i8* %11
%12 = icmp eq i64 %10, 100
br i1 %12, label %13, label %3
13: ; preds = %8, %6
%14 = phi i64 [ %7, %6 ], [ 100, %8 ]
%15 = getelementptr inbounds i8, i8* %1, i64 %14
store i8 0, i8* %15
ret i32 %5
}