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

/* Variables and functions */
int /*<<< orphan*/ GL_LINEAR;
int /*<<< orphan*/ GL_NEAREST_MIPMAP_LINEAR;
int /*<<< orphan*/ GL_REPEAT;
int /*<<< orphan*/ GL_RGBA;
int /*<<< orphan*/ GL_TEXTURE_2D;
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*/ free(int *);
int /*<<< orphan*/ glTexParameteri(int /*<<< orphan*/, int /*<<< orphan*/,
                                   int /*<<< orphan*/);
int /*<<< orphan*/ gluBuild2DMipmaps(int /*<<< orphan*/, int, int, int,
                                     int /*<<< orphan*/, int /*<<< orphan*/,
                                     int *);
scalar_t__ malloc(int);
void setCheckTexture(void) {
  int texWidth = 64;
  int texHeight = 64;
  GLubyte *texPixels, *p;
  int i, j;
  texPixels = (GLubyte *)malloc(texWidth * texHeight * 4 * sizeof(GLubyte));
  if (texPixels == NULL) {
    return;
  }
  p = texPixels;
  for (i = 0; i < texHeight; ++i) {
    for (j = 0; j < texWidth; ++j) {
      if ((i ^ j) & 8) {
        p[0] = 0xff;
        p[1] = 0xff;
        p[2] = 0xff;
        p[3] = 0xff;
      } else {
        p[0] = 0x08;
        p[1] = 0x08;
        p[2] = 0x08;
        p[3] = 0xff;
      }
      p += 4;
    }
  }
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
                  GL_NEAREST_MIPMAP_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  gluBuild2DMipmaps(GL_TEXTURE_2D, 4, texWidth, texHeight, GL_RGBA,
                    GL_UNSIGNED_BYTE, texPixels);
  free(texPixels);
}


