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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
void process(FILE *fpout, const unsigned char *data, const size_t size,
             const size_t ucsize, const char *tag) {
  int cnt = 8;
  fprintf(fpout,
          "#include <stddef.h>\n"
          "const unsigned char c_%s[] =\n"
          "{"
          "",
          tag);
  for (size_t i = 0; i < size; i++) {
    if (cnt == 8) {
      fputs("\n  ", fpout);
      cnt = 0;
    }
    fprintf(fpout, "0x%02X , ", data[i]);
    cnt++;
  }
  fprintf(fpout, "\n};\n\nconst size_t c_%s_size = %lu;\n", tag,
          (unsigned long)size);
  if (size != ucsize) {
    fprintf(fpout, "const size_t c_%s_ucsize = %lu;\n", tag,
            (unsigned long)ucsize);
  }
}


x86 assembly (clang, -O0):
<process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x8,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11c8 <process+0xa8>
cmpl   $0x8,-0x2c(%rbp)
jne    1190 <process+0x70>
mov    -0x8(%rbp),%rsi
lea    0xeaf(%rip),%rdi
call   1030 <fputs@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1161 <process+0x41>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     120a <process+0xea>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x10(%rsp)
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0xebd(%rip),%rsi
mov    %r8,0x8(%rsp)
mov    %r8,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r12,%r12
je     11b1 <process+0x91>
mov    $0x8,%ebp
lea    0xed4(%rip),%r14
xor    %r15d,%r15d
jmp    118f <process+0x6f>
nopl   0x0(%rax,%rax,1)
movzbl 0x0(%r13,%r15,1),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%ebp
add    $0x1,%r15
cmp    %r15,%r12
je     11b1 <process+0x91>
cmp    $0x8,%ebp
jne    1170 <process+0x50>
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xe8e(%rip),%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
xor    %ebp,%ebp
jmp    1170 <process+0x50>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
mov    0x8(%rsp),%rbp
mov    %rbp,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x10(%rsp),%rcx
cmp    %rcx,%r12
jne    11e6 <process+0xc6>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"#include <stddef.h>\0Aconst unsigned char c_%s[] =\0A{\00"
@.str.1 = [4 x i8] c"\0A \00"
@.str.2 = [10 x i8] c"0x%02X , \00"
@.str.3 = [36 x i8] c"\0A};\0A\0Aconst size_t c_%s_size = %lu;\0A\00"
@.str.4 = [33 x i8] c"const size_t c_%s_ucsize = %lu;\0A\00"
define void @process(i32* %0, i8* %1, i64 %2, i64 %3, i8* %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i64
store i32* %0, i32** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i8* %4, i8** %10
store i32 8, i32* %11
%13 = load i32*, i32** %6
%14 = load i8*, i8** %10
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %14)
store i64 0, i64* %12
br label %16
16: ; preds = %36, %5
%17 = load i64, i64* %12
%18 = load i64, i64* %8
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %39
20: ; preds = %16
%21 = load i32, i32* %11
%22 = icmp eq i32 %21, 8
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32*, i32** %6
%25 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %24)
store i32 0, i32* %11
br label %26
26: ; preds = %23, %20
%27 = load i32*, i32** %6
%28 = load i8*, i8** %7
%29 = load i64, i64* %12
%30 = getelementptr inbounds i8, i8* %28, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %11
%35 = add nsw i32 %34, 1
store i32 %35, i32* %11
br label %36
36: ; preds = %26
%37 = load i64, i64* %12
%38 = add i64 %37, 1
store i64 %38, i64* %12
br label %16
39: ; preds = %16
%40 = load i32*, i32** %6
%41 = load i8*, i8** %10
%42 = load i64, i64* %8
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %41, i64 %42)
%44 = load i64, i64* %8
%45 = load i64, i64* %9
%46 = icmp ne i64 %44, %45
br i1 %46, label %47, label %52
47: ; preds = %39
%48 = load i32*, i32** %6
%49 = load i8*, i8** %10
%50 = load i64, i64* %9
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %49, i64 %50)
br label %52
52: ; preds = %47, %39
ret void
}

LLVM IR (-O2):
@.str = [51 x i8] c"#include <stddef.h>\0Aconst unsigned char c_%s[] =\0A{\00"
@.str.1 = [4 x i8] c"\0A \00"
@.str.2 = [10 x i8] c"0x%02X , \00"
@.str.3 = [36 x i8] c"\0A};\0A\0Aconst size_t c_%s_size = %lu;\0A\00"
@.str.4 = [33 x i8] c"const size_t c_%s_ucsize = %lu;\0A\00"
define void @process(i32* nocapture %0, i8* nocapture %1, i64 %2, i64 %3, i8* %4) {
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %4)
%7 = icmp eq i64 %2, 0
br i1 %7, label %8, label %11
8: ; preds = %17, %5
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %4, i64 %2)
%10 = icmp eq i64 %2, %3
br i1 %10, label %28, label %26
11: ; preds = %5, %17
%12 = phi i64 [ %24, %17 ], [ 0, %5 ]
%13 = phi i32 [ %23, %17 ], [ 8, %5 ]
%14 = icmp eq i32 %13, 8
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 3, i64 1, i32* %0)
br label %17
17: ; preds = %15, %11
%18 = phi i32 [ 0, %15 ], [ %13, %11 ]
%19 = getelementptr inbounds i8, i8* %1, i64 %12
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = add nsw i32 %18, 1
%24 = add nuw i64 %12, 1
%25 = icmp eq i64 %24, %2
br i1 %25, label %8, label %11
26: ; preds = %8
%27 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %4, i64 %3)
br label %28
28: ; preds = %26, %8
ret void
}