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

/* Variables and functions */
int outfile(char const *, int, int, int, int, int, void *, int /*<<< orphan*/,
            int, char *, char, char, int, int /*<<< orphan*/,
            int /*<<< orphan*/, int, int, int, int, int, int,
            int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
            int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int stbi_write_bmp(char const *filename, int x, int y, int comp, void *data) {
  int pad = (-x * 3) & 3;
  return outfile(filename, -1, -1, x, y, comp, data, 0, pad,
                 (char *)"11 4 22 4"
                         "4 44 22 444444",
                 'B', 'M', 14 + 40 + (x * 3 + pad) * y, 0, 0, 14 + 40, 40, x, y,
                 1, 24, 0, 0, 0, 0, 0, 0);
}


x86 assembly (clang, -O0):
<stbi_write_bmp>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0xd8,%rsp
mov    %rdi,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
mov    %edx,-0x28(%rbp)
mov    %ecx,-0x2c(%rbp)
mov    %r8,-0x38(%rbp)
xor    %eax,%eax
sub    -0x24(%rbp),%eax
imul   $0x3,%eax,%eax
and    $0x3,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x38(%rbp),%r15
mov    -0x3c(%rbp),%r14d
imul   $0x3,-0x24(%rbp),%r11d
add    -0x3c(%rbp),%r11d
imul   -0x28(%rbp),%r11d
add    $0x36,%r11d
mov    -0x24(%rbp),%r10d
mov    -0x28(%rbp),%eax
mov    $0xffffffff,%edx
xor    %esi,%esi
lea    0xe83(%rip),%rbx
mov    %edx,%esi
mov    %r15,(%rsp)
movl   $0x0,0x8(%rsp)
mov    %r14d,0x10(%rsp)
mov    %rbx,0x18(%rsp)
movl   $0x42,0x20(%rsp)
movl   $0x4d,0x28(%rsp)
mov    %r11d,0x30(%rsp)
movl   $0x0,0x38(%rsp)
movl   $0x0,0x40(%rsp)
movl   $0x36,0x48(%rsp)
movl   $0x28,0x50(%rsp)
mov    %r10d,0x58(%rsp)
mov    %eax,0x60(%rsp)
movl   $0x1,0x68(%rsp)
movl   $0x18,0x70(%rsp)
movl   $0x0,0x78(%rsp)
movl   $0x0,0x80(%rsp)
movl   $0x0,0x88(%rsp)
movl   $0x0,0x90(%rsp)
movl   $0x0,0x98(%rsp)
movl   $0x0,0xa0(%rsp)
call   1030 <outfile@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<stbi_write_bmp>:
push   %rbx
mov    %r8,%r10
mov    %ecx,%r9d
mov    %edx,%r8d
mov    %esi,%ecx
lea    (%rcx,%rcx,2),%eax
mov    %eax,%r11d
neg    %r11d
and    $0x3,%r11d
add    %r11d,%eax
imul   %edx,%eax
add    $0x36,%eax
sub    $0x8,%rsp
lea    0xec3(%rip),%rbx
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x18
push   $0x1
push   %r8
push   %rcx
push   $0x28
push   $0x36
push   $0x0
push   $0x0
push   %rax
push   $0x4d
push   $0x42
push   %rbx
push   %r11
push   $0x0
push   %r10
call   1030 <outfile@plt>
add    $0xb0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"11 4 22 44 44 22 444444\00"
define i32 @stbi_write_bmp(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*
%11 = alloca i32
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
%12 = load i32, i32* %7
%13 = sub nsw i32 0, %12
%14 = mul nsw i32 %13, 3
%15 = and i32 %14, 3
store i32 %15, i32* %11
%16 = load i8*, i8** %6
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = load i8*, i8** %10
%21 = load i32, i32* %11
%22 = load i32, i32* %7
%23 = mul nsw i32 %22, 3
%24 = load i32, i32* %11
%25 = add nsw i32 %23, %24
%26 = load i32, i32* %8
%27 = mul nsw i32 %25, %26
%28 = add nsw i32 54, %27
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = call i32 @outfile(i8* %16, i32 -1, i32 -1, i32 %17, i32 %18, i32 %19, i8* %20, i32 0, i32 %21, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8 signext 66, i8 signext 77, i32 %28, i32 0, i32 0, i32 54, i32 40, i32 %29, i32 %30, i32 1, i32 24, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
ret i32 %31
}

LLVM IR (-O2):
@.str = [24 x i8] c"11 4 22 44 44 22 444444\00"
define i32 @stbi_write_bmp(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = mul i32 %1, -3
%7 = and i32 %6, 3
%8 = mul nsw i32 %1, 3
%9 = add nsw i32 %7, %8
%10 = mul nsw i32 %9, %2
%11 = add nsw i32 %10, 54
%12 = tail call i32 @outfile(i8* %0, i32 -1, i32 -1, i32 %1, i32 %2, i32 %3, i8* %4, i32 0, i32 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8 signext 66, i8 signext 77, i32 %11, i32 0, i32 0, i32 54, i32 40, i32 %1, i32 %2, i32 1, i32 24, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
ret i32 %12
}