#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 getline(char *, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int len, max;
  int total;
  int text;
  char line[100];
  len = total = max = text = 0;
  while ((len = getline(line, 100)) > 0) {
    total = total + len;
    text = text + len;
    if (len + 1 < 100 || line[len - 1] == '\n') {
      if (total > max)
        max = total;
      total = 0;
    }
  }
  printf("longest: %d\n", max);
  printf("total: %d\n", text);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x80(%rbp),%rdi
mov    $0x64,%esi
call   1040 <getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11bd <main+0x9d>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cmp    $0x64,%eax
jl     119f <main+0x7f>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    11b8 <main+0x98>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11b1 <main+0x91>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    114e <main+0x2e>
mov    -0xc(%rbp),%esi
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rsp,%rdi
mov    $0x64,%esi
call   1040 <getline@plt>
test   %eax,%eax
jle    117e <main+0x5e>
xor    %ebx,%ebx
mov    %rsp,%r14
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    116c <main+0x4c>
nopw   0x0(%rax,%rax,1)
cmp    %r15d,%ebp
cmovg  %ebp,%r15d
xor    %ebp,%ebp
add    %eax,%ebx
mov    %r14,%rdi
mov    $0x64,%esi
call   1040 <getline@plt>
test   %eax,%eax
jle    1183 <main+0x63>
add    %eax,%ebp
cmp    $0x63,%eax
jb     1150 <main+0x30>
lea    -0x1(%rax),%ecx
cmpb   $0xa,(%rsp,%rcx,1)
je     1150 <main+0x30>
jmp    1159 <main+0x39>
xor    %r15d,%r15d
xor    %ebx,%ebx
lea    0xe76(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
lea    0xe74(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"longest: %d\0A\00"
@.str.1 = [11 x i8] c"total: %d\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @getline(i8* %2, i32 100)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %27
5: ; preds = %0, %22
%6 = phi i32 [ %25, %22 ], [ %3, %0 ]
%7 = phi i32 [ %11, %22 ], [ 0, %0 ]
%8 = phi i32 [ %24, %22 ], [ 0, %0 ]
%9 = phi i32 [ %23, %22 ], [ 0, %0 ]
%10 = add nsw i32 %6, %8
%11 = add nsw i32 %6, %7
%12 = icmp ult i32 %6, 99
br i1 %12, label %19, label %13
13: ; preds = %5
%14 = add nsw i32 %6, -1
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 10
br i1 %18, label %19, label %22
19: ; preds = %13, %5
%20 = icmp sgt i32 %10, %9
%21 = select i1 %20, i32 %10, i32 %9
br label %22
22: ; preds = %19, %13
%23 = phi i32 [ %21, %19 ], [ %9, %13 ]
%24 = phi i32 [ 0, %19 ], [ %10, %13 ]
%25 = call i32 @getline(i8* %2, i32 100)
%26 = icmp sgt i32 %25, 0
br i1 %26, label %5, label %27
27: ; preds = %22, %0
%28 = phi i32 [ 0, %0 ], [ %23, %22 ]
%29 = phi i32 [ 0, %0 ], [ %11, %22 ]
%30 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %28)
%31 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %29)
ret i32 0
}