#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();
void getline_my(char *line) {
  int i = 0;
  int c = 0;
  for (i = 0; ((c = getchar()) != EOF) && c != '\n' && i < 100; line++, i++) {
    *line = c;
  };
  *line++ = '\0';
}


x86 assembly (clang, -O0):
<getline_my>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x10(%rbp)
xor    %eax,%eax
mov    0x2ea2(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x11(%rbp)
je     116a <getline_my+0x5a>
xor    %eax,%eax
cmpl   $0xa,-0x10(%rbp)
mov    %al,-0x11(%rbp)
je     116a <getline_my+0x5a>
cmpl   $0x64,-0xc(%rbp)
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    117a <getline_my+0x6a>
jmp    119f <getline_my+0x8f>
mov    -0x10(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1131 <getline_my+0x21>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getline_my>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%eax
je     1164 <getline_my+0x54>
mov    0x2ebd(%rip),%r14
cmp    (%r14),%eax
je     1164 <getline_my+0x54>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %al,(%r15,%rbx,1)
xor    %eax,%eax
call   1030 <getchar@plt>
lea    0x1(%rbx),%rcx
cmp    $0xa,%eax
je     1161 <getline_my+0x51>
cmp    (%r14),%eax
je     1161 <getline_my+0x51>
cmp    $0x63,%ebx
mov    %rcx,%rbx
jb     1140 <getline_my+0x30>
add    %rcx,%r15
movb   $0x0,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@EOF = global i32 0
define void @getline_my(i8* nocapture writeonly %0) {
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp ne i32 %2, %3
%5 = icmp ne i32 %2, 10
%6 = and i1 %5, %4
br i1 %6, label %7, label %21
7: ; preds = %1, %7
%8 = phi i32 [ %14, %7 ], [ %2, %1 ]
%9 = phi i32 [ %13, %7 ], [ 0, %1 ]
%10 = phi i8* [ %12, %7 ], [ %0, %1 ]
%11 = trunc i32 %8 to i8
store i8 %11, i8* %10
%12 = getelementptr inbounds i8, i8* %10, i64 1
%13 = add nuw nsw i32 %9, 1
%14 = tail call i32 (...) @getchar()
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
%17 = icmp ne i32 %14, 10
%18 = and i1 %17, %16
%19 = icmp ult i32 %9, 99
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %7, label %21
21: ; preds = %7, %1
%22 = phi i8* [ %0, %1 ], [ %12, %7 ]
store i8 0, i8* %22
ret void
}