#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 main(void) {
  int cur_length;
  int total_length;
  char cur_line[100];
  total_length = 0;
  while ((cur_length = getline(cur_line, 100)) != 0) {
    total_length = total_length + cur_length;
    if (total_length > 4) {
      printf("%s", cur_line);
    }
    if (cur_length < 100) {
      printf("\n");
      printf("line length: %d\n", total_length);
      total_length = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
call   1040 <getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     11aa <main+0x8a>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jle    1175 <main+0x55>
lea    -0x70(%rbp),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x64,-0x8(%rbp)
jge    11a5 <main+0x85>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %rsp,%rdi
mov    $0x64,%esi
call   1050 <getline@plt>
test   %eax,%eax
je     11b6 <main+0x86>
mov    %eax,%ebx
lea    0xeaa(%rip),%r14
mov    %rsp,%r12
lea    0xea3(%rip),%r15
xor    %ebp,%ebp
jmp    1183 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    $0x64,%esi
call   1050 <getline@plt>
mov    %eax,%ebx
test   %eax,%eax
je     11b6 <main+0x86>
add    %ebx,%ebp
cmp    $0x5,%ebp
jl     1197 <main+0x67>
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x63,%ebx
jg     1170 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebp,%ebp
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.2 = [17 x i8] c"line length: %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 eq i32 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %0, %17
%6 = phi i32 [ %19, %17 ], [ %3, %0 ]
%7 = phi i32 [ %18, %17 ], [ 0, %0 ]
%8 = add nsw i32 %6, %7
%9 = icmp sgt i32 %8, 4
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %12
12: ; preds = %10, %5
%13 = icmp slt i32 %6, 100
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = call i32 @putchar(i32 10)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %8)
br label %17
17: ; preds = %14, %12
%18 = phi i32 [ 0, %14 ], [ %8, %12 ]
%19 = call i32 @getline(i8* %2, i32 100)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %5
21: ; preds = %17, %0
ret i32 0
}