#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(char *, char *);
scalar_t__ get_line(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
void get_max_line() {
  char *s, buf[128], max_buffer[128];
  int max;
  int max_len = 128;
  max = 0;
  while (get_line(buf, max_len) > 0) {
    int len;
    len = strlen(buf);
    if (len > max) {
      max = len;
      copy(max_buffer, buf);
    }
  }
  printf("max len line:%s\n", max_buffer);
}


x86 assembly (clang, -O0):
<get_max_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x80,-0x118(%rbp)
movl   $0x0,-0x114(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x118(%rbp),%esi
call   1030 <get_line@plt>
cmp    $0x0,%rax
jle    11c3 <get_max_line+0x83>
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x11c(%rbp)
mov    -0x11c(%rbp),%eax
cmp    -0x114(%rbp),%eax
jle    11be <get_max_line+0x7e>
mov    -0x11c(%rbp),%eax
mov    %eax,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1060 <copy@plt>
jmp    115f <get_max_line+0x1f>
lea    -0x110(%rbp),%rsi
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_max_line>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
lea    0x80(%rsp),%rdi
mov    $0x80,%esi
call   1030 <get_line@plt>
test   %rax,%rax
jle    11af <get_max_line+0x6f>
xor    %ebx,%ebx
lea    0x80(%rsp),%r15
mov    %rsp,%r14
jmp    1192 <get_max_line+0x52>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    $0x80,%esi
call   1030 <get_line@plt>
test   %rax,%rax
jle    11af <get_max_line+0x6f>
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    %ebx,%eax
jle    1180 <get_max_line+0x40>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <copy@plt>
mov    %ebp,%ebx
jmp    1180 <get_max_line+0x40>
lea    0xe4a(%rip),%rdi
mov    %rsp,%rsi
call   1050 <printf@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"max len line:%s\0A\00"
define void @get_max_line() {
%1 = alloca i8*
%2 = alloca [128 x i8]
%3 = alloca [128 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 128, i32* %5
store i32 0, i32* %4
br label %7
7: ; preds = %23, %0
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%9 = load i32, i32* %5
%10 = call i64 @get_line(i8* %8, i32 %9)
%11 = icmp sgt i64 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %7
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load i32, i32* %6
store i32 %19, i32* %4
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%22 = call i32 @copy(i8* %20, i8* %21)
br label %23
23: ; preds = %18, %12
br label %7
24: ; preds = %7
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %25)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"max len line:%s\0A\00"
define void @get_max_line() {
%1 = alloca [128 x i8]
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = call i64 @get_line(i8* %3, i32 128)
%6 = icmp sgt i64 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %0, %13
%8 = phi i32 [ %14, %13 ], [ 0, %0 ]
%9 = call i32 @strlen(i8* %3)
%10 = icmp sgt i32 %9, %8
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @copy(i8* %4, i8* %3)
br label %13
13: ; preds = %11, %7
%14 = phi i32 [ %9, %11 ], [ %8, %7 ]
%15 = call i64 @get_line(i8* %3, i32 128)
%16 = icmp sgt i64 %15, 0
br i1 %16, label %7, label %17
17: ; preds = %13, %0
%18 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %4)
ret void
}