#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 *, char *, ...);
main() {
  int len, max;
  char line[10];
  char longest[10];
  max = 0;
  while ((len = getLine(line, 10)) > 0) {
    if (len == 10 - 1) {
      max = max + len;
      printf("%s", line);
    } else {
      printf("%s%d\n", line, max + len);
      max = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x16(%rbp),%rdi
mov    $0xa,%esi
call   1040 <getLine@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    119e <main+0x7e>
cmpl   $0x9,-0x8(%rbp)
jne    117a <main+0x5a>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x16(%rbp),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1199 <main+0x79>
lea    -0x16(%rbp),%rsi
mov    -0xc(%rbp),%edx
add    -0x8(%rbp),%edx
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe(%rsp),%rdi
mov    $0xa,%esi
call   1040 <getLine@plt>
test   %eax,%eax
jle    119b <main+0x7b>
lea    0xebc(%rip),%r14
lea    0xe(%rsp),%rbx
lea    0xeb3(%rip),%r15
xor    %ebp,%ebp
jmp    1184 <main+0x64>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %ebp,%eax
xor    %ebp,%ebp
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <getLine@plt>
test   %eax,%eax
jle    119b <main+0x7b>
cmp    $0x9,%eax
jne    1160 <main+0x40>
add    $0x9,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1173 <main+0x53>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c"%s%d\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @getLine(i8* %2, i32 10)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %19
5: ; preds = %0, %15
%6 = phi i32 [ %17, %15 ], [ %3, %0 ]
%7 = phi i32 [ %16, %15 ], [ 0, %0 ]
%8 = icmp eq i32 %6, 9
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = add nsw i32 %7, 9
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %15
12: ; preds = %5
%13 = add nsw i32 %6, %7
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 %13)
br label %15
15: ; preds = %12, %9
%16 = phi i32 [ %10, %9 ], [ 0, %12 ]
%17 = call i32 @getLine(i8* %2, i32 10)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %5, label %19
19: ; preds = %15, %0
ret i32 0
}