#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 /*<<< orphan*/ printf(char *, ...);
void print_tab(char *name, int max, int (*fun)(int)) {
  int i;
  printf("\n");
  printf("static const unsigned short %s[] = {\n", name);
  for (i = 0; i < max; i++) {
    if (i == 0) {
      printf("\t");
    } else if (i % 12 == 0) {
      printf(",\n\t");
    } else {
      printf(", ");
    }
    printf("%3d", fun(i));
  }
  printf("\n};\n");
}


x86 assembly (clang, -O0):
<print_tab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xf0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d4 <print_tab+0xc4>
cmpl   $0x0,-0x1c(%rbp)
jne    1173 <print_tab+0x63>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ad <print_tab+0x9d>
mov    -0x1c(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119a <print_tab+0x8a>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a8 <print_tab+0x98>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ad <print_tab+0x9d>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%edi
call   *%rax
mov    %eax,%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <print_tab+0x3a>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_tab>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xeac(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jle    1186 <print_tab+0x56>
mov    $0x9,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   *%r14
lea    0xeb5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x1,%ebp
jne    11a0 <print_tab+0x70>
lea    0xea4(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
mov    $0x1,%ebx
mov    $0xaaaaaaab,%r12d
lea    0xe74(%rip),%r13
lea    0xe74(%rip),%r15
jmp    11df <print_tab+0xaf>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   *%r14
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
je     1186 <print_tab+0x56>
mov    %ebx,%eax
imul   %r12,%rax
shr    $0x23,%rax
shl    $0x2,%eax
lea    (%rax,%rax,2),%eax
mov    %r13,%rdi
cmp    %eax,%ebx
je     11c0 <print_tab+0x90>
lea    0xe2d(%rip),%rdi
jmp    11c0 <print_tab+0x90>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [38 x i8] c"static const unsigned short %s[] = {\0A\00"
@.str.2 = [2 x i8] c"\09\00"
@.str.3 = [4 x i8] c",\0A\09\00"
@.str.4 = [3 x i8] c", \00"
@.str.5 = [4 x i8] c"%3d\00"
@.str.6 = [5 x i8] c"\0A};\0A\00"
define void @print_tab(i8* %0, i32 %1, i32 (i32)* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32 (i32)*
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 (i32)* %2, i32 (i32)** %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %9)
store i32 0, i32* %7
br label %11
11: ; preds = %34, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %37
15: ; preds = %11
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %29
20: ; preds = %15
%21 = load i32, i32* %7
%22 = srem i32 %21, 12
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %28
26: ; preds = %20
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %26, %24
br label %29
29: ; preds = %28, %18
%30 = load i32 (i32)*, i32 (i32)** %6
%31 = load i32, i32* %7
%32 = call i32 %30(i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %29
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %11
37: ; preds = %11
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [38 x i8] c"static const unsigned short %s[] = {\0A\00"
@.str.3 = [4 x i8] c",\0A\09\00"
@.str.4 = [3 x i8] c", \00"
@.str.5 = [4 x i8] c"%3d\00"
@str = [4 x i8] c"\0A};\00"
define void @print_tab(i8* %0, i32 %1, i32 (i32)* nocapture %2) {
%4 = tail call i32 @putchar(i32 10)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %22
7: ; preds = %3
%8 = tail call i32 @putchar(i32 9)
%9 = tail call i32 %2(i32 0)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %9)
%11 = icmp eq i32 %1, 1
br i1 %11, label %22, label %12
12: ; preds = %7, %12
%13 = phi i32 [ %20, %12 ], [ 1, %7 ]
%14 = urem i32 %13, 12
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %16)
%18 = tail call i32 %2(i32 %13)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i32 %13, 1
%21 = icmp eq i32 %20, %1
br i1 %21, label %22, label %12
22: ; preds = %12, %7, %3
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
ret void
}