#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;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_8bit_Ctbl(char *name, size_t sz, size_t by, const uint8_t *block) {
  int i;
  printf("const uint8_t %s[] = {\n\t", name);
  for (i = 0; i < sz - 1; i++) {
    if ((i + 1) % by != 0)
      printf("0x%02X, ", block[i]);
    else
      printf("0x%02X,\n\t", block[i]);
  }
  printf("0x%02X};\n", block[sz - 1]);
}


x86 assembly (clang, -O0):
<print_8bit_Ctbl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jae    11ba <print_8bit_Ctbl+0xaa>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
je     118e <print_8bit_Ctbl+0x7e>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a7 <print_8bit_Ctbl+0x97>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ac <print_8bit_Ctbl+0x9c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1141 <print_8bit_Ctbl+0x31>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_8bit_Ctbl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rsi
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x1,%r15
je     1199 <print_8bit_Ctbl+0x89>
mov    $0x1,%ebx
lea    0xedb(%rip),%r13
lea    0xecb(%rip),%rbp
jmp    1160 <print_8bit_Ctbl+0x50>
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
je     1199 <print_8bit_Ctbl+0x89>
mov    %rbx,%rax
or     %r12,%rax
shr    $0x20,%rax
je     1180 <print_8bit_Ctbl+0x70>
mov    %rbx,%rax
xor    %edx,%edx
div    %r12
jmp    1187 <print_8bit_Ctbl+0x77>
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %r12d
mov    -0x4(%r14,%rbx,4),%esi
mov    %r13,%rdi
test   %rdx,%rdx
je     1150 <print_8bit_Ctbl+0x40>
mov    %rbp,%rdi
jmp    1150 <print_8bit_Ctbl+0x40>
mov    -0x4(%r14,%r15,4),%esi
lea    0xe87(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

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

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