#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 EOF;
int /*<<< orphan*/ copy(char *, char *);
int get_line(char *, int);
int getchar();
int /*<<< orphan*/ printf(char *, int, int, char *);
int main() {
  int c;
  int len;
  int max;
  char line[10];
  char longest[10];
  max = 0;
  while ((len = get_line(line, 10)) > 0) {
    if (line[len - 1] != '\n')
      while ((c = getchar()) != EOF && c != '\n')
        len++;
    if (len > max) {
      max = len;
      copy(longest, line);
    }
  }
  if (max > 0) {
    printf("Longest line has %d characters (including \\n), first %d "
           "characters are %s",
           max, 10, longest);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x1a(%rbp),%rdi
mov    $0xa,%esi
call   1030 <get_line@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    11fc <main+0xbc>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x1a(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     11d8 <main+0x98>
jmp    118b <main+0x4b>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
mov    0x2e48(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x25(%rbp)
je     11b5 <main+0x75>
cmpl   $0xa,-0x8(%rbp)
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11c5 <main+0x85>
jmp    11d3 <main+0x93>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118b <main+0x4b>
jmp    11d8 <main+0x98>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11f7 <main+0xb7>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    -0x24(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1050 <copy@plt>
jmp    1156 <main+0x16>
cmpl   $0x0,-0x10(%rbp)
jle    121e <main+0xde>
mov    -0x10(%rbp),%esi
lea    -0x24(%rbp),%rcx
lea    0xdec(%rip),%rdi
mov    $0xa,%edx
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   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xc(%rsp),%rdi
mov    $0xa,%esi
call   1030 <get_line@plt>
test   %eax,%eax
jle    11e7 <main+0xa7>
mov    %eax,%ebx
lea    0x16(%rsp),%r14
lea    0xc(%rsp),%r15
mov    0x2e72(%rip),%rbp
xor    %r12d,%r12d
jmp    1193 <main+0x53>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0xa,%esi
call   1030 <get_line@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    11c9 <main+0x89>
lea    -0x1(%rbx),%eax
cmpb   $0xa,0xc(%rsp,%rax,1)
je     11b4 <main+0x74>
mov    %eax,%ebx
nop
xor    %eax,%eax
call   1060 <getchar@plt>
add    $0x1,%ebx
cmp    $0xa,%eax
je     11b4 <main+0x74>
cmp    0x0(%rbp),%eax
jne    11a0 <main+0x60>
cmp    %r12d,%ebx
jle    1180 <main+0x40>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <copy@plt>
mov    %ebx,%r12d
jmp    1180 <main+0x40>
test   %r12d,%r12d
jle    11e7 <main+0xa7>
lea    0xe2b(%rip),%rdi
lea    0x16(%rsp),%rcx
mov    %r12d,%esi
mov    $0xa,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [74 x i8] c"Longest line has %d characters (including \\n), first %d characters are %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x i8]
%6 = alloca [10 x i8]
store i32 0, i32* %1
store i32 0, i32* %4
br label %7
7: ; preds = %42, %0
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%9 = call i32 @get_line(i8* %8, i32 10)
store i32 %9, i32* %3
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %43
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]* %5, 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 %33
19: ; preds = %11
br label %20
20: ; preds = %29, %19
%21 = call i32 (...) @getchar()
store i32 %21, i32* %2
%22 = load i32, i32* @EOF
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %2
%26 = icmp ne i32 %25, 10
br label %27
27: ; preds = %24, %20
%28 = phi i1 [ false, %20 ], [ %26, %24 ]
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %20
32: ; preds = %27
br label %33
33: ; preds = %32, %11
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = icmp sgt i32 %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i32, i32* %3
store i32 %38, i32* %4
%39 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%41 = call i32 @copy(i8* %39, i8* %40)
br label %42
42: ; preds = %37, %33
br label %7
43: ; preds = %7
%44 = load i32, i32* %4
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = load i32, i32* %4
%48 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%49 = call i32 @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0), i32 %47, i32 10, i8* %48)
br label %50
50: ; preds = %46, %43
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [74 x i8] c"Longest line has %d characters (including \\n), first %d characters are %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 @get_line(i8* %3, i32 10)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %36
7: ; preds = %0, %28
%8 = phi i32 [ %30, %28 ], [ %5, %0 ]
%9 = phi i32 [ %29, %28 ], [ 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 %23, label %15
15: ; preds = %7, %15
%16 = phi i32 [ %22, %15 ], [ %8, %7 ]
%17 = call i32 (...) @getchar()
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
%20 = icmp ne i32 %17, 10
%21 = and i1 %20, %19
%22 = add nsw i32 %16, 1
br i1 %21, label %15, label %23
23: ; preds = %15, %7
%24 = phi i32 [ %8, %7 ], [ %16, %15 ]
%25 = icmp sgt i32 %24, %9
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @copy(i8* %4, i8* %3)
br label %28
28: ; preds = %26, %23
%29 = phi i32 [ %24, %26 ], [ %9, %23 ]
%30 = call i32 @get_line(i8* %3, i32 10)
%31 = icmp sgt i32 %30, 0
br i1 %31, label %7, label %32
32: ; preds = %28
%33 = icmp sgt i32 %29, 0
br i1 %33, label %34, label %36
34: ; preds = %32
%35 = call i32 @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0), i32 %29, i32 10, i8* %4)
br label %36
36: ; preds = %0, %34, %32
ret i32 0
}