int main() {
  char line[100] = {0};
  int max = 0, len;
  while (len = my_getline(line, 100)) {
    printf("len : %d \n", len);
    if (len > 80) {
      printf("line : %s", len, line);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
movl   $0x0,-0x74(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
mov    $0x0,%al
call   1050 <my_getline@plt>
mov    %eax,-0x78(%rbp)
cmp    $0x0,%eax
je     11aa <main+0x7a>
mov    -0x78(%rbp),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x50,-0x78(%rbp)
jle    11a5 <main+0x75>
mov    -0x78(%rbp),%esi
lea    -0x70(%rbp),%rdx
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1159 <main+0x29>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
mov    %rsp,%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1050 <my_getline@plt>
test   %eax,%eax
je     11c7 <main+0x97>
mov    %eax,%ebp
lea    0xe82(%rip),%r15
lea    0xe86(%rip),%r14
mov    %rsp,%rbx
jmp    11a5 <main+0x75>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1050 <my_getline@plt>
mov    %eax,%ebp
test   %eax,%eax
je     11c7 <main+0x97>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x51,%ebp
jl     1190 <main+0x60>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1190 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"len : %d \0A\00"
@.str.1 = [10 x i8] c"line : %s\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [100 x i8]* %2 to i8*
store i32 0, i32* %3
br label %6
6: ; preds = %19, %0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @my_getline to i32 (i8*, i32, ...)*)(i8* %7, i32 100)
store i32 %8, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i32, i32* %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 80
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* %4
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %16, i8* %17)
br label %19
19: ; preds = %15, %10
br label %6
20: ; preds = %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"len : %d \0A\00"
@.str.1 = [10 x i8] c"line : %s\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @my_getline to i32 (i8*, i32, ...)*)(i8* %2, i32 100)
%4 = icmp eq i32 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %0, %11
%6 = phi i32 [ %12, %11 ], [ %3, %0 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp sgt i32 %6, 80
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %6, i8* %2)
br label %11
11: ; preds = %9, %5
%12 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @my_getline to i32 (i8*, i32, ...)*)(i8* %2, i32 100)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %11, %0
%15 = call i32 @putchar(i32 10)
ret i32 0
}