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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void dump_byte_table(FILE *f, const char *cname, const uint8_t *tab, int len) {
  int i;
  fprintf(f, "static const uint8_t %s[%d] = {", cname, len);
  for (i = 0; i < len; i++) {
    if (i % 8 == 0)
      fprintf(f, "\n   ");
    fprintf(f, " 0x%02x,", tab[i]);
  }
  fprintf(f, "\n};\n\n");
}


x86 assembly (clang, -O0):
<dump_byte_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xec7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11a4 <dump_byte_table+0x94>
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1179 <dump_byte_table+0x69>
mov    -0x8(%rbp),%rdi
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1147 <dump_byte_table+0x37>
mov    -0x8(%rbp),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_byte_table>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xec3(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %ebp,%ebp
jle    1197 <dump_byte_table+0x77>
mov    %ebp,%r13d
lea    0xece(%rip),%r15
lea    0xecc(%rip),%r12
xor    %ebp,%ebp
jmp    117a <dump_byte_table+0x5a>
nopl   (%rax)
mov    (%r14,%rbp,4),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     1197 <dump_byte_table+0x77>
test   $0x7,%bpl
jne    1160 <dump_byte_table+0x40>
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
jmp    1160 <dump_byte_table+0x40>
lea    0xe90(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fwrite@plt>

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

LLVM IR (-O2):
@.str = [32 x i8] c"static const uint8_t %s[%d] = {\00"
@.str.1 = [5 x i8] c"\0A \00"
@.str.2 = [9 x i8] c" 0x%02x,\00"
@.str.3 = [6 x i8] c"\0A};\0A\0A\00"
define void @dump_byte_table(i32* nocapture %0, i8* %1, i32* nocapture %2, i32 %3) {
%5 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %3)
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %21
7: ; preds = %4
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %7, %15
%10 = phi i64 [ 0, %7 ], [ %19, %15 ]
%11 = and i64 %10, 7
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 4, i64 1, i32* %0)
br label %15
15: ; preds = %13, %9
%16 = getelementptr inbounds i32, i32* %2, i64 %10
%17 = load i32, i32* %16
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = add nuw nsw i64 %10, 1
%20 = icmp eq i64 %19, %8
br i1 %20, label %21, label %9
21: ; preds = %15, %4
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 5, i64 1, i32* %0)
ret void
}