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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ read_texture(char *, int *, int *, int *);
int /*<<< orphan*/ stderr;
void imgLoad(char *filename_in, int *w_out, int *h_out, GLubyte **img_out) {
  int comp;
  *img_out = (GLubyte *)read_texture(filename_in, w_out, h_out, &comp);
  if (img_out == NULL) {
    fprintf(stderr, "unable to read %s\n", filename_in);
    exit(EXIT_FAILURE);
  }
  if (comp != 3 && comp != 4) {
    fprintf(stderr, "%s: image is not RGB or RGBA\n", filename_in);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<imgLoad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1040 <read_texture@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x20(%rbp)
jne    1199 <imgLoad+0x69>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe7a(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
cmpl   $0x3,-0x24(%rbp)
je     11d4 <imgLoad+0xa4>
cmpl   $0x4,-0x24(%rbp)
je     11d4 <imgLoad+0xa4>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe52(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imgLoad>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdi,%r14
lea    0x4(%rsp),%rcx
call   1040 <read_texture@plt>
mov    %rax,(%rbx)
mov    0x4(%rsp),%eax
add    $0xfffffffb,%eax
cmp    $0xfffffffd,%eax
jbe    115b <imgLoad+0x2b>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"unable to read %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [30 x i8] c"%s: image is not RGB or RGBA\0A\00"
define void @imgLoad(i8* %0, i32* %1, i32* %2, i32** %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32**
%9 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32** %3, i32*** %8
%10 = load i8*, i8** %5
%11 = load i32*, i32** %6
%12 = load i32*, i32** %7
%13 = call i64 @read_texture(i8* %10, i32* %11, i32* %12, i32* %9)
%14 = inttoptr i64 %13 to i32*
%15 = load i32**, i32*** %8
store i32* %14, i32** %15
%16 = load i32**, i32*** %8
%17 = icmp eq i32** %16, null
br i1 %17, label %18, label %24
18: ; preds = %4
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %5
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %4
%25 = load i32, i32* %9
%26 = icmp ne i32 %25, 3
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i32, i32* %9
%29 = icmp ne i32 %28, 4
br i1 %29, label %30, label %36
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %5
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %27, %24
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [30 x i8] c"%s: image is not RGB or RGBA\0A\00"
define void @imgLoad(i8* %0, i32* %1, i32* %2, i32** nocapture writeonly %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = call i64 @read_texture(i8* %0, i32* %1, i32* %2, i32* %5)
%8 = inttoptr i64 %7 to i32*
store i32* %8, i32** %3
%9 = load i32, i32* %5
%10 = add i32 %9, -5
%11 = icmp ult i32 %10, -2
br i1 %11, label %12, label %17
12: ; preds = %4
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %4
ret void
}