#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 getchar();
int /*<<< orphan*/ printf(char *, char *);
int main(void) {
  char longest[1000];
  char line[1000];
  int c;
  int x = 0;
  int l = 0;
  while ((c = getchar()) != EOF) {
    line[x++] = c;
    if (c == '\n') {
      if (x > l) {
        line[x] = '\0';
        l = x;
        x = 0;
        while (longest[x] = line[x])
          x++;
        printf("\n\tLongest line now is:\n\t %s\n", line);
        x = 0;
      } else {
        printf("\n\tLongest line still is:\n\t %s\n", longest);
        x = 0;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x7e8(%rbp)
movl   $0x0,-0x7ec(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x7e4(%rbp)
mov    0x2e8e(%rip),%rcx
cmp    (%rcx),%eax
je     1249 <main+0x129>
mov    -0x7e4(%rbp),%eax
mov    %al,%cl
mov    -0x7e8(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x7e8(%rbp)
cltq
mov    %cl,-0x7e0(%rbp,%rax,1)
cmpl   $0xa,-0x7e4(%rbp)
jne    1244 <main+0x124>
mov    -0x7e8(%rbp),%eax
cmp    -0x7ec(%rbp),%eax
jle    1222 <main+0x102>
movslq -0x7e8(%rbp),%rax
movb   $0x0,-0x7e0(%rbp,%rax,1)
mov    -0x7e8(%rbp),%eax
mov    %eax,-0x7ec(%rbp)
movl   $0x0,-0x7e8(%rbp)
movslq -0x7e8(%rbp),%rax
mov    -0x7e0(%rbp,%rax,1),%al
movslq -0x7e8(%rbp),%rcx
mov    %al,-0x3f0(%rbp,%rcx,1)
cmp    $0x0,%al
je     1200 <main+0xe0>
mov    -0x7e8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e8(%rbp)
jmp    11c8 <main+0xa8>
lea    -0x7e0(%rbp),%rsi
lea    0xdf2(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x7e8(%rbp)
jmp    123f <main+0x11f>
lea    -0x3f0(%rbp),%rsi
lea    0xded(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x7e8(%rbp)
jmp    1244 <main+0x124>
jmp    1146 <main+0x26>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7d8,%rsp
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2ea9(%rip),%rbx
cmp    (%rbx),%eax
jne    1157 <main+0x37>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xea2(%rip),%r12
mov    %rsp,%r13
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    1184 <main+0x64>
nopl   0x0(%rax)
mov    %ebp,%r14d
mov    %r15d,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebp,%r15d
cmp    (%rbx),%eax
je     1143 <main+0x23>
movslq %r14d,%rbp
mov    %al,(%rsp,%rbp,1)
add    $0x1,%rbp
cmp    $0xa,%eax
jne    1170 <main+0x50>
cmp    %r15d,%r14d
jge    11c0 <main+0xa0>
lea    0xe7e(%rip),%rdi
lea    0x3f0(%rsp),%rsi
call   1030 <printf@plt>
xor    %r14d,%r14d
jmp    1173 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rsp,%rbp,1)
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movzbl (%rsp,%rax,1),%ecx
mov    %cl,0x3f0(%rsp,%rax,1)
add    $0x1,%rax
test   %cl,%cl
jne    11d0 <main+0xb0>
mov    %r12,%rdi
mov    %r13,%rsi
call   1030 <printf@plt>
xor    %r14d,%r14d
jmp    1176 <main+0x56>

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [29 x i8] c"\0A\09Longest line now is:\0A\09 %s\0A\00"
@.str.1 = [31 x i8] c"\0A\09Longest line still is:\0A\09 %s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = call i32 (...) @getchar()
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %39, label %8
8: ; preds = %0, %33
%9 = phi i32 [ %36, %33 ], [ %5, %0 ]
%10 = phi i32 [ %35, %33 ], [ 0, %0 ]
%11 = phi i32 [ %34, %33 ], [ 0, %0 ]
%12 = trunc i32 %9 to i8
%13 = add nsw i32 %11, 1
%14 = sext i32 %11 to i64
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %14
store i8 %12, i8* %15
%16 = icmp eq i32 %9, 10
br i1 %16, label %17, label %33
17: ; preds = %8
%18 = icmp slt i32 %11, %10
br i1 %18, label %31, label %19
19: ; preds = %17
%20 = sext i32 %13 to i64
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %20
store i8 0, i8* %21
br label %22
22: ; preds = %22, %19
%23 = phi i64 [ %28, %22 ], [ 0, %19 ]
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %23
store i8 %25, i8* %26
%27 = icmp eq i8 %25, 0
%28 = add nuw i64 %23, 1
br i1 %27, label %29, label %22
29: ; preds = %22
%30 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %33
31: ; preds = %17
%32 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %33
33: ; preds = %29, %31, %8
%34 = phi i32 [ 0, %29 ], [ 0, %31 ], [ %13, %8 ]
%35 = phi i32 [ %13, %29 ], [ %10, %31 ], [ %10, %8 ]
%36 = call i32 (...) @getchar()
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %8
39: ; preds = %33, %0
ret i32 0
}