#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 *);
int getline(char *, int);
int /*<<< orphan*/ printf(char *, char *);
void printLongestInputLine() {
  int len = 0;
  int max = 0;
  char line[1000];
  char longest[1000];
  while ((len = getline(line, 1000)) > 0) {
    if (len > max) {
      max = len;
      copy(longest, line);
    }
  }
  if (max > 0) {
    printf("%s", longest);
  }
}


x86 assembly (clang, -O0):
<printLongestInputLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7e0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1050 <getline@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jle    1190 <printLongestInputLine+0x60>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    118b <printLongestInputLine+0x5b>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    -0x7e0(%rbp),%rdi
lea    -0x3f0(%rbp),%rsi
call   1040 <copy@plt>
jmp    1149 <printLongestInputLine+0x19>
cmpl   $0x0,-0x8(%rbp)
jle    11ad <printLongestInputLine+0x7d>
lea    -0x7e0(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
add    $0x7e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printLongestInputLine>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x7d8,%rsp
lea    0x3f0(%rsp),%rdi
mov    $0x3e8,%esi
call   1050 <getline@plt>
test   %eax,%eax
jle    11a9 <printLongestInputLine+0x79>
mov    %eax,%ebp
xor    %ebx,%ebx
mov    %rsp,%r14
lea    0x3f0(%rsp),%r15
jmp    1183 <printLongestInputLine+0x53>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1050 <getline@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1196 <printLongestInputLine+0x66>
cmp    %ebx,%ebp
jle    1170 <printLongestInputLine+0x40>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <copy@plt>
mov    %ebp,%ebx
jmp    1170 <printLongestInputLine+0x40>
test   %ebx,%ebx
jle    11a9 <printLongestInputLine+0x79>
lea    0xe5f(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @printLongestInputLine() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = call i32 @getline(i8* %3, i32 1000)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %21
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(i8* %4, i8* %3)
br label %13
13: ; preds = %11, %7
%14 = phi i32 [ %8, %11 ], [ %9, %7 ]
%15 = call i32 @getline(i8* %3, i32 1000)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %7, label %17
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 ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %21
21: ; preds = %0, %19, %17
ret void
}