x86 assembly (clang, -O0):
<setCheckTexture>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x40,-0x4(%rbp)
movl   $0x40,-0x8(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
shl    $0x2,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1181 <setCheckTexture+0x41>
jmp    1307 <setCheckTexture+0x1c7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1249 <setCheckTexture+0x109>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1236 <setCheckTexture+0xf6>
mov    -0x1c(%rbp),%eax
xor    -0x20(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11f1 <setCheckTexture+0xb1>
mov    -0x18(%rbp),%rax
movl   $0xff,(%rax)
mov    -0x18(%rbp),%rax
movl   $0xff,0x4(%rax)
mov    -0x18(%rbp),%rax
movl   $0xff,0x8(%rax)
mov    -0x18(%rbp),%rax
movl   $0xff,0xc(%rax)
jmp    121c <setCheckTexture+0xdc>
mov    -0x18(%rbp),%rax
movl   $0x8,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x8,0x4(%rax)
mov    -0x18(%rbp),%rax
movl   $0x8,0x8(%rax)
mov    -0x18(%rbp),%rax
movl   $0xff,0xc(%rax)
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a3 <setCheckTexture+0x63>
jmp    123b <setCheckTexture+0xfb>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1190 <setCheckTexture+0x50>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
mov    0x2d87(%rip),%rax
mov    (%rax),%esi
mov    0x2d56(%rip),%rax
mov    (%rax),%edx
call   1040 <glTexParameteri@plt>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
mov    0x2d27(%rip),%rax
mov    (%rax),%esi
mov    0x2d56(%rip),%rax
mov    (%rax),%edx
call   1040 <glTexParameteri@plt>
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
mov    0x2d37(%rip),%rax
mov    (%rax),%esi
mov    0x2d0e(%rip),%rax
mov    (%rax),%edx
call   1040 <glTexParameteri@plt>
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
mov    0x2cd7(%rip),%rax
mov    (%rax),%esi
mov    0x2cee(%rip),%rax
mov    (%rax),%edx
call   1040 <glTexParameteri@plt>
mov    0x2cf0(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    0x2d11(%rip),%rax
mov    (%rax),%r8d
mov    0x2cbf(%rip),%rax
mov    (%rax),%r9d
mov    -0x10(%rbp),%rax
mov    $0x4,%esi
mov    %rax,(%rsp)
call   1060 <gluBuild2DMipmaps@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setCheckTexture>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x10000,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     126d <setCheckTexture+0x12d>
mov    %rax,%rbx
xor    %eax,%eax
mov    $0x8,%ecx
mov    %rbx,%rdx
nopl   0x0(%rax)
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %esi,%edi
xor    %eax,%edi
test   $0x8,%dil
mov    $0xff,%edi
cmove  %ecx,%edi
mov    %edi,(%rdx)
mov    %edi,0x4(%rdx)
mov    %edi,0x8(%rdx)
movl   $0xff,0xc(%rdx)
mov    %edi,0x10(%rdx)
mov    %edi,0x14(%rdx)
mov    %edi,0x18(%rdx)
movl   $0xff,0x1c(%rdx)
add    $0x20,%rdx
add    $0x2,%esi
cmp    $0x40,%esi
jne    1180 <setCheckTexture+0x40>
add    $0x1,%eax
cmp    $0x40,%eax
jne    1170 <setCheckTexture+0x30>
mov    0x2df6(%rip),%r14
mov    (%r14),%edi
mov    0x2e0c(%rip),%rax
mov    (%rax),%esi
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
call   1040 <glTexParameteri@plt>
mov    (%r14),%edi
mov    0x2db2(%rip),%rax
mov    (%rax),%esi
mov    0x2de1(%rip),%rax
mov    (%rax),%edx
call   1040 <glTexParameteri@plt>
mov    (%r14),%edi
mov    0x2dc8(%rip),%rax
mov    (%rax),%esi
mov    0x2d9f(%rip),%r15
mov    (%r15),%edx
call   1040 <glTexParameteri@plt>
mov    (%r14),%edi
mov    0x2d6d(%rip),%rax
mov    (%rax),%esi
mov    (%r15),%edx
call   1040 <glTexParameteri@plt>
mov    (%r14),%edi
mov    0x2db9(%rip),%rax
mov    (%rax),%r8d
mov    0x2d67(%rip),%rax
mov    (%rax),%r9d
mov    %rbx,(%rsp)
mov    $0x4,%esi
mov    $0x40,%edx
mov    $0x40,%ecx
call   1060 <gluBuild2DMipmaps@plt>
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@GL_TEXTURE_2D = global i32 0
@GL_TEXTURE_MIN_FILTER = global i32 0
@GL_NEAREST_MIPMAP_LINEAR = global i32 0
@GL_TEXTURE_MAG_FILTER = global i32 0
@GL_LINEAR = global i32 0
@GL_TEXTURE_WRAP_S = global i32 0
@GL_REPEAT = global i32 0
@GL_TEXTURE_WRAP_T = global i32 0
@GL_RGBA = global i32 0
@GL_UNSIGNED_BYTE = global i32 0
define void @setCheckTexture() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32 64, i32* %1
store i32 64, i32* %2
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = mul nsw i32 %7, %8
%10 = mul nsw i32 %9, 4
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %3
%16 = load i32*, i32** %3
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %19
18: ; preds = %0
br label %90
19: ; preds = %0
%20 = load i32*, i32** %3
store i32* %20, i32** %4
store i32 0, i32* %5
br label %21
21: ; preds = %61, %19
%22 = load i32, i32* %5
%23 = load i32, i32* %2
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %64
25: ; preds = %21
store i32 0, i32* %6
br label %26
26: ; preds = %57, %25
%27 = load i32, i32* %6
%28 = load i32, i32* %1
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %60
30: ; preds = %26
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = xor i32 %31, %32
%34 = and i32 %33, 8
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %45
36: ; preds = %30
%37 = load i32*, i32** %4
%38 = getelementptr inbounds i32, i32* %37, i64 0
store i32 255, i32* %38
%39 = load i32*, i32** %4
%40 = getelementptr inbounds i32, i32* %39, i64 1
store i32 255, i32* %40
%41 = load i32*, i32** %4
%42 = getelementptr inbounds i32, i32* %41, i64 2
store i32 255, i32* %42
%43 = load i32*, i32** %4
%44 = getelementptr inbounds i32, i32* %43, i64 3
store i32 255, i32* %44
br label %54
45: ; preds = %30
%46 = load i32*, i32** %4
%47 = getelementptr inbounds i32, i32* %46, i64 0
store i32 8, i32* %47
%48 = load i32*, i32** %4
%49 = getelementptr inbounds i32, i32* %48, i64 1
store i32 8, i32* %49
%50 = load i32*, i32** %4
%51 = getelementptr inbounds i32, i32* %50, i64 2
store i32 8, i32* %51
%52 = load i32*, i32** %4
%53 = getelementptr inbounds i32, i32* %52, i64 3
store i32 255, i32* %53
br label %54
54: ; preds = %45, %36
%55 = load i32*, i32** %4
%56 = getelementptr inbounds i32, i32* %55, i64 4
store i32* %56, i32** %4
br label %57
57: ; preds = %54
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %26
60: ; preds = %26
br label %61
61: ; preds = %60
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
br label %21
64: ; preds = %21
%65 = load i32, i32* @GL_TEXTURE_2D
%66 = load i32, i32* @GL_TEXTURE_MIN_FILTER
%67 = load i32, i32* @GL_NEAREST_MIPMAP_LINEAR
%68 = call i32 @glTexParameteri(i32 %65, i32 %66, i32 %67)
%69 = load i32, i32* @GL_TEXTURE_2D
%70 = load i32, i32* @GL_TEXTURE_MAG_FILTER
%71 = load i32, i32* @GL_LINEAR
%72 = call i32 @glTexParameteri(i32 %69, i32 %70, i32 %71)
%73 = load i32, i32* @GL_TEXTURE_2D
%74 = load i32, i32* @GL_TEXTURE_WRAP_S
%75 = load i32, i32* @GL_REPEAT
%76 = call i32 @glTexParameteri(i32 %73, i32 %74, i32 %75)
%77 = load i32, i32* @GL_TEXTURE_2D
%78 = load i32, i32* @GL_TEXTURE_WRAP_T
%79 = load i32, i32* @GL_REPEAT
%80 = call i32 @glTexParameteri(i32 %77, i32 %78, i32 %79)
%81 = load i32, i32* @GL_TEXTURE_2D
%82 = load i32, i32* %1
%83 = load i32, i32* %2
%84 = load i32, i32* @GL_RGBA
%85 = load i32, i32* @GL_UNSIGNED_BYTE
%86 = load i32*, i32** %3
%87 = call i32 @gluBuild2DMipmaps(i32 %81, i32 4, i32 %82, i32 %83, i32 %84, i32 %85, i32* %86)
%88 = load i32*, i32** %3
%89 = call i32 @free(i32* %88)
br label %90
90: ; preds = %64, %18
ret void
}

LLVM IR (-O2):
@GL_TEXTURE_2D = global i32 0
@GL_TEXTURE_MIN_FILTER = global i32 0
@GL_NEAREST_MIPMAP_LINEAR = global i32 0
@GL_TEXTURE_MAG_FILTER = global i32 0
@GL_LINEAR = global i32 0
@GL_TEXTURE_WRAP_S = global i32 0
@GL_REPEAT = global i32 0
@GL_TEXTURE_WRAP_T = global i32 0
@GL_RGBA = global i32 0
@GL_UNSIGNED_BYTE = global i32 0
define void @setCheckTexture() {
%1 = tail call i64 @malloc(i32 65536)
%2 = inttoptr i64 %1 to i32*
%3 = icmp eq i64 %1, 0
br i1 %3, label %53, label %4
4: ; preds = %0, %28
%5 = phi i32 [ %29, %28 ], [ 0, %0 ]
%6 = phi i32* [ %25, %28 ], [ %2, %0 ]
br label %7
7: ; preds = %7, %4
%8 = phi i32 [ 0, %4 ], [ %26, %7 ]
%9 = phi i32* [ %6, %4 ], [ %25, %7 ]
%10 = xor i32 %8, %5
%11 = and i32 %10, 8
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 8, i32 255
store i32 %13, i32* %9
%14 = getelementptr inbounds i32, i32* %9, i64 1
store i32 %13, i32* %14
%15 = getelementptr inbounds i32, i32* %9, i64 2
store i32 %13, i32* %15
%16 = getelementptr inbounds i32, i32* %9, i64 3
store i32 255, i32* %16
%17 = getelementptr inbounds i32, i32* %9, i64 4
%18 = xor i32 %8, %5
%19 = and i32 %18, 8
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i32 8, i32 255
store i32 %21, i32* %17
%22 = getelementptr inbounds i32, i32* %9, i64 5
store i32 %21, i32* %22
%23 = getelementptr inbounds i32, i32* %9, i64 6
store i32 %21, i32* %23
%24 = getelementptr inbounds i32, i32* %9, i64 7
store i32 255, i32* %24
%25 = getelementptr inbounds i32, i32* %9, i64 8
%26 = add nuw nsw i32 %8, 2
%27 = icmp eq i32 %26, 64
br i1 %27, label %28, label %7
28: ; preds = %7
%29 = add nuw nsw i32 %5, 1
%30 = icmp eq i32 %29, 64
br i1 %30, label %31, label %4
31: ; preds = %28
%32 = load i32, i32* @GL_TEXTURE_2D
%33 = load i32, i32* @GL_TEXTURE_MIN_FILTER
%34 = load i32, i32* @GL_NEAREST_MIPMAP_LINEAR
%35 = tail call i32 @glTexParameteri(i32 %32, i32 %33, i32 %34)
%36 = load i32, i32* @GL_TEXTURE_2D
%37 = load i32, i32* @GL_TEXTURE_MAG_FILTER
%38 = load i32, i32* @GL_LINEAR
%39 = tail call i32 @glTexParameteri(i32 %36, i32 %37, i32 %38)
%40 = load i32, i32* @GL_TEXTURE_2D
%41 = load i32, i32* @GL_TEXTURE_WRAP_S
%42 = load i32, i32* @GL_REPEAT
%43 = tail call i32 @glTexParameteri(i32 %40, i32 %41, i32 %42)
%44 = load i32, i32* @GL_TEXTURE_2D
%45 = load i32, i32* @GL_TEXTURE_WRAP_T
%46 = load i32, i32* @GL_REPEAT
%47 = tail call i32 @glTexParameteri(i32 %44, i32 %45, i32 %46)
%48 = load i32, i32* @GL_TEXTURE_2D
%49 = load i32, i32* @GL_RGBA
%50 = load i32, i32* @GL_UNSIGNED_BYTE
%51 = tail call i32 @gluBuild2DMipmaps(i32 %48, i32 4, i32 64, i32 64, i32 %49, i32 %50, i32* %2)
%52 = tail call i32 @free(i32* %2)
br label %53
53: ; preds = %0, %31
ret void
}