#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, int /*<<< orphan*/, 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 == 2 || comp == 4);
  int colorbytes = has_alpha ? comp - 1 : comp;
  int format = colorbytes < 2 ? 3 : 2;
  return outfile(filename, -1, -1, x, y, comp, 0, (void *)data, has_alpha, 0,
                 "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y,
                 (colorbytes + has_alpha) * 8, has_alpha * 8);
}


x86 assembly (clang, -O0):
<stbi_write_tga>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rdi,-0x30(%rbp)
mov    %esi,-0x34(%rbp)
mov    %edx,-0x38(%rbp)
mov    %ecx,-0x3c(%rbp)
mov    %r8,-0x48(%rbp)
mov    $0x1,%al
cmpl   $0x2,-0x3c(%rbp)
mov    %al,-0x55(%rbp)
je     114e <stbi_write_tga+0x3e>
cmpl   $0x4,-0x3c(%rbp)
sete   %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     1171 <stbi_write_tga+0x61>
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1177 <stbi_write_tga+0x67>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%edx
mov    $0x2,%eax
mov    $0x3,%ecx
cmp    $0x2,%edx
cmovl  %ecx,%eax
mov    %eax,-0x54(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%r8d
mov    -0x3c(%rbp),%r9d
mov    -0x48(%rbp),%r13
mov    -0x4c(%rbp),%r12d
mov    -0x54(%rbp),%r14d
mov    -0x34(%rbp),%ebx
mov    -0x38(%rbp),%r11d
mov    -0x50(%rbp),%r10d
add    -0x4c(%rbp),%r10d
shl    $0x3,%r10d
mov    -0x4c(%rbp),%eax
shl    $0x3,%eax
mov    $0xffffffff,%edx
xor    %esi,%esi
lea    0xe2b(%rip),%r15
mov    %edx,%esi
movl   $0x0,(%rsp)
mov    %r13,0x8(%rsp)
mov    %r12d,0x10(%rsp)
movl   $0x0,0x18(%rsp)
mov    %r15,0x20(%rsp)
movl   $0x0,0x28(%rsp)
movl   $0x0,0x30(%rsp)
mov    %r14d,0x38(%rsp)
movl   $0x0,0x40(%rsp)
movl   $0x0,0x48(%rsp)
movl   $0x0,0x50(%rsp)
movl   $0x0,0x58(%rsp)
movl   $0x0,0x60(%rsp)
mov    %ebx,0x68(%rsp)
mov    %r11d,0x70(%rsp)
mov    %r10d,0x78(%rsp)
mov    %eax,0x80(%rsp)
call   1030 <outfile@plt>
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<stbi_write_tga>:
push   %r15
push   %r14
push   %rbx
mov    %r8,%r10
mov    %ecx,%r9d
mov    %edx,%r8d
mov    %esi,%ecx
lea    -0x2(%r9),%eax
xor    %r11d,%r11d
test   $0xfffffffd,%eax
sete   %r11b
mov    %r9d,%edx
sub    %r11d,%edx
xor    %eax,%eax
cmp    $0x2,%edx
setl   %al
or     $0x2,%eax
lea    0x0(,%r9,8),%r15d
lea    0x0(,%r11,8),%ebx
sub    $0x8,%rsp
lea    0xea4(%rip),%r14
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
push   %rbx
push   %r15
push   %r8
push   %rcx
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   %rax
push   $0x0
push   $0x0
push   %r14
push   $0x0
push   %r11
push   %r10
push   $0x0
call   1030 <outfile@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
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
%12 = alloca i32
%13 = 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
%14 = load i32, i32* %9
%15 = icmp eq i32 %14, 2
br i1 %15, label %19, label %16
16: ; preds = %5
%17 = load i32, i32* %9
%18 = icmp eq i32 %17, 4
br label %19
19: ; preds = %16, %5
%20 = phi i1 [ true, %5 ], [ %18, %16 ]
%21 = zext i1 %20 to i32
store i32 %21, i32* %11
%22 = load i32, i32* %11
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* %9
%26 = sub nsw i32 %25, 1
br label %29
27: ; preds = %19
%28 = load i32, i32* %9
br label %29
29: ; preds = %27, %24
%30 = phi i32 [ %26, %24 ], [ %28, %27 ]
store i32 %30, i32* %12
%31 = load i32, i32* %12
%32 = icmp slt i32 %31, 2
%33 = zext i1 %32 to i64
%34 = select i1 %32, i32 3, i32 2
store i32 %34, i32* %13
%35 = load i8*, i8** %6
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = load i32, i32* %9
%39 = load i8*, i8** %10
%40 = load i32, i32* %11
%41 = load i32, i32* %13
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = load i32, i32* %12
%45 = load i32, i32* %11
%46 = add nsw i32 %44, %45
%47 = mul nsw i32 %46, 8
%48 = load i32, i32* %11
%49 = mul nsw i32 %48, 8
%50 = call i32 @outfile(i8* %35, i32 -1, i32 -1, i32 %36, i32 %37, i32 %38, i32 0, i8* %39, i32 %40, i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32 %41, i32 0, i32 0, i32 0, i32 0, i32 0, i32 %42, i32 %43, i32 %47, i32 %49)
ret i32 %50
}

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 = icmp eq i32 %3, 2
%7 = icmp eq i32 %3, 4
%8 = or i1 %6, %7
%9 = zext i1 %8 to i32
%10 = sext i1 %8 to i32
%11 = add nsw i32 %10, %3
%12 = icmp slt i32 %11, 2
%13 = select i1 %12, i32 3, i32 2
%14 = add nsw i32 %11, %9
%15 = shl nsw i32 %14, 3
%16 = select i1 %8, i32 8, i32 0
%17 = tail call i32 @outfile(i8* %0, i32 -1, i32 -1, i32 %1, i32 %2, i32 %3, i32 0, i8* %4, i32 %9, i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32 %13, i32 0, i32 0, i32 0, i32 0, i32 0, i32 %1, i32 %2, i32 %15, i32 %16)
ret i32 %17
}