#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 *, int);
int main(void) {
  int ret = 0;
  int crLength = 0, maxSoFar = 0;
  char crLine[3];
  char longestLine[3];
  while ((crLength = getline(crLine, 3)) > 0)
    if (crLength > maxSoFar) {
      maxSoFar = crLength;
      copy(crLine, longestLine);
    }
  if (maxSoFar > 0)
    printf("The longesc line '%s[...]' has %d chars", longestLine, maxSoFar);
  return ret;
}


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)
movl   $0x0,-0x10(%rbp)
lea    -0x13(%rbp),%rdi
mov    $0x3,%esi
call   1050 <getline@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    1192 <main+0x62>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    118d <main+0x5d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    -0x13(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1040 <copy@plt>
jmp    1154 <main+0x24>
cmpl   $0x0,-0x10(%rbp)
jle    11af <main+0x7f>
lea    -0x16(%rbp),%rsi
mov    -0x10(%rbp),%edx
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0x5(%rsp),%rdi
mov    $0x3,%esi
call   1050 <getline@plt>
test   %eax,%eax
jle    119d <main+0x6d>
mov    %eax,%ebp
xor    %ebx,%ebx
lea    0x5(%rsp),%r14
lea    0x2(%rsp),%r15
jmp    1173 <main+0x43>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x3,%esi
call   1050 <getline@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1186 <main+0x56>
cmp    %ebx,%ebp
jle    1160 <main+0x30>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <copy@plt>
mov    %ebp,%ebx
jmp    1160 <main+0x30>
test   %ebx,%ebx
jle    119d <main+0x6d>
lea    0xe6f(%rip),%rdi
lea    0x2(%rsp),%rsi
mov    %ebx,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [40 x i8] c"The longesc line '%s[...]' has %d chars\00"
define i32 @main() {
%1 = alloca [3 x i8]
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%5 = call i32 @getline(i8* %3, i32 3)
%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* %3, i8* %4)
br label %13
13: ; preds = %11, %7
%14 = phi i32 [ %8, %11 ], [ %9, %7 ]
%15 = call i32 @getline(i8* %3, i32 3)
%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 ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %14)
br label %21
21: ; preds = %0, %19, %17
ret i32 0
}