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


x86 assembly (clang, -O0):
<getline_my>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <clear_line@plt>
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
mov    0x2e86(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x1d(%rbp)
je     1177 <getline_my+0x57>
cmpl   $0xa,-0x1c(%rbp)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1187 <getline_my+0x67>
jmp    11a5 <getline_my+0x85>
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114d <getline_my+0x2d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getline_my>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <clear_line@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1167 <getline_my+0x47>
mov    0x2ea9(%rip),%r14
cmp    (%r14),%eax
je     1167 <getline_my+0x47>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %al,(%rbx)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1167 <getline_my+0x47>
add    $0x1,%rbx
cmp    (%r14),%eax
jne    1150 <getline_my+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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