#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 fold_line(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int reset_vet(char *, int, int);
int /*<<< orphan*/ start_vet(char *, int);
int main(void) {
  int c, i, j;
  i = j = 0;
  char vet[10];
  while ((c = fold_line(vet, 10, i)) != EOF && c != '\n') {
    if (c > 0) {
      for (j = 0; j <= c; ++j)
        printf("%c", vet[j]);
      printf("\n");
      i = reset_vet(vet, 10, (c + 1));
    } else {
      printf("%s\n", vet);
      start_vet(vet, 10);
      i = 0;
    }
  }
  printf("%s", vet);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x1a(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    $0xa,%esi
call   1050 <fold_line@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
mov    0x2e6c(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x1b(%rbp)
je     1191 <main+0x51>
cmpl   $0xa,-0x8(%rbp)
setne  %al
mov    %al,-0x1b(%rbp)
mov    -0x1b(%rbp),%al
test   $0x1,%al
jne    11a1 <main+0x61>
jmp    1239 <main+0xf9>
cmpl   $0x0,-0x8(%rbp)
jle    120d <main+0xcd>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11e3 <main+0xa3>
movslq -0x10(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b2 <main+0x72>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1a(%rbp),%rdi
mov    -0x8(%rbp),%edx
add    $0x1,%edx
mov    $0xa,%esi
call   1030 <reset_vet@plt>
mov    %eax,-0xc(%rbp)
jmp    1234 <main+0xf4>
lea    -0x1a(%rbp),%rsi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1a(%rbp),%rdi
mov    $0xa,%esi
call   1060 <start_vet@plt>
movl   $0x0,-0xc(%rbp)
jmp    115d <main+0x1d>
lea    -0x1a(%rbp),%rsi
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe(%rsp),%rdi
mov    $0xa,%esi
xor    %edx,%edx
call   1070 <fold_line@plt>
cmp    $0xa,%eax
je     1225 <main+0xc5>
mov    %eax,%r12d
mov    0x2e59(%rip),%r15
cmp    (%r15),%eax
je     1225 <main+0xc5>
lea    0xe(%rsp),%r14
nopl   (%rax)
test   %r12d,%r12d
jle    11f0 <main+0x90>
add    $0x1,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl 0xe(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11b0 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0xa,%esi
mov    %r12d,%edx
call   1050 <reset_vet@plt>
mov    %eax,%edx
jmp    1207 <main+0xa7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1080 <start_vet@plt>
xor    %edx,%edx
mov    %r14,%rdi
mov    $0xa,%esi
call   1070 <fold_line@plt>
cmp    $0xa,%eax
je     1225 <main+0xc5>
mov    %eax,%r12d
cmp    (%r15),%eax
jne    11a0 <main+0x40>
lea    0xdd4(%rip),%rdi
lea    0xe(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str.3 = [3 x i8] c"%s\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 @fold_line(i8* %2, i32 10, i32 0)
%4 = load i32, i32* @EOF
%5 = icmp ne i32 %3, %4
%6 = icmp ne i32 %3, 10
%7 = and i1 %6, %5
br i1 %7, label %8, label %35
8: ; preds = %0, %28
%9 = phi i32 [ %30, %28 ], [ %3, %0 ]
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = add nuw i32 %9, 1
%13 = zext i32 %12 to i64
br label %14
14: ; preds = %11, %14
%15 = phi i64 [ 0, %11 ], [ %20, %14 ]
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = call i32 @putchar(i32 %18)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %13
br i1 %21, label %22, label %14
22: ; preds = %14
%23 = call i32 @putchar(i32 10)
%24 = call i32 @reset_vet(i8* %2, i32 10, i32 %12)
br label %28
25: ; preds = %8
%26 = call i32 @puts(i8* %2)
%27 = call i32 @start_vet(i8* %2, i32 10)
br label %28
28: ; preds = %25, %22
%29 = phi i32 [ %24, %22 ], [ 0, %25 ]
%30 = call i32 @fold_line(i8* %2, i32 10, i32 %29)
%31 = load i32, i32* @EOF
%32 = icmp ne i32 %30, %31
%33 = icmp ne i32 %30, 10
%34 = and i1 %33, %32
br i1 %34, label %8, label %35
35: ; preds = %28, %0
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
ret i32 0
}