#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 /*<<< orphan*/ printf(char *);
int getLine(char line[]) {
  int size, c;
  printf("Please enter a phrase or return to end this\n");
  for (size = 0; size < 100 - 1 && (c = getchar()) != EOF && c != '\n'; size++)
    line[size] = c;
  line[size] = '\0';
  return size;
}


x86 assembly (clang, -O0):
<getLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x63,-0xc(%rbp)
mov    %al,-0x11(%rbp)
jge    1178 <getLine+0x58>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x10(%rbp)
xor    %eax,%eax
mov    0x2e85(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x11(%rbp)
je     1178 <getLine+0x58>
cmpl   $0xa,-0x10(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1188 <getLine+0x68>
jmp    11a6 <getLine+0x86>
mov    -0x10(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113f <getLine+0x1f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLine>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
mov    0x2ead(%rip),%r15
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1164 <getLine+0x44>
cmp    (%r15),%eax
je     1164 <getLine+0x44>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    $0x63,%rbx
jne    1140 <getLine+0x20>
mov    $0x63,%ebx
mov    %ebx,%eax
movb   $0x0,(%r14,%rax,1)
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Please enter a phrase or return to end this\0A\00"
@EOF = global i32 0
define i32 @getLine(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %6
6: ; preds = %25, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 99
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = call i32 (...) @getchar()
store i32 %10, i32* %4
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 10
br label %16
16: ; preds = %13, %9, %6
%17 = phi i1 [ false, %9 ], [ false, %6 ], [ %15, %13 ]
br i1 %17, label %18, label %28
18: ; preds = %16
%19 = load i32, i32* %4
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 %20, i8* %24
br label %25
25: ; preds = %18
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %6
28: ; preds = %16
%29 = load i8*, i8** %2
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 0, i8* %32
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@EOF = global i32 0
@str = [44 x i8] c"Please enter a phrase or return to end this\00"
define i32 @getLine(i8* nocapture writeonly %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %3
3: ; preds = %1, %10
%4 = phi i64 [ 0, %1 ], [ %13, %10 ]
%5 = tail call i32 (...) @getchar()
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
%8 = icmp ne i32 %5, 10
%9 = and i1 %8, %7
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = trunc i32 %5 to i8
%12 = getelementptr inbounds i8, i8* %0, i64 %4
store i8 %11, i8* %12
%13 = add nuw nsw i64 %4, 1
%14 = icmp eq i64 %13, 99
br i1 %14, label %17, label %3
15: ; preds = %3
%16 = trunc i64 %4 to i32
br label %17
17: ; preds = %10, %15
%18 = phi i32 [ %16, %15 ], [ 99, %10 ]
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
store i8 0, i8* %20
ret i32 %18
}