#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*/ decl(int /*<<< orphan*/ *, int /*<<< orphan*/ *, char *,
                        char *, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ outS(unsigned char *, int /*<<< orphan*/, int,
                        int /*<<< orphan*/ *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void outBitmap(unsigned char *bitmap, int packed, int w, int h, int size,
               FILE *fs, FILE *fh, char *id, int global) {
  char temp[2048];
  strcpy(temp, id);
  strcat(temp, "_image");
  decl(fs, fh, 0, temp, 2, 0);
  outS(bitmap, 0, size, fs, 1);
  fprintf(fs, "\n");
  decl(fs, fh, "Bitmap", id, 2, global);
  fprintf(fs, "    dc.w    %d\n", packed);
  fprintf(fs, "    dc.w    %d, %d\n", w, h);
  fprintf(fs, "    dc.l    %s_palette\n", id);
  fprintf(fs, "    dc.l    %s\n", temp);
  fprintf(fs, "\n");
}


x86 assembly (clang, -O0):
<outBitmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
lea    -0x820(%rbp),%rdi
mov    0x18(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x820(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    0x10(%rbp),%rsi
lea    -0x820(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%edx
mov    $0x2,%r8d
xor    %r9d,%r9d
call   1040 <decl@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%rcx
xor    %esi,%esi
mov    $0x1,%r8d
call   1070 <outS@plt>
mov    -0x20(%rbp),%rdi
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    0x10(%rbp),%rsi
mov    0x18(%rbp),%rcx
mov    0x20(%rbp),%r9d
lea    0xe07(%rip),%rdx
mov    $0x2,%r8d
call   1040 <decl@plt>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xded(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    0x18(%rbp),%rdx
lea    0xdeb(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x820(%rbp),%rdx
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdaa(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<outBitmap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
mov    %r9,%rbx
mov    %r8d,%r12d
mov    %ecx,0xc(%rsp)
mov    %edx,0x8(%rsp)
mov    %esi,%ebp
mov    %rdi,%r13
mov    0x850(%rsp),%r15
mov    0x858(%rsp),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xe58(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %edx,%edx
mov    %r14,%rcx
mov    $0x2,%r8d
xor    %r9d,%r9d
call   1040 <decl@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    %r12d,%edx
mov    %rbx,%rcx
mov    $0x1,%r8d
call   1080 <outS@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
lea    0xe14(%rip),%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    0x858(%rsp),%rcx
mov    $0x2,%r8d
mov    0x860(%rsp),%r9d
call   1040 <decl@plt>
lea    0xdf3(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xdf0(%rip),%rsi
mov    %rbx,%rdi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xdeb(%rip),%rsi
mov    %rbx,%rdi
mov    0x858(%rsp),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xdea(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"_image\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [7 x i8] c"Bitmap\00"
@.str.3 = [16 x i8] c" dc.w %d\0A\00"
@.str.4 = [20 x i8] c" dc.w %d, %d\0A\00"
@.str.5 = [24 x i8] c" dc.l %s_palette\0A\00"
@.str.6 = [16 x i8] c" dc.l %s\0A\00"
define void @outBitmap(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5, i32* %6, i8* %7, i32 %8) {
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i8*
%18 = alloca i32
%19 = alloca [2048 x i8]
store i8* %0, i8** %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32* %5, i32** %15
store i32* %6, i32** %16
store i8* %7, i8** %17
store i32 %8, i32* %18
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %19, i64 0, i64 0
%21 = load i8*, i8** %17
%22 = call i32 @strcpy(i8* %20, i8* %21)
%23 = getelementptr inbounds [2048 x i8], [2048 x i8]* %19, i64 0, i64 0
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%25 = load i32*, i32** %15
%26 = load i32*, i32** %16
%27 = getelementptr inbounds [2048 x i8], [2048 x i8]* %19, i64 0, i64 0
%28 = call i32 @decl(i32* %25, i32* %26, i8* null, i8* %27, i32 2, i32 0)
%29 = load i8*, i8** %10
%30 = load i32, i32* %14
%31 = load i32*, i32** %15
%32 = call i32 @outS(i8* %29, i32 0, i32 %30, i32* %31, i32 1)
%33 = load i32*, i32** %15
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32*, i32** %15
%36 = load i32*, i32** %16
%37 = load i8*, i8** %17
%38 = load i32, i32* %18
%39 = call i32 @decl(i32* %35, i32* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %37, i32 2, i32 %38)
%40 = load i32*, i32** %15
%41 = load i32, i32* %11
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = load i32*, i32** %15
%44 = load i32, i32* %12
%45 = load i32, i32* %13
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %44, i32 %45)
%47 = load i32*, i32** %15
%48 = load i8*, i8** %17
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %48)
%50 = load i32*, i32** %15
%51 = getelementptr inbounds [2048 x i8], [2048 x i8]* %19, i64 0, i64 0
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %51)
%53 = load i32*, i32** %15
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"_image\00"
@.str.2 = [7 x i8] c"Bitmap\00"
@.str.3 = [16 x i8] c" dc.w %d\0A\00"
@.str.4 = [20 x i8] c" dc.w %d, %d\0A\00"
@.str.5 = [24 x i8] c" dc.l %s_palette\0A\00"
@.str.6 = [16 x i8] c" dc.l %s\0A\00"
define void @outBitmap(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5, i32* %6, i8* %7, i32 %8) {
%10 = alloca [2048 x i8]
%11 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%12 = call i32 @strcpy(i8* %11, i8* %7)
%13 = call i32 @strcat(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @decl(i32* %5, i32* %6, i8* null, i8* %11, i32 2, i32 0)
%15 = call i32 @outS(i8* %0, i32 0, i32 %4, i32* %5, i32 1)
%16 = call i32 @fputc(i32 10, i32* %5)
%17 = call i32 @decl(i32* %5, i32* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %7, i32 2, i32 %8)
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %1)
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %2, i32 %3)
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %7)
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %11)
%22 = call i32 @fputc(i32 10, i32* %5)
ret void
}