#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*/ printf(char *, ...);
void cdump8(const char *name, const void *buf, size_t len) {
  const uint8_t *data = buf;
  size_t i;
  if (!len) {
    return;
  }
  printf("uint8_t %s[%zd] = {\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    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    113c <cdump8+0x2c>
jmp    11e2 <cdump8+0xd2>
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    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11d4 <cdump8+0xc4>
mov    -0x28(%rbp),%rax
mov    $0xc,%ecx
xor    %edx,%edx
div    %rcx
lea    0xe91(%rip),%rdi
lea    0xe87(%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    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    116b <cdump8+0x5b>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdump8>:
test   %rdx,%rdx
je     116a <cdump8+0x4a>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rsi
mov    (%r14),%ecx
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%r15
jne    116b <cdump8+0x4b>
lea    0xecc(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
ret
add    $0xffffffffffffffff,%r15
mov    $0x1,%ebx
lea    0xea4(%rip),%rbp
lea    0xe93(%rip),%r12
xor    %r13d,%r13d
jmp    11b3 <cdump8+0x93>
nopw   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     1150 <cdump8+0x30>
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     1190 <cdump8+0x70>
lea    0xe3a(%rip),%rdi
jmp    1190 <cdump8+0x70>

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

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