#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 */
unsigned int printf(char const *, ...);
void table_int(const char *prefix, const char *fmt, int *v, unsigned n) {
  unsigned i, width = 0;
  printf("static "
         "int"
         " %s[%u] = {\n",
         prefix, n);
  width += printf("   ");
  for (i = 0; i < n; i++) {
    if (width > 70) {
      width = printf("\n    ") - 1;
    } else {
      width += printf(" ");
    }
    width += printf(fmt, v[i]);
    if (i < n) {
      width += printf(",");
    }
  }
  printf("\n};\n");
}


x86 assembly (clang, -O0):
<table_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11ef <table_int+0xdf>
cmpl   $0x46,-0x24(%rbp)
jbe    118d <table_int+0x7d>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a1 <table_int+0x91>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1030 <printf@plt>
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11dc <table_int+0xcc>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11e1 <table_int+0xd1>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115e <table_int+0x4e>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<table_int>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rsi
lea    0xec2(%rip),%rdi
mov    %ecx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r15d,%r15d
je     11c3 <table_int+0xa3>
mov    %eax,%ebp
mov    %r15d,%r13d
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x47,%ebp
lea    0xea1(%rip),%rdi
lea    0xe96(%rip),%rax
cmovae %rax,%rdi
mov    $0xffffffff,%eax
cmovae %eax,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    (%r14,%r15,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %eax,%ebp
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    %ebx,%ebp
add    %eax,%ebp
add    $0x1,%r15
cmp    %r15,%r13
jne    1170 <table_int+0x50>
lea    0xe55(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"static int %s[%u] = {\0A\00"
@.str.1 = [4 x i8] c" \00"
@.str.2 = [6 x i8] c"\0A \00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c",\00"
@.str.5 = [5 x i8] c"\0A};\0A\00"
define void @table_int(i8* %0, i8* %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store i32 0, i32* %10
%11 = load i8*, i8** %5
%12 = load i32, i32* %8
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %11, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* %10
%16 = add i32 %15, %14
store i32 %16, i32* %10
store i32 0, i32* %9
br label %17
17: ; preds = %49, %4
%18 = load i32, i32* %9
%19 = load i32, i32* %8
%20 = icmp ult i32 %18, %19
br i1 %20, label %21, label %52
21: ; preds = %17
%22 = load i32, i32* %10
%23 = icmp ugt i32 %22, 70
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%26 = sub i32 %25, 1
store i32 %26, i32* %10
br label %31
27: ; preds = %21
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32, i32* %10
%30 = add i32 %29, %28
store i32 %30, i32* %10
br label %31
31: ; preds = %27, %24
%32 = load i8*, i8** %6
%33 = load i32*, i32** %7
%34 = load i32, i32* %9
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* %32, i32 %37)
%39 = load i32, i32* %10
%40 = add i32 %39, %38
store i32 %40, i32* %10
%41 = load i32, i32* %9
%42 = load i32, i32* %8
%43 = icmp ult i32 %41, %42
br i1 %43, label %44, label %48
44: ; preds = %31
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%46 = load i32, i32* %10
%47 = add i32 %46, %45
store i32 %47, i32* %10
br label %48
48: ; preds = %44, %31
br label %49
49: ; preds = %48
%50 = load i32, i32* %9
%51 = add i32 %50, 1
store i32 %51, i32* %9
br label %17
52: ; preds = %17
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"static int %s[%u] = {\0A\00"
@.str.1 = [4 x i8] c" \00"
@.str.2 = [6 x i8] c"\0A \00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c",\00"
@str = [4 x i8] c"\0A};\00"
define void @table_int(i8* %0, i8* nocapture %1, i32* nocapture %2, i32 %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %3)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32 %3, 0
br i1 %7, label %26, label %8
8: ; preds = %4
%9 = zext i32 %3 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %24, %10 ]
%12 = phi i32 [ %6, %8 ], [ %23, %10 ]
%13 = icmp ugt i32 %12, 70
%14 = select i1 %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%15 = select i1 %13, i32 -1, i32 %12
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %14)
%17 = add i32 %16, %15
%18 = getelementptr inbounds i32, i32* %2, i64 %11
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %1, i32 %19)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%22 = add i32 %20, %17
%23 = add i32 %22, %21
%24 = add nuw nsw i64 %11, 1
%25 = icmp eq i64 %24, %9
br i1 %25, label %26, label %10
26: ; preds = %10, %4
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
ret void
}