#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 get_line(char *, int);
int /*<<< orphan*/ printf(char *, int, char *);
int main(void) {
  int len, max, prev_len;
  char s[50], l[50], t[50];
  max = prev_len = 0;
  while ((len = get_line(s, 50)) > 0) {
    if (prev_len + len > max) {
      max = prev_len + len;
      if (prev_len)
        copy(l, t);
      else
        copy(l, s);
    }
    if (s[len - 1] != '\n') {
      if (prev_len == 0)
        copy(t, s);
      prev_len += len;
    } else
      prev_len = 0;
  }
  printf("Longest: %d, Line:%s\n", max, l);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x32,%esi
call   1030 <get_line@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1203 <main+0xd3>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11b9 <main+0x89>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11a4 <main+0x74>
lea    -0x90(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
call   1050 <copy@plt>
jmp    11b4 <main+0x84>
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <copy@plt>
jmp    11b9 <main+0x89>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     11f7 <main+0xc7>
cmpl   $0x0,-0x10(%rbp)
jne    11e9 <main+0xb9>
lea    -0xd0(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <copy@plt>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11fe <main+0xce>
movl   $0x0,-0x10(%rbp)
jmp    1150 <main+0x20>
mov    -0xc(%rbp),%esi
lea    -0x90(%rbp),%rdx
lea    0xdec(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rsp,%rdi
mov    $0x32,%esi
call   1030 <get_line@plt>
test   %eax,%eax
jle    11d7 <main+0xa7>
mov    %eax,%ebx
xor    %r14d,%r14d
mov    %rsp,%r12
lea    0x80(%rsp),%r15
xor    %r13d,%r13d
jmp    1188 <main+0x58>
mov    %ebp,%r13d
xchg   %ax,%ax
xor    %ebp,%ebp
mov    %r12,%rdi
mov    $0x32,%esi
call   1030 <get_line@plt>
mov    %eax,%ebx
mov    %ebp,%r14d
test   %eax,%eax
jle    11da <main+0xaa>
lea    (%rbx,%r14,1),%ebp
cmp    %r13d,%ebp
jle    11a6 <main+0x76>
lea    0x40(%rsp),%rdi
test   %r14d,%r14d
je     11b6 <main+0x86>
mov    %r15,%rsi
call   1050 <copy@plt>
mov    %ebp,%r13d
add    $0xffffffff,%ebx
cmpb   $0xa,(%rsp,%rbx,1)
je     1170 <main+0x40>
test   %r14d,%r14d
jne    1172 <main+0x42>
jmp    11ca <main+0x9a>
mov    %r12,%rsi
call   1050 <copy@plt>
add    $0xffffffff,%ebx
cmpb   $0xa,(%rsp,%rbx,1)
mov    %ebp,%r13d
je     116b <main+0x3b>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <copy@plt>
jmp    1172 <main+0x42>
xor    %r13d,%r13d
lea    0xe1f(%rip),%rdi
lea    0x40(%rsp),%rdx
mov    %r13d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [22 x i8] c"Longest: %d, Line:%s\0A\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%7 = call i32 @get_line(i8* %4, i32 50)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %43
9: ; preds = %0, %38
%10 = phi i32 [ %41, %38 ], [ %7, %0 ]
%11 = phi i32 [ %40, %38 ], [ 0, %0 ]
%12 = phi i32 [ %39, %38 ], [ 0, %0 ]
%13 = add nsw i32 %10, %11
%14 = icmp sgt i32 %13, %12
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = icmp eq i32 %11, 0
br i1 %16, label %26, label %17
17: ; preds = %15
%18 = call i32 @copy(i8* %5, i8* %6)
br label %19
19: ; preds = %17, %9
%20 = phi i32 [ %13, %17 ], [ %12, %9 ]
%21 = add nsw i32 %10, -1
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 10
br i1 %25, label %38, label %33
26: ; preds = %15
%27 = call i32 @copy(i8* %5, i8* %4)
%28 = add nsw i32 %10, -1
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 10
br i1 %32, label %38, label %35
33: ; preds = %19
%34 = icmp eq i32 %11, 0
br i1 %34, label %35, label %38
35: ; preds = %26, %33
%36 = phi i32 [ %20, %33 ], [ %13, %26 ]
%37 = call i32 @copy(i8* %6, i8* %4)
br label %38
38: ; preds = %26, %19, %33, %35
%39 = phi i32 [ %36, %35 ], [ %20, %33 ], [ %20, %19 ], [ %13, %26 ]
%40 = phi i32 [ %13, %35 ], [ %13, %33 ], [ 0, %19 ], [ 0, %26 ]
%41 = call i32 @get_line(i8* %4, i32 50)
%42 = icmp sgt i32 %41, 0
br i1 %42, label %9, label %43
43: ; preds = %38, %0
%44 = phi i32 [ 0, %0 ], [ %39, %38 ]
%45 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %44, i8* %5)
ret i32 0
}