#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 /*<<< orphan*/ GL_QUADS;
int /*<<< orphan*/ GL_TEXTURE_2D;
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glBindTexture(int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glTexCoord2f(float, float);
int /*<<< orphan*/ glVertex2f(float, float);
void textureDraw(unsigned int id, int tw, int th, int x, int y, int w, int h,
                 float sx, float sy) {
  float rx = (float)x / (float)tw, ry = (float)y / (float)th;
  float rw = (float)w / (float)tw, rh = (float)h / (float)th;
  glBindTexture(GL_TEXTURE_2D, id);
  glBegin(GL_QUADS);
  glTexCoord2f(rx, ry);
  glVertex2f(sx, sy);
  glTexCoord2f(rx + rw, ry);
  glVertex2f(sx + w, sy);
  glTexCoord2f(rx + rw, ry + rh);
  glVertex2f(sx + w, sy + h);
  glTexCoord2f(rx, ry + rh);
  glVertex2f(sx, sy + h);
  glEnd();
}


x86 assembly (clang, -O0):
<textureDraw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
movss  %xmm1,-0x20(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
cvtsi2ssl 0x10(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
call   1060 <glBindTexture@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
movss  -0x24(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
call   1050 <glTexCoord2f@plt>
movss  -0x1c(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
call   1040 <glVertex2f@plt>
movss  -0x24(%rbp),%xmm0
addss  -0x2c(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
call   1050 <glTexCoord2f@plt>
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0x18(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  -0x20(%rbp),%xmm1
call   1040 <glVertex2f@plt>
movss  -0x24(%rbp),%xmm0
addss  -0x2c(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
addss  -0x30(%rbp),%xmm1
call   1050 <glTexCoord2f@plt>
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0x18(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  -0x20(%rbp),%xmm1
cvtsi2ssl 0x10(%rbp),%xmm2
addss  %xmm2,%xmm1
call   1040 <glVertex2f@plt>
movss  -0x24(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
addss  -0x30(%rbp),%xmm1
call   1050 <glTexCoord2f@plt>
movss  -0x1c(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
cvtsi2ssl 0x10(%rbp),%xmm2
addss  %xmm2,%xmm1
call   1040 <glVertex2f@plt>
mov    $0x0,%al
call   1030 <glEnd@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<textureDraw>:
sub    $0x68,%rsp
cvtsi2ss %esi,%xmm2
cvtsi2ss %edx,%xmm3
movss  %xmm1,0x8(%rsp)
movss  %xmm0,0xc(%rsp)
mov    %edi,%esi
movd   %r9d,%xmm0
movd   %ecx,%xmm1
punpckldq %xmm0,%xmm1
cvtdq2ps %xmm1,%xmm0
movaps %xmm0,0x30(%rsp)
shufps $0x0,%xmm2,%xmm2
divps  %xmm2,%xmm0
movaps %xmm0,0x20(%rsp)
movd   %r8d,%xmm0
movd   0x70(%rsp),%xmm1
punpckldq %xmm1,%xmm0
cvtdq2ps %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
shufps $0x0,%xmm3,%xmm3
divps  %xmm3,%xmm0
movaps %xmm0,0x10(%rsp)
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
call   1060 <glBindTexture@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
movaps 0x20(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
call   1050 <glTexCoord2f@plt>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   1040 <glVertex2f@plt>
movaps 0x20(%rsp),%xmm1
movaps %xmm1,%xmm0
shufps $0x55,%xmm1,%xmm0
addss  %xmm1,%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0x10(%rsp),%xmm1
call   1050 <glTexCoord2f@plt>
movaps 0x30(%rsp),%xmm0
shufps $0x55,%xmm0,%xmm0
addss  0xc(%rsp),%xmm0
movaps %xmm0,0x30(%rsp)
movss  0x8(%rsp),%xmm1
call   1040 <glVertex2f@plt>
movaps 0x10(%rsp),%xmm0
movaps %xmm0,%xmm1
shufps $0x55,%xmm0,%xmm1
addss  %xmm0,%xmm1
movaps %xmm1,0x10(%rsp)
movaps 0x50(%rsp),%xmm0
call   1050 <glTexCoord2f@plt>
movaps 0x40(%rsp),%xmm1
shufps $0x55,%xmm1,%xmm1
addss  0x8(%rsp),%xmm1
movaps %xmm1,0x40(%rsp)
movaps 0x30(%rsp),%xmm0
call   1040 <glVertex2f@plt>
movaps 0x20(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
call   1050 <glTexCoord2f@plt>
movss  0xc(%rsp),%xmm0
movaps 0x40(%rsp),%xmm1
call   1040 <glVertex2f@plt>
xor    %eax,%eax
add    $0x68,%rsp
jmp    1030 <glEnd@plt>

LLVM IR (-O0):
@GL_TEXTURE_2D = global i32 0
@GL_QUADS = global i32 0
define void @textureDraw(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, float %7, float %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca float
store i32 %0, i32* %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store float %7, float* %17
store float %8, float* %18
%23 = load i32, i32* %13
%24 = sitofp i32 %23 to float
%25 = load i32, i32* %11
%26 = sitofp i32 %25 to float
%27 = fdiv float %24, %26
store float %27, float* %19
%28 = load i32, i32* %14
%29 = sitofp i32 %28 to float
%30 = load i32, i32* %12
%31 = sitofp i32 %30 to float
%32 = fdiv float %29, %31
store float %32, float* %20
%33 = load i32, i32* %15
%34 = sitofp i32 %33 to float
%35 = load i32, i32* %11
%36 = sitofp i32 %35 to float
%37 = fdiv float %34, %36
store float %37, float* %21
%38 = load i32, i32* %16
%39 = sitofp i32 %38 to float
%40 = load i32, i32* %12
%41 = sitofp i32 %40 to float
%42 = fdiv float %39, %41
store float %42, float* %22
%43 = load i32, i32* @GL_TEXTURE_2D
%44 = load i32, i32* %10
%45 = call i32 @glBindTexture(i32 %43, i32 %44)
%46 = load i32, i32* @GL_QUADS
%47 = call i32 @glBegin(i32 %46)
%48 = load float, float* %19
%49 = load float, float* %20
%50 = call i32 @glTexCoord2f(float %48, float %49)
%51 = load float, float* %17
%52 = load float, float* %18
%53 = call i32 @glVertex2f(float %51, float %52)
%54 = load float, float* %19
%55 = load float, float* %21
%56 = fadd float %54, %55
%57 = load float, float* %20
%58 = call i32 @glTexCoord2f(float %56, float %57)
%59 = load float, float* %17
%60 = load i32, i32* %15
%61 = sitofp i32 %60 to float
%62 = fadd float %59, %61
%63 = load float, float* %18
%64 = call i32 @glVertex2f(float %62, float %63)
%65 = load float, float* %19
%66 = load float, float* %21
%67 = fadd float %65, %66
%68 = load float, float* %20
%69 = load float, float* %22
%70 = fadd float %68, %69
%71 = call i32 @glTexCoord2f(float %67, float %70)
%72 = load float, float* %17
%73 = load i32, i32* %15
%74 = sitofp i32 %73 to float
%75 = fadd float %72, %74
%76 = load float, float* %18
%77 = load i32, i32* %16
%78 = sitofp i32 %77 to float
%79 = fadd float %76, %78
%80 = call i32 @glVertex2f(float %75, float %79)
%81 = load float, float* %19
%82 = load float, float* %20
%83 = load float, float* %22
%84 = fadd float %82, %83
%85 = call i32 @glTexCoord2f(float %81, float %84)
%86 = load float, float* %17
%87 = load float, float* %18
%88 = load i32, i32* %16
%89 = sitofp i32 %88 to float
%90 = fadd float %87, %89
%91 = call i32 @glVertex2f(float %86, float %90)
%92 = call i32 (...) @glEnd()
ret void
}

LLVM IR (-O2):
@GL_TEXTURE_2D = global i32 0
@GL_QUADS = global i32 0
define void @textureDraw(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, float %7, float %8) {
%10 = sitofp i32 %1 to float
%11 = sitofp i32 %2 to float
%12 = insertelement <2 x i32> poison, i32 %3, i64 0
%13 = insertelement <2 x i32> %12, i32 %5, i64 1
%14 = sitofp <2 x i32> %13 to <2 x float>
%15 = insertelement <2 x float> poison, float %10, i64 0
%16 = shufflevector <2 x float> %15, <2 x float> poison, <2 x i32> zeroinitializer
%17 = fdiv <2 x float> %14, %16
%18 = insertelement <2 x i32> poison, i32 %4, i64 0
%19 = insertelement <2 x i32> %18, i32 %6, i64 1
%20 = sitofp <2 x i32> %19 to <2 x float>
%21 = insertelement <2 x float> poison, float %11, i64 0
%22 = shufflevector <2 x float> %21, <2 x float> poison, <2 x i32> zeroinitializer
%23 = fdiv <2 x float> %20, %22
%24 = load i32, i32* @GL_TEXTURE_2D
%25 = tail call i32 @glBindTexture(i32 %24, i32 %0)
%26 = load i32, i32* @GL_QUADS
%27 = tail call i32 @glBegin(i32 %26)
%28 = extractelement <2 x float> %17, i64 0
%29 = extractelement <2 x float> %23, i64 0
%30 = tail call i32 @glTexCoord2f(float %28, float %29)
%31 = tail call i32 @glVertex2f(float %7, float %8)
%32 = shufflevector <2 x float> %17, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%33 = fadd <2 x float> %17, %32
%34 = extractelement <2 x float> %33, i64 0
%35 = tail call i32 @glTexCoord2f(float %34, float %29)
%36 = extractelement <2 x float> %14, i64 1
%37 = fadd float %36, %7
%38 = tail call i32 @glVertex2f(float %37, float %8)
%39 = shufflevector <2 x float> %23, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%40 = fadd <2 x float> %23, %39
%41 = extractelement <2 x float> %40, i64 0
%42 = tail call i32 @glTexCoord2f(float %34, float %41)
%43 = extractelement <2 x float> %20, i64 1
%44 = fadd float %43, %8
%45 = tail call i32 @glVertex2f(float %37, float %44)
%46 = tail call i32 @glTexCoord2f(float %28, float %41)
%47 = tail call i32 @glVertex2f(float %7, float %44)
%48 = tail call i32 (...) @glEnd()
ret void
}