#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ copy(char *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int getline(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int len;
  int max;
  char line[1000];
  char longest[1000];
  FILE *in;
  if (argc != 2) {
    printf("Missing input files\n");
    return 1;
  }
  if ((in = fopen(argv[1], "r")) == NULL) {
    perror(argv[1]);
    return 1;
  }
  max = 0;
  while ((len = getline(in, line, 1000)) > 0) {
    if (len > max) {
      max = len;
      copy(longest, line);
    }
  }
  if (max > 0) {
    printf("%d:%s", max, longest);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     118d <main+0x3d>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1249 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe79(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x7f8(%rbp)
cmp    $0x0,%rax
jne    11cb <main+0x7b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1249 <main+0xf9>
movl   $0x0,-0x18(%rbp)
mov    -0x7f8(%rbp),%rdi
lea    -0x400(%rbp),%rsi
mov    $0x3e8,%edx
call   1070 <getline@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    1220 <main+0xd0>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    121b <main+0xcb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x7f0(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1040 <copy@plt>
jmp    11d2 <main+0x82>
cmpl   $0x0,-0x18(%rbp)
jle    1242 <main+0xf2>
mov    -0x18(%rbp),%esi
lea    -0x7f0(%rbp),%rdx
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x7e0,%rsp
cmp    $0x2,%edi
jne    11e9 <main+0x89>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe7e(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     122b <main+0xcb>
mov    %rax,%r12
lea    0x3f0(%rsp),%rsi
mov    %rax,%rdi
mov    $0x3e8,%edx
call   1080 <getline@plt>
test   %eax,%eax
jle    1217 <main+0xb7>
mov    %eax,%ebp
xor    %ebx,%ebx
mov    %rsp,%r14
lea    0x3f0(%rsp),%r15
jmp    11d6 <main+0x76>
nopl   (%rax)
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x3e8,%edx
call   1080 <getline@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    11fc <main+0x9c>
cmp    %ebx,%ebp
jle    11c0 <main+0x60>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <copy@plt>
mov    %ebp,%ebx
jmp    11c0 <main+0x60>
lea    0xe18(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
jmp    1219 <main+0xb9>
test   %ebx,%ebx
jle    1217 <main+0xb7>
lea    0xdfb(%rip),%rdi
xor    %ebp,%ebp
mov    %rsp,%rdx
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1219 <main+0xb9>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rbx),%rdi
call   1070 <perror@plt>
jmp    11f5 <main+0x95>

LLVM IR (-O0):
@.str = [21 x i8] c"Missing input files\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%d:%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1000 x i8]
%9 = alloca [1000 x i8]
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %50
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %10
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @perror(i8* %24)
store i32 1, i32* %3
br label %50
26: ; preds = %15
store i32 0, i32* %7
br label %27
27: ; preds = %41, %26
%28 = load i32*, i32** %10
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%30 = call i32 @getline(i32* %28, i8* %29, i32 1000)
store i32 %30, i32* %6
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %42
32: ; preds = %27
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = load i32, i32* %6
store i32 %37, i32* %7
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%39 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%40 = call i32 @copy(i8* %38, i8* %39)
br label %41
41: ; preds = %36, %32
br label %27
42: ; preds = %27
%43 = load i32, i32* %7
%44 = icmp sgt i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load i32, i32* %7
%47 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %46, i8* %47)
br label %49
49: ; preds = %45, %42
store i32 0, i32* %3
br label %50
50: ; preds = %49, %21, %13
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%d:%s\00"
@str = [20 x i8] c"Missing input files\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 2
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %35
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = call i32 @getline(i32* %13, i8* %5, i32 1000)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %21, label %35
18: ; preds = %10
%19 = load i8*, i8** %11
%20 = tail call i32 @perror(i8* %19)
br label %35
21: ; preds = %15, %27
%22 = phi i32 [ %29, %27 ], [ %16, %15 ]
%23 = phi i32 [ %28, %27 ], [ 0, %15 ]
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @copy(i8* %6, i8* %5)
br label %27
27: ; preds = %25, %21
%28 = phi i32 [ %22, %25 ], [ %23, %21 ]
%29 = call i32 @getline(i32* %13, i8* %5, i32 1000)
%30 = icmp sgt i32 %29, 0
br i1 %30, label %21, label %31
31: ; preds = %27
%32 = icmp sgt i32 %28, 0
br i1 %32, label %33, label %35
33: ; preds = %31
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %28, i8* %6)
br label %35
35: ; preds = %15, %31, %33, %18, %8
%36 = phi i32 [ 1, %8 ], [ 1, %18 ], [ 0, %33 ], [ 0, %31 ], [ 0, %15 ]
ret i32 %36
}