#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 getchar();
int getl(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  int max, len;
  char line[10];
  char longest[10];
  max = 0;
  while ((len = getl(line, 10)) > 0) {
    if (line[len - 1] != '\n') {
      int c;
      while ((c = getchar()) != '\n') {
        ++len;
      }
    }
    if (len > max) {
      max = len;
      copy(longest, line);
    }
  }
  if (max > 0) {
    printf("The longest line is: %s", longest);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x16(%rbp),%rdi
mov    $0xa,%esi
call   1030 <getl@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    11d5 <main+0x95>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x16(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     11b1 <main+0x71>
jmp    118b <main+0x4b>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xa,%eax
je     11ac <main+0x6c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118b <main+0x4b>
jmp    11b1 <main+0x71>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    11d0 <main+0x90>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1050 <copy@plt>
jmp    1156 <main+0x16>
cmpl   $0x0,-0x8(%rbp)
jle    11ef <main+0xaf>
lea    -0x20(%rbp),%rsi
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0x4(%rsp),%rdi
mov    $0xa,%esi
call   1030 <getl@plt>
test   %eax,%eax
jle    11c7 <main+0x87>
mov    %eax,%ebx
lea    0xe(%rsp),%r14
lea    0x4(%rsp),%r15
xor    %ebp,%ebp
jmp    1183 <main+0x43>
nopl   (%rax)
mov    %r15,%rdi
mov    $0xa,%esi
call   1030 <getl@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    11b2 <main+0x72>
lea    -0x1(%rbx),%eax
cmpb   $0xa,0x4(%rsp,%rax,1)
je     119f <main+0x5f>
mov    %eax,%ebx
nop
xor    %eax,%eax
call   1060 <getchar@plt>
add    $0x1,%ebx
cmp    $0xa,%eax
jne    1190 <main+0x50>
cmp    %ebp,%ebx
jle    1170 <main+0x30>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <copy@plt>
mov    %ebx,%ebp
jmp    1170 <main+0x30>
test   %ebp,%ebp
jle    11c7 <main+0x87>
lea    0xe43(%rip),%rdi
lea    0xe(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"The longest line is: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i8]
%5 = alloca [10 x i8]
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %7
7: ; preds = %36, %0
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%9 = call i32 @getl(i8* %8, i32 10)
store i32 %9, i32* %3
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %37
11: ; preds = %7
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 10
br i1 %18, label %19, label %27
19: ; preds = %11
br label %20
20: ; preds = %23, %19
%21 = call i32 (...) @getchar()
store i32 %21, i32* %6
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %20
26: ; preds = %20
br label %27
27: ; preds = %26, %11
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = icmp sgt i32 %28, %29
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i32, i32* %3
store i32 %32, i32* %2
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%35 = call i32 @copy(i8* %33, i8* %34)
br label %36
36: ; preds = %31, %27
br label %7
37: ; preds = %7
%38 = load i32, i32* %2
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%42 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %40, %37
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"The longest line is: %s\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = call i32 @getl(i8* %3, i32 10)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %33
7: ; preds = %0, %25
%8 = phi i32 [ %27, %25 ], [ %5, %0 ]
%9 = phi i32 [ %26, %25 ], [ 0, %0 ]
%10 = add nsw i32 %8, -1
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 10
br i1 %14, label %20, label %15
15: ; preds = %7, %15
%16 = phi i32 [ %19, %15 ], [ %8, %7 ]
%17 = call i32 (...) @getchar()
%18 = icmp eq i32 %17, 10
%19 = add nsw i32 %16, 1
br i1 %18, label %20, label %15
20: ; preds = %15, %7
%21 = phi i32 [ %8, %7 ], [ %16, %15 ]
%22 = icmp sgt i32 %21, %9
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @copy(i8* %4, i8* %3)
br label %25
25: ; preds = %23, %20
%26 = phi i32 [ %21, %23 ], [ %9, %20 ]
%27 = call i32 @getl(i8* %3, i32 10)
%28 = icmp sgt i32 %27, 0
br i1 %28, label %7, label %29
29: ; preds = %25
%30 = icmp sgt i32 %26, 0
br i1 %30, label %31, label %33
31: ; preds = %29
%32 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %33
33: ; preds = %0, %31, %29
ret i32 0
}