#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;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ GL_CLAMP;
int /*<<< orphan*/ GL_DECAL;
int /*<<< orphan*/ GL_LINEAR;
int /*<<< orphan*/ GL_RGB;
int /*<<< orphan*/ GL_TEXTURE_2D;
int /*<<< orphan*/ GL_TEXTURE_ENV;
int /*<<< orphan*/ GL_TEXTURE_ENV_MODE;
int /*<<< orphan*/ GL_TEXTURE_MAG_FILTER;
int /*<<< orphan*/ GL_TEXTURE_MIN_FILTER;
int /*<<< orphan*/ GL_TEXTURE_WRAP_S;
int /*<<< orphan*/ GL_TEXTURE_WRAP_T;
int /*<<< orphan*/ GL_UNPACK_ALIGNMENT;
int /*<<< orphan*/ GL_UNSIGNED_BYTE;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ glBindTexture(int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ glGenTextures(int, unsigned int *);
int /*<<< orphan*/ glPixelStorei(int /*<<< orphan*/, int);
int /*<<< orphan*/ glTexEnvf(int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/);
int /*<<< orphan*/ glTexImage2D(int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int, int,
                                int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ glTexParameteri(int /*<<< orphan*/, int /*<<< orphan*/,
                                   int /*<<< orphan*/);
int /*<<< orphan*/ *malloc(int);
unsigned int textureFile(const char *pcFile, int iWidth, int iHeight) {
  unsigned int uiTexture;
  GLubyte *data;
  FILE *file;
  file = fopen(pcFile, "rb");
  if (file == NULL)
    return 0;
  data = malloc(3 * iWidth * iHeight);
  fread(data, iWidth * iHeight * 3, 1, file);
  fclose(file);
  glGenTextures(1, &uiTexture);
  glBindTexture(GL_TEXTURE_2D, uiTexture);
  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, iWidth, iHeight, 0, GL_RGB,
               GL_UNSIGNED_BYTE, data);
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  free(data);
  return uiTexture;
}


x86 assembly (clang, -O0):
<textureFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11ed <textureFile+0x3d>
movl   $0x0,-0x4(%rbp)
jmp    134e <textureFile+0x19e>
imul   $0x3,-0x14(%rbp),%edi
imul   -0x18(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   $0x3,%eax,%esi
mov    -0x30(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x1,%edi
lea    -0x1c(%rbp),%rsi
call   10b0 <glGenTextures@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%esi
call   10d0 <glBindTexture@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1080 <glPixelStorei@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
mov    0x2d7b(%rip),%rax
mov    (%rax),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    0x2d6b(%rip),%rax
mov    (%rax),%r11d
mov    0x2d11(%rip),%rax
mov    (%rax),%r10d
mov    -0x28(%rbp),%rax
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1070 <glTexImage2D@plt>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
mov    0x2d01(%rip),%rax
mov    (%rax),%esi
mov    0x2d40(%rip),%rax
mov    (%rax),%edx
call   1090 <glTexEnvf@plt>
mov    0x2cd2(%rip),%rax
mov    (%rax),%edi
mov    0x2d01(%rip),%rax
mov    (%rax),%esi
mov    0x2cf0(%rip),%rax
mov    (%rax),%edx
call   1060 <glTexParameteri@plt>
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
mov    0x2c99(%rip),%rax
mov    (%rax),%esi
mov    0x2cd0(%rip),%rax
mov    (%rax),%edx
call   1060 <glTexParameteri@plt>
mov    0x2c92(%rip),%rax
mov    (%rax),%edi
mov    0x2c99(%rip),%rax
mov    (%rax),%esi
mov    0x2cd8(%rip),%rax
mov    (%rax),%edx
call   1060 <glTexParameteri@plt>
mov    0x2c72(%rip),%rax
mov    (%rax),%edi
mov    0x2c49(%rip),%rax
mov    (%rax),%esi
mov    0x2cb8(%rip),%rax
mov    (%rax),%edx
call   1060 <glTexParameteri@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<textureFile>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r15d
mov    %esi,%r12d
lea    0xe37(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     12f4 <textureFile+0x144>
mov    %rax,%rbp
mov    %r12d,%eax
imul   %r15d,%eax
lea    (%rax,%rax,2),%ebx
mov    %ebx,%edi
call   10a0 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
lea    0xc(%rsp),%rsi
mov    $0x1,%edi
call   10b0 <glGenTextures@plt>
mov    0x2d7a(%rip),%rbx
mov    (%rbx),%edi
mov    0xc(%rsp),%esi
call   10d0 <glBindTexture@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1080 <glPixelStorei@plt>
mov    (%rbx),%edi
mov    0x2d9b(%rip),%rax
mov    (%rax),%edx
mov    0x2d42(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%rsp
xor    %esi,%esi
mov    %r12d,%ecx
mov    %r15d,%r8d
xor    %r9d,%r9d
push   %r14
push   %rax
push   %rdx
call   1070 <glTexImage2D@plt>
add    $0x20,%rsp
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
mov    0x2d34(%rip),%rax
mov    (%rax),%esi
mov    0x2d73(%rip),%rax
mov    (%rax),%edx
call   1090 <glTexEnvf@plt>
mov    (%rbx),%edi
mov    0x2d3b(%rip),%rax
mov    (%rax),%esi
mov    0x2d2a(%rip),%rbp
mov    0x0(%rbp),%edx
call   1060 <glTexParameteri@plt>
mov    (%rbx),%edi
mov    0x2cd9(%rip),%rax
mov    (%rax),%esi
mov    0x0(%rbp),%edx
call   1060 <glTexParameteri@plt>
mov    (%rbx),%edi
mov    0x2ce6(%rip),%rax
mov    (%rax),%esi
mov    0x2d25(%rip),%rbp
mov    0x0(%rbp),%edx
call   1060 <glTexParameteri@plt>
mov    (%rbx),%edi
mov    0x2c9c(%rip),%rax
mov    (%rax),%esi
mov    0x0(%rbp),%edx
call   1060 <glTexParameteri@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0xc(%rsp),%eax
jmp    12f6 <textureFile+0x146>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@GL_TEXTURE_2D = global i32 0
@GL_UNPACK_ALIGNMENT = global i32 0
@GL_RGB = global i32 0
@GL_UNSIGNED_BYTE = global i32 0
@GL_TEXTURE_ENV = global i32 0
@GL_TEXTURE_ENV_MODE = global i32 0
@GL_DECAL = global i32 0
@GL_TEXTURE_MIN_FILTER = global i32 0
@GL_LINEAR = global i32 0
@GL_TEXTURE_MAG_FILTER = global i32 0
@GL_TEXTURE_WRAP_S = global i32 0
@GL_CLAMP = global i32 0
@GL_TEXTURE_WRAP_T = global i32 0
define i32 @textureFile(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%11 = load i8*, i8** %5
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %10
%13 = load i32*, i32** %10
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %16
15: ; preds = %3
store i32 0, i32* %4
br label %68
16: ; preds = %3
%17 = load i32, i32* %6
%18 = mul nsw i32 3, %17
%19 = load i32, i32* %7
%20 = mul nsw i32 %18, %19
%21 = call i32* @malloc(i32 %20)
store i32* %21, i32** %9
%22 = load i32*, i32** %9
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = mul nsw i32 %23, %24
%26 = mul nsw i32 %25, 3
%27 = load i32*, i32** %10
%28 = call i32 @fread(i32* %22, i32 %26, i32 1, i32* %27)
%29 = load i32*, i32** %10
%30 = call i32 @fclose(i32* %29)
%31 = call i32 @glGenTextures(i32 1, i32* %8)
%32 = load i32, i32* @GL_TEXTURE_2D
%33 = load i32, i32* %8
%34 = call i32 @glBindTexture(i32 %32, i32 %33)
%35 = load i32, i32* @GL_UNPACK_ALIGNMENT
%36 = call i32 @glPixelStorei(i32 %35, i32 1)
%37 = load i32, i32* @GL_TEXTURE_2D
%38 = load i32, i32* @GL_RGB
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = load i32, i32* @GL_RGB
%42 = load i32, i32* @GL_UNSIGNED_BYTE
%43 = load i32*, i32** %9
%44 = call i32 @glTexImage2D(i32 %37, i32 0, i32 %38, i32 %39, i32 %40, i32 0, i32 %41, i32 %42, i32* %43)
%45 = load i32, i32* @GL_TEXTURE_ENV
%46 = load i32, i32* @GL_TEXTURE_ENV_MODE
%47 = load i32, i32* @GL_DECAL
%48 = call i32 @glTexEnvf(i32 %45, i32 %46, i32 %47)
%49 = load i32, i32* @GL_TEXTURE_2D
%50 = load i32, i32* @GL_TEXTURE_MIN_FILTER
%51 = load i32, i32* @GL_LINEAR
%52 = call i32 @glTexParameteri(i32 %49, i32 %50, i32 %51)
%53 = load i32, i32* @GL_TEXTURE_2D
%54 = load i32, i32* @GL_TEXTURE_MAG_FILTER
%55 = load i32, i32* @GL_LINEAR
%56 = call i32 @glTexParameteri(i32 %53, i32 %54, i32 %55)
%57 = load i32, i32* @GL_TEXTURE_2D
%58 = load i32, i32* @GL_TEXTURE_WRAP_S
%59 = load i32, i32* @GL_CLAMP
%60 = call i32 @glTexParameteri(i32 %57, i32 %58, i32 %59)
%61 = load i32, i32* @GL_TEXTURE_2D
%62 = load i32, i32* @GL_TEXTURE_WRAP_T
%63 = load i32, i32* @GL_CLAMP
%64 = call i32 @glTexParameteri(i32 %61, i32 %62, i32 %63)
%65 = load i32*, i32** %9
%66 = call i32 @free(i32* %65)
%67 = load i32, i32* %8
store i32 %67, i32* %4
br label %68
68: ; preds = %16, %15
%69 = load i32, i32* %4
ret i32 %69
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@GL_TEXTURE_2D = global i32 0
@GL_UNPACK_ALIGNMENT = global i32 0
@GL_RGB = global i32 0
@GL_UNSIGNED_BYTE = global i32 0
@GL_TEXTURE_ENV = global i32 0
@GL_TEXTURE_ENV_MODE = global i32 0
@GL_DECAL = global i32 0
@GL_TEXTURE_MIN_FILTER = global i32 0
@GL_LINEAR = global i32 0
@GL_TEXTURE_MAG_FILTER = global i32 0
@GL_TEXTURE_WRAP_S = global i32 0
@GL_CLAMP = global i32 0
@GL_TEXTURE_WRAP_T = global i32 0
define i32 @textureFile(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %46, label %8
8: ; preds = %3
%9 = mul i32 %1, 3
%10 = mul i32 %9, %2
%11 = tail call i32* @malloc(i32 %10)
%12 = tail call i32 @fread(i32* %11, i32 %10, i32 1, i32* %6)
%13 = tail call i32 @fclose(i32* %6)
%14 = call i32 @glGenTextures(i32 1, i32* %4)
%15 = load i32, i32* @GL_TEXTURE_2D
%16 = load i32, i32* %4
%17 = call i32 @glBindTexture(i32 %15, i32 %16)
%18 = load i32, i32* @GL_UNPACK_ALIGNMENT
%19 = call i32 @glPixelStorei(i32 %18, i32 1)
%20 = load i32, i32* @GL_TEXTURE_2D
%21 = load i32, i32* @GL_RGB
%22 = load i32, i32* @GL_UNSIGNED_BYTE
%23 = call i32 @glTexImage2D(i32 %20, i32 0, i32 %21, i32 %1, i32 %2, i32 0, i32 %21, i32 %22, i32* %11)
%24 = load i32, i32* @GL_TEXTURE_ENV
%25 = load i32, i32* @GL_TEXTURE_ENV_MODE
%26 = load i32, i32* @GL_DECAL
%27 = call i32 @glTexEnvf(i32 %24, i32 %25, i32 %26)
%28 = load i32, i32* @GL_TEXTURE_2D
%29 = load i32, i32* @GL_TEXTURE_MIN_FILTER
%30 = load i32, i32* @GL_LINEAR
%31 = call i32 @glTexParameteri(i32 %28, i32 %29, i32 %30)
%32 = load i32, i32* @GL_TEXTURE_2D
%33 = load i32, i32* @GL_TEXTURE_MAG_FILTER
%34 = load i32, i32* @GL_LINEAR
%35 = call i32 @glTexParameteri(i32 %32, i32 %33, i32 %34)
%36 = load i32, i32* @GL_TEXTURE_2D
%37 = load i32, i32* @GL_TEXTURE_WRAP_S
%38 = load i32, i32* @GL_CLAMP
%39 = call i32 @glTexParameteri(i32 %36, i32 %37, i32 %38)
%40 = load i32, i32* @GL_TEXTURE_2D
%41 = load i32, i32* @GL_TEXTURE_WRAP_T
%42 = load i32, i32* @GL_CLAMP
%43 = call i32 @glTexParameteri(i32 %40, i32 %41, i32 %42)
%44 = call i32 @free(i32* %11)
%45 = load i32, i32* %4
br label %46
46: ; preds = %3, %8
%47 = phi i32 [ %45, %8 ], [ 0, %3 ]
ret i32 %47
}