#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 unsigned int GLuint;
typedef int /*<<< orphan*/ GLsizei;

/* Variables and functions */
int /*<<< orphan*/ GL_NEAREST;
int /*<<< orphan*/ GL_REPEAT;
int /*<<< orphan*/ GL_REPLACE;
int /*<<< orphan*/ GL_RGBA;
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_UNSIGNED_BYTE;
int /*<<< orphan*/ glBindTexture(int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ glGenTextures(int, unsigned int *);
int /*<<< orphan*/ glTexEnvf(int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/);
int /*<<< orphan*/ glTexImage2D(int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/,
                                unsigned int *);
int /*<<< orphan*/ glTexParameterf(int /*<<< orphan*/, int /*<<< orphan*/,
                                   int /*<<< orphan*/);
int /*<<< orphan*/ glTexParameteri(int /*<<< orphan*/, int /*<<< orphan*/,
                                   int /*<<< orphan*/);
unsigned int textureGen(int w, int h, unsigned int *data) {
  GLuint id;
  glGenTextures(1, &id);
  glBindTexture(GL_TEXTURE_2D, id);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)w, (GLsizei)h, 0, GL_RGBA,
               GL_UNSIGNED_BYTE, data);
  return id;
}


x86 assembly (clang, -O0):
<textureGen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    $0x1,%edi
lea    -0x14(%rbp),%rsi
call   1070 <glGenTextures@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
call   1080 <glBindTexture@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
mov    0x2dfe(%rip),%rax
mov    (%rax),%edx
call   1030 <glTexParameteri@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
mov    0x2dcf(%rip),%rax
mov    (%rax),%esi
mov    0x2dde(%rip),%rax
mov    (%rax),%edx
call   1030 <glTexParameteri@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
mov    0x2db6(%rip),%rax
mov    (%rax),%edx
call   1060 <glTexParameterf@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    0x2d7f(%rip),%rax
mov    (%rax),%esi
mov    0x2d96(%rip),%rax
mov    (%rax),%edx
call   1060 <glTexParameterf@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    0x2daf(%rip),%rax
mov    (%rax),%esi
mov    0x2d86(%rip),%rax
mov    (%rax),%edx
call   1050 <glTexEnvf@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
mov    0x2daf(%rip),%rax
mov    (%rax),%edx
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%r8d
mov    0x2d9f(%rip),%rax
mov    (%rax),%r11d
mov    0x2d3d(%rip),%rax
mov    (%rax),%r10d
mov    -0x10(%rbp),%rax
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <glTexImage2D@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<textureGen>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %esi,%r15d
mov    %edi,%r12d
lea    0xc(%rsp),%rsi
mov    $0x1,%edi
call   1070 <glGenTextures@plt>
mov    0x2e2d(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0xc(%rsp),%esi
call   1080 <glBindTexture@plt>
mov    0x0(%rbp),%edi
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
mov    0x2dfe(%rip),%rbx
mov    (%rbx),%edx
call   1030 <glTexParameteri@plt>
mov    0x0(%rbp),%edi
mov    0x2dd5(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
call   1030 <glTexParameteri@plt>
mov    0x0(%rbp),%edi
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
mov    0x2dc9(%rip),%rbx
mov    (%rbx),%edx
call   1060 <glTexParameterf@plt>
mov    0x0(%rbp),%edi
mov    0x2d98(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
call   1060 <glTexParameterf@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
mov    0x2dcf(%rip),%rax
mov    (%rax),%esi
mov    0x2da6(%rip),%rax
mov    (%rax),%edx
call   1050 <glTexEnvf@plt>
mov    0x0(%rbp),%edi
mov    0x2dd5(%rip),%rax
mov    (%rax),%edx
mov    0x2d74(%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   1040 <glTexImage2D@plt>
add    $0x20,%rsp
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GL_TEXTURE_2D = global i32 0
@GL_TEXTURE_MIN_FILTER = global i32 0
@GL_NEAREST = global i32 0
@GL_TEXTURE_MAG_FILTER = global i32 0
@GL_TEXTURE_WRAP_S = global i32 0
@GL_REPEAT = global i32 0
@GL_TEXTURE_WRAP_T = global i32 0
@GL_TEXTURE_ENV = global i32 0
@GL_TEXTURE_ENV_MODE = global i32 0
@GL_REPLACE = global i32 0
@GL_RGBA = global i32 0
@GL_UNSIGNED_BYTE = global i32 0
define i32 @textureGen(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%8 = call i32 @glGenTextures(i32 1, i32* %7)
%9 = load i32, i32* @GL_TEXTURE_2D
%10 = load i32, i32* %7
%11 = call i32 @glBindTexture(i32 %9, i32 %10)
%12 = load i32, i32* @GL_TEXTURE_2D
%13 = load i32, i32* @GL_TEXTURE_MIN_FILTER
%14 = load i32, i32* @GL_NEAREST
%15 = call i32 @glTexParameteri(i32 %12, i32 %13, i32 %14)
%16 = load i32, i32* @GL_TEXTURE_2D
%17 = load i32, i32* @GL_TEXTURE_MAG_FILTER
%18 = load i32, i32* @GL_NEAREST
%19 = call i32 @glTexParameteri(i32 %16, i32 %17, i32 %18)
%20 = load i32, i32* @GL_TEXTURE_2D
%21 = load i32, i32* @GL_TEXTURE_WRAP_S
%22 = load i32, i32* @GL_REPEAT
%23 = call i32 @glTexParameterf(i32 %20, i32 %21, i32 %22)
%24 = load i32, i32* @GL_TEXTURE_2D
%25 = load i32, i32* @GL_TEXTURE_WRAP_T
%26 = load i32, i32* @GL_REPEAT
%27 = call i32 @glTexParameterf(i32 %24, i32 %25, i32 %26)
%28 = load i32, i32* @GL_TEXTURE_ENV
%29 = load i32, i32* @GL_TEXTURE_ENV_MODE
%30 = load i32, i32* @GL_REPLACE
%31 = call i32 @glTexEnvf(i32 %28, i32 %29, i32 %30)
%32 = load i32, i32* @GL_TEXTURE_2D
%33 = load i32, i32* @GL_RGBA
%34 = load i32, i32* %4
%35 = load i32, i32* %5
%36 = load i32, i32* @GL_RGBA
%37 = load i32, i32* @GL_UNSIGNED_BYTE
%38 = load i32*, i32** %6
%39 = call i32 @glTexImage2D(i32 %32, i32 0, i32 %33, i32 %34, i32 %35, i32 0, i32 %36, i32 %37, i32* %38)
%40 = load i32, i32* %7
ret i32 %40
}

LLVM IR (-O2):
@GL_TEXTURE_2D = global i32 0
@GL_TEXTURE_MIN_FILTER = global i32 0
@GL_NEAREST = global i32 0
@GL_TEXTURE_MAG_FILTER = global i32 0
@GL_TEXTURE_WRAP_S = global i32 0
@GL_REPEAT = global i32 0
@GL_TEXTURE_WRAP_T = global i32 0
@GL_TEXTURE_ENV = global i32 0
@GL_TEXTURE_ENV_MODE = global i32 0
@GL_REPLACE = global i32 0
@GL_RGBA = global i32 0
@GL_UNSIGNED_BYTE = global i32 0
define i32 @textureGen(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = call i32 @glGenTextures(i32 1, i32* %4)
%7 = load i32, i32* @GL_TEXTURE_2D
%8 = load i32, i32* %4
%9 = call i32 @glBindTexture(i32 %7, i32 %8)
%10 = load i32, i32* @GL_TEXTURE_2D
%11 = load i32, i32* @GL_TEXTURE_MIN_FILTER
%12 = load i32, i32* @GL_NEAREST
%13 = call i32 @glTexParameteri(i32 %10, i32 %11, i32 %12)
%14 = load i32, i32* @GL_TEXTURE_2D
%15 = load i32, i32* @GL_TEXTURE_MAG_FILTER
%16 = load i32, i32* @GL_NEAREST
%17 = call i32 @glTexParameteri(i32 %14, i32 %15, i32 %16)
%18 = load i32, i32* @GL_TEXTURE_2D
%19 = load i32, i32* @GL_TEXTURE_WRAP_S
%20 = load i32, i32* @GL_REPEAT
%21 = call i32 @glTexParameterf(i32 %18, i32 %19, i32 %20)
%22 = load i32, i32* @GL_TEXTURE_2D
%23 = load i32, i32* @GL_TEXTURE_WRAP_T
%24 = load i32, i32* @GL_REPEAT
%25 = call i32 @glTexParameterf(i32 %22, i32 %23, i32 %24)
%26 = load i32, i32* @GL_TEXTURE_ENV
%27 = load i32, i32* @GL_TEXTURE_ENV_MODE
%28 = load i32, i32* @GL_REPLACE
%29 = call i32 @glTexEnvf(i32 %26, i32 %27, i32 %28)
%30 = load i32, i32* @GL_TEXTURE_2D
%31 = load i32, i32* @GL_RGBA
%32 = load i32, i32* @GL_UNSIGNED_BYTE
%33 = call i32 @glTexImage2D(i32 %30, i32 0, i32 %31, i32 %0, i32 %1, i32 0, i32 %31, i32 %32, i32* %2)
%34 = load i32, i32* %4
ret i32 %34
}