#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*/ bin2c_table(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
void bin2c(char *name, int size, FILE *in, FILE *out, char *inname) {
  fprintf(out, "/* generated by bin2c from %s */\n\n", inname);
  fprintf(out, "char %s[%d] = {\n", name, size);
  bin2c_table(size, in, out);
  fputs("};\n", out);
}


x86 assembly (clang, -O0):
<bin2c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xeb0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <bin2c_table@plt>
mov    -0x20(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1030 <fputs@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bin2c>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r15
lea    0xeb7(%rip),%rsi
mov    %rcx,%rdi
mov    %r8,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xec6(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <bin2c_table@plt>
lea    0xeb4(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"/* generated by bin2c from %s */\0A\0A\00"
@.str.1 = [17 x i8] c"char %s[%d] = {\0A\00"
@.str.2 = [4 x i8] c"};\0A\00"
define void @bin2c(i8* %0, i32 %1, i32* %2, i32* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i8* %4, i8** %10
%11 = load i32*, i32** %9
%12 = load i8*, i8** %10
%13 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32*, i32** %9
%15 = load i8*, i8** %6
%16 = load i32, i32* %7
%17 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %16)
%18 = load i32, i32* %7
%19 = load i32*, i32** %8
%20 = load i32*, i32** %9
%21 = call i32 @bin2c_table(i32 %18, i32* %19, i32* %20)
%22 = load i32*, i32** %9
%23 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %22)
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"/* generated by bin2c from %s */\0A\0A\00"
@.str.1 = [17 x i8] c"char %s[%d] = {\0A\00"
@.str.2 = [4 x i8] c"};\0A\00"
define void @bin2c(i8* %0, i32 %1, i32* %2, i32* %3, i8* %4) {
%6 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %4)
%7 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %1)
%8 = tail call i32 @bin2c_table(i32 %1, i32* %2, i32* %3)
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 3, i64 1, i32* %3)
ret void
}