#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 /*<<< orphan*/ copy_str(char *, char *);
int my_getline(char *, int);
int /*<<< orphan*/ printf(char *, int, char *);
int main() {
  char line[100] = {0};
  char longest[100] = {0};
  int max = 0, len;
  while (len = my_getline(line, 100)) {
    if (len > max) {
      max = len;
      copy_str(longest, line);
    }
  }
  if (max > 0) {
    printf("max : %d longest: %s\n", max, longest);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
movl   $0x0,-0xe4(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
call   1060 <my_getline@plt>
mov    %eax,-0xe8(%rbp)
cmp    $0x0,%eax
je     11cf <main+0x8f>
mov    -0xe8(%rbp),%eax
cmp    -0xe4(%rbp),%eax
jle    11ca <main+0x8a>
mov    -0xe8(%rbp),%eax
mov    %eax,-0xe4(%rbp)
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1050 <copy_str@plt>
jmp    117f <main+0x3f>
cmpl   $0x0,-0xe4(%rbp)
jle    11f5 <main+0xb5>
mov    -0xe4(%rbp),%esi
lea    -0xe0(%rbp),%rdx
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xd8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
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)
lea    0x70(%rsp),%rdi
mov    $0x64,%esi
call   1050 <my_getline@plt>
test   %eax,%eax
je     11fb <main+0xcb>
mov    %eax,%ebp
xor    %ebx,%ebx
mov    %rsp,%r14
lea    0x70(%rsp),%r15
jmp    11d3 <main+0xa3>
xchg   %ax,%ax
mov    %r15,%rdi
mov    $0x64,%esi
call   1050 <my_getline@plt>
mov    %eax,%ebp
test   %eax,%eax
je     11e6 <main+0xb6>
cmp    %ebx,%ebp
jle    11c0 <main+0x90>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <copy_str@plt>
mov    %ebp,%ebx
jmp    11c0 <main+0x90>
test   %ebx,%ebx
jle    11fb <main+0xcb>
lea    0xe0f(%rip),%rdi
mov    %rsp,%rdx
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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