#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,
            int /*<<< orphan*/, char *, int /*<<< orphan*/, int /*<<< orphan*/,
            int, int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
            int /*<<< orphan*/, int /*<<< orphan*/, int, int, int, int);
int stbi_write_tga(char const *filename, int x, int y, int comp,
                   const void *data) {
  int has_alpha = !(comp & 1);
  return outfile(filename, -1, -1, x, y, comp, (void *)data, has_alpha, 0,
                 "111 221 2222 11", 0, 0, 2, 0, 0, 0, 0, 0, x, y,
                 24 + 8 * has_alpha, 8 * has_alpha);
}


x86 assembly (clang, -O0):
<stbi_write_tga>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb0,%rsp
mov    %rdi,-0x28(%rbp)
mov    %esi,-0x2c(%rbp)
mov    %edx,-0x30(%rbp)
mov    %ecx,-0x34(%rbp)
mov    %r8,-0x40(%rbp)
mov    -0x34(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x34(%rbp),%r9d
mov    -0x40(%rbp),%r12
mov    -0x44(%rbp),%r15d
mov    -0x2c(%rbp),%ebx
mov    -0x30(%rbp),%r11d
mov    -0x44(%rbp),%r10d
shl    $0x3,%r10d
add    $0x18,%r10d
mov    -0x44(%rbp),%eax
shl    $0x3,%eax
mov    $0xffffffff,%edx
xor    %esi,%esi
lea    0xe79(%rip),%r14
mov    %edx,%esi
mov    %r12,(%rsp)
mov    %r15d,0x8(%rsp)
movl   $0x0,0x10(%rsp)
mov    %r14,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
movl   $0x2,0x30(%rsp)
movl   $0x0,0x38(%rsp)
movl   $0x0,0x40(%rsp)
movl   $0x0,0x48(%rsp)
movl   $0x0,0x50(%rsp)
movl   $0x0,0x58(%rsp)
mov    %ebx,0x60(%rsp)
mov    %r11d,0x68(%rsp)
mov    %r10d,0x70(%rsp)
mov    %eax,0x78(%rsp)
call   1030 <outfile@plt>
add    $0xb0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<stbi_write_tga>:
push   %r14
push   %rbx
push   %rax
mov    %r8,%r10
mov    %ecx,%r9d
mov    %edx,%r8d
mov    %esi,%ecx
mov    %r9d,%eax
not    %eax
and    $0x1,%eax
lea    0x0(,%rax,8),%ebx
lea    0x18(,%rax,8),%r14d
lea    0xec3(%rip),%r11
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
push   %rbx
push   %r14
push   %r8
push   %rcx
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x2
push   $0x0
push   $0x0
push   %r11
push   $0x0
push   %rax
push   %r10
call   1030 <outfile@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"111 221 2222 11\00"
define i32 @stbi_write_tga(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* %9
%13 = and i32 %12, 1
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
%16 = zext i1 %15 to i32
store i32 %16, i32* %11
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = load i32, i32* %8
%20 = load i32, i32* %9
%21 = load i8*, i8** %10
%22 = load i32, i32* %11
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = load i32, i32* %11
%26 = mul nsw i32 8, %25
%27 = add nsw i32 24, %26
%28 = load i32, i32* %11
%29 = mul nsw i32 8, %28
%30 = call i32 @outfile(i8* %17, i32 -1, i32 -1, i32 %18, i32 %19, i32 %20, i8* %21, i32 %22, i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 %23, i32 %24, i32 %27, i32 %29)
ret i32 %30
}

LLVM IR (-O2):
@.str = [16 x i8] c"111 221 2222 11\00"
define i32 @stbi_write_tga(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = and i32 %3, 1
%7 = xor i32 %6, 1
%8 = shl nuw nsw i32 %7, 3
%9 = add nuw nsw i32 %8, 24
%10 = tail call i32 @outfile(i8* %0, i32 -1, i32 -1, i32 %1, i32 %2, i32 %3, i8* %4, i32 %7, i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 %1, i32 %2, i32 %9, i32 %8)
ret i32 %10
}