#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*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ assert(void const *);
int /*<<< orphan*/ printf(char *, ...);
void cdump8(const char *name, const void *buf, size_t len) {
  assert(name);
  assert(buf);
  const uint8_t *data = buf;
  size_t i;
  if (!len) {
    return;
  }
  printf("uint8_t %s[%zu] = {\n\t0x%02x", name, len, *data++);
  for (i = 1; i < len; ++i) {
    printf((i % 12) ? ", " : ",\n\t");
    printf("0x%02x", *data++);
  }
  printf("\n};\n");
}


x86 assembly (clang, -O0):
<cdump8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115e <cdump8+0x3e>
jmp    1204 <cdump8+0xe4>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%ecx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11f6 <cdump8+0xd6>
mov    -0x28(%rbp),%rax
mov    $0xc,%ecx
xor    %edx,%edx
div    %rcx
lea    0xe6f(%rip),%rdi
lea    0xe65(%rip),%rax
cmp    $0x0,%rdx
cmovne %rax,%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    118d <cdump8+0x6d>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdump8>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <assert@plt>
mov    %r14,%rdi
call   1050 <assert@plt>
test   %r15,%r15
je     118d <cdump8+0x5d>
mov    (%r14),%ecx
lea    0xea0(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%r15
jne    119c <cdump8+0x6c>
lea    0xea9(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0xffffffffffffffff,%r15
mov    $0x1,%ebx
lea    0xe73(%rip),%rbp
lea    0xe62(%rip),%r12
xor    %r13d,%r13d
jmp    11e3 <cdump8+0xb3>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%r14,%r13,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
add    $0x1,%r13
cmp    %r13,%r15
je     1173 <cdump8+0x43>
mov    %rbx,%rax
movabs $0xaaaaaaaaaaaaaaab,%rcx
aa aa aa
mul    %rcx
shr    $0x3,%rdx
lea    (%rdx,%rdx,2),%rax
lea    -0x1(,%rax,4),%rax
ff
mov    %rbp,%rdi
cmp    %r13,%rax
je     11c0 <cdump8+0x90>
lea    0xe0a(%rip),%rdi
jmp    11c0 <cdump8+0x90>

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

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