#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int itoa(char *, int);
int /*<<< orphan*/ printf(char *, ...);
void bounded_lines(int run_count, char tag, FILE *new_file) {
  static FILE *file = NULL;
  static char a[20];
  static int line;
  if (new_file != NULL) {
    file = new_file;
    line = 0;
  } else if (file == NULL)
    return;
  int written = itoa(a, run_count);
  if (run_count == 1)
    a[0] = tag;
  else if (run_count > 1) {
    a[written] = tag;
    a[written + 1] = '\0';
    written++;
  } else
    return;
  if ((line += written) > 70) {
    printf("\n");
    line = 0;
  }
  printf("%s", a);
}


x86 assembly (clang, -O0):
<bounded_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    %rdx,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115a <bounded_lines+0x3a>
mov    -0x10(%rbp),%rax
mov    %rax,0x2ef5(%rip)
movl   $0x0,0x2f0f(%rip)
jmp    1172 <bounded_lines+0x52>
cmpq   $0x0,0x2ede(%rip)
jne    116d <bounded_lines+0x4d>
jmp    1228 <bounded_lines+0x108>
jmp    1172 <bounded_lines+0x52>
mov    -0x4(%rbp),%esi
lea    0x2ed4(%rip),%rdi
call   1040 <itoa@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    119c <bounded_lines+0x7c>
mov    -0x5(%rbp),%al
mov    %al,0x2eb9(%rip)
jmp    11e3 <bounded_lines+0xc3>
cmpl   $0x1,-0x4(%rbp)
jle    11d9 <bounded_lines+0xb9>
mov    -0x5(%rbp),%dl
movslq -0x14(%rbp),%rcx
lea    0x2e9c(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2e89(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11de <bounded_lines+0xbe>
jmp    1228 <bounded_lines+0x108>
jmp    11e3 <bounded_lines+0xc3>
mov    -0x14(%rbp),%eax
add    0x2e78(%rip),%eax
mov    %eax,0x2e72(%rip)
cmp    $0x46,%eax
jle    1213 <bounded_lines+0xf3>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,0x2e51(%rip)
lea    0xde8(%rip),%rdi
lea    0x2e2f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bounded_lines>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
test   %rdx,%rdx
je     1150 <bounded_lines+0x20>
mov    %rdx,0x2f0c(%rip)
movl   $0x0,0x2f26(%rip)
jmp    115a <bounded_lines+0x2a>
cmpq   $0x0,0x2ef8(%rip)
je     11c8 <bounded_lines+0x98>
lea    0x2eff(%rip),%r14
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <itoa@plt>
cmp    $0x1,%ebp
jne    1178 <bounded_lines+0x48>
mov    %bl,0x2eea(%rip)
jmp    118a <bounded_lines+0x5a>
jle    11c8 <bounded_lines+0x98>
cltq
mov    %bl,(%rax,%r14,1)
movb   $0x0,0x1(%rax,%r14,1)
add    $0x1,%rax
add    0x2ee4(%rip),%eax
mov    %eax,0x2ede(%rip)
cmp    $0x47,%eax
jl     11af <bounded_lines+0x7f>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,0x2ec5(%rip)
lea    0xe4a(%rip),%rdi
lea    0x2ea3(%rip),%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@bounded_lines.file = internal unnamed_addr global i32* null
@bounded_lines.a = internal global [20 x i8] zeroinitializer
@bounded_lines.line = internal unnamed_addr global i32 0
@.str.1 = [3 x i8] c"%s\00"
define void @bounded_lines(i32 %0, i8 signext %1, i32* %2) {
%4 = icmp eq i32* %2, null
br i1 %4, label %6, label %5
5: ; preds = %3
store i32* %2, i32** @bounded_lines.file
store i32 0, i32* @bounded_lines.line
br label %9
6: ; preds = %3
%7 = load i32*, i32** @bounded_lines.file
%8 = icmp eq i32* %7, null
br i1 %8, label %30, label %9
9: ; preds = %6, %5
%10 = tail call i32 @itoa(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @bounded_lines.a, i64 0, i64 0), i32 %0)
%11 = icmp eq i32 %0, 1
br i1 %11, label %12, label %13
12: ; preds = %9
store i8 %1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @bounded_lines.a, i64 0, i64 0)
br label %21
13: ; preds = %9
%14 = icmp sgt i32 %0, 1
br i1 %14, label %15, label %30
15: ; preds = %13
%16 = sext i32 %10 to i64
%17 = getelementptr inbounds [20 x i8], [20 x i8]* @bounded_lines.a, i64 0, i64 %16
store i8 %1, i8* %17
%18 = add nsw i32 %10, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [20 x i8], [20 x i8]* @bounded_lines.a, i64 0, i64 %19
store i8 0, i8* %20
br label %21
21: ; preds = %15, %12
%22 = phi i32 [ %10, %12 ], [ %18, %15 ]
%23 = load i32, i32* @bounded_lines.line
%24 = add nsw i32 %23, %22
store i32 %24, i32* @bounded_lines.line
%25 = icmp sgt i32 %24, 70
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = tail call i32 @putchar(i32 10)
store i32 0, i32* @bounded_lines.line
br label %28
28: ; preds = %26, %21
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @bounded_lines.a, i64 0, i64 0))
br label %30
30: ; preds = %28, %13, %6
ret void
}