#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_array(char *, char *);
int get_line(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int current_line_length = 0;
  int longest_line_length = 0;
  char current_line[5];
  char longest_line[5];
  printf("Hit RETURN at the end of each line. When finished, input an empty "
         "line.\n");
  while ((current_line_length = get_line(current_line)) > 0) {
    if (current_line_length > longest_line_length) {
      longest_line_length = current_line_length;
      copy_array(current_line, longest_line);
    }
  }
  if (longest_line_length > 0) {
    printf("The longest line has length %d\n", longest_line_length);
  } else {
    printf("You didn't input any lines!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x11(%rbp),%rdi
call   1030 <get_line@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1194 <main+0x64>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    118f <main+0x5f>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x11(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1050 <copy_array@plt>
jmp    115b <main+0x2b>
cmpl   $0x0,-0xc(%rbp)
jle    11b4 <main+0x84>
mov    -0xc(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c2 <main+0x92>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xe(%rsp),%rdi
call   1040 <get_line@plt>
test   %eax,%eax
jle    11b7 <main+0x77>
mov    %eax,%ebp
xor    %ebx,%ebx
lea    0xe(%rsp),%r14
lea    0x13(%rsp),%r15
jmp    118e <main+0x4e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <get_line@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    11a1 <main+0x61>
cmp    %ebx,%ebp
jle    1180 <main+0x40>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <copy_array@plt>
mov    %ebp,%ebx
jmp    1180 <main+0x40>
test   %ebx,%ebx
jle    11b7 <main+0x77>
lea    0xe54(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c3 <main+0x83>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [73 x i8] c"Hit RETURN at the end of each line. When finished, input an empty line.\0A\00"
@.str.1 = [32 x i8] c"The longest line has length %d\0A\00"
@.str.2 = [29 x i8] c"You didn't input any lines!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [5 x i8]
%5 = alloca [5 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %20, %0
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%9 = call i32 @get_line(i8* %8)
store i32 %9, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = icmp sgt i32 %12, %13
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32, i32* %2
store i32 %16, i32* %3
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%19 = call i32 @copy_array(i8* %17, i8* %18)
br label %20
20: ; preds = %15, %11
br label %7
21: ; preds = %7
%22 = load i32, i32* %3
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %29
27: ; preds = %21
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [32 x i8] c"The longest line has length %d\0A\00"
@str = [72 x i8] c"Hit RETURN at the end of each line. When finished, input an empty line.\00"
@str.3 = [28 x i8] c"You didn't input any lines!\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str, i64 0, i64 0))
%6 = call i32 @get_line(i8* %3)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %0, %14
%9 = phi i32 [ %16, %14 ], [ %6, %0 ]
%10 = phi i32 [ %15, %14 ], [ 0, %0 ]
%11 = icmp sgt i32 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @copy_array(i8* %3, i8* %4)
br label %14
14: ; preds = %12, %8
%15 = phi i32 [ %9, %12 ], [ %10, %8 ]
%16 = call i32 @get_line(i8* %3)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %8, label %18
18: ; preds = %14
%19 = icmp sgt i32 %15, 0
br i1 %19, label %20, label %22
20: ; preds = %18
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %24
22: ; preds = %0, %18
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
ret i32 0
}