#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 double GLfloat;

/* Variables and functions */
int /*<<< orphan*/ GL_QUAD_STRIP;
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glColor4fv(double *);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glVertex2f(double, double);
void drawCheck(int w, int h, GLfloat lightCheck[4], GLfloat darkCheck[4]) {
  float dw = 2.0 / w;
  float dh = 2.0 / h;
  int i, j;
  for (i = 0; i < w; ++i) {
    GLfloat x0 = -1.0 + i * dw;
    GLfloat x1 = x0 + dw;
    glBegin(GL_QUAD_STRIP);
    for (j = 0; j <= h; ++j) {
      GLfloat y = -1.0 + j * dh;
      if ((i ^ j) & 1) {
        glColor4fv(lightCheck);
      } else {
        glColor4fv(darkCheck);
      }
      glVertex2f(x0, y);
      glVertex2f(x1, y);
    }
    glEnd();
  }
}


x86 assembly (clang, -O0):
<drawCheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe9d(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe83(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    127d <drawCheck+0x13d>
cvtsi2ssl -0x24(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe55(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1060 <glBegin@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1268 <drawCheck+0x128>
cvtsi2ssl -0x28(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdfe(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x24(%rbp),%eax
xor    -0x28(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1233 <drawCheck+0xf3>
mov    -0x10(%rbp),%rdi
call   1030 <glColor4fv@plt>
jmp    123c <drawCheck+0xfc>
mov    -0x18(%rbp),%rdi
call   1030 <glColor4fv@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   1050 <glVertex2f@plt>
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   1050 <glVertex2f@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11e8 <drawCheck+0xa8>
mov    $0x0,%al
call   1040 <glEnd@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1191 <drawCheck+0x51>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawCheck>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,0x10(%rsp)
test   %edi,%edi
jle    129c <drawCheck+0x15c>
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %edi,%r12d
cvtsi2sd %edi,%xmm0
movsd  0xe90(%rip),%xmm1
movapd %xmm1,%xmm2
divsd  %xmm0,%xmm2
cvtsd2ss %xmm2,%xmm2
mov    0x10(%rsp),%rax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x8(%rsp)
movss  %xmm2,0xc(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
movsd  %xmm0,0x28(%rsp)
lea    0x1(%rax),%ebp
xor    %r13d,%r13d
jmp    11d4 <drawCheck+0x94>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <glEnd@plt>
add    $0x1,%r13d
cmp    %r12d,%r13d
je     129c <drawCheck+0x15c>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1060 <glBegin@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %r13d,%xmm0
mulss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xe09(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  %xmm1,0x18(%rsp)
cmpl   $0x0,0x10(%rsp)
movss  0x8(%rsp),%xmm1
js     11c0 <drawCheck+0x80>
movsd  0x18(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x20(%rsp)
mov    %r15d,%eax
xor    %r13d,%eax
test   $0x1,%al
mov    %rbx,%rdi
cmove  %r14,%rdi
call   1030 <glColor4fv@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1050 <glVertex2f@plt>
movsd  0x30(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1050 <glVertex2f@plt>
movss  0x8(%rsp),%xmm1
movsd  0xd7a(%rip),%xmm2
add    $0x1,%r15d
cmp    %r15d,%ebp
jne    1230 <drawCheck+0xf0>
jmp    11c0 <drawCheck+0x80>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GL_QUAD_STRIP = global i32 0
define void @drawCheck(i32 %0, i32 %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca float
%10 = alloca float
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store double* %2, double** %7
store double* %3, double** %8
%16 = load i32, i32* %5
%17 = sitofp i32 %16 to double
%18 = fdiv double 2.000000e+00, %17
%19 = fptrunc double %18 to float
store float %19, float* %9
%20 = load i32, i32* %6
%21 = sitofp i32 %20 to double
%22 = fdiv double 2.000000e+00, %21
%23 = fptrunc double %22 to float
store float %23, float* %10
store i32 0, i32* %11
br label %24
24: ; preds = %75, %4
%25 = load i32, i32* %11
%26 = load i32, i32* %5
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %78
28: ; preds = %24
%29 = load i32, i32* %11
%30 = sitofp i32 %29 to float
%31 = load float, float* %9
%32 = fmul float %30, %31
%33 = fpext float %32 to double
%34 = fadd double -1.000000e+00, %33
store double %34, double* %13
%35 = load double, double* %13
%36 = load float, float* %9
%37 = fpext float %36 to double
%38 = fadd double %35, %37
store double %38, double* %14
%39 = load i32, i32* @GL_QUAD_STRIP
%40 = call i32 @glBegin(i32 %39)
store i32 0, i32* %12
br label %41
41: ; preds = %70, %28
%42 = load i32, i32* %12
%43 = load i32, i32* %6
%44 = icmp sle i32 %42, %43
br i1 %44, label %45, label %73
45: ; preds = %41
%46 = load i32, i32* %12
%47 = sitofp i32 %46 to float
%48 = load float, float* %10
%49 = fmul float %47, %48
%50 = fpext float %49 to double
%51 = fadd double -1.000000e+00, %50
store double %51, double* %15
%52 = load i32, i32* %11
%53 = load i32, i32* %12
%54 = xor i32 %52, %53
%55 = and i32 %54, 1
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %45
%58 = load double*, double** %7
%59 = call i32 @glColor4fv(double* %58)
br label %63
60: ; preds = %45
%61 = load double*, double** %8
%62 = call i32 @glColor4fv(double* %61)
br label %63
63: ; preds = %60, %57
%64 = load double, double* %13
%65 = load double, double* %15
%66 = call i32 @glVertex2f(double %64, double %65)
%67 = load double, double* %14
%68 = load double, double* %15
%69 = call i32 @glVertex2f(double %67, double %68)
br label %70
70: ; preds = %63
%71 = load i32, i32* %12
%72 = add nsw i32 %71, 1
store i32 %72, i32* %12
br label %41
73: ; preds = %41
%74 = call i32 (...) @glEnd()
br label %75
75: ; preds = %73
%76 = load i32, i32* %11
%77 = add nsw i32 %76, 1
store i32 %77, i32* %11
br label %24
78: ; preds = %24
ret void
}

LLVM IR (-O2):
@GL_QUAD_STRIP = global i32 0
define void @drawCheck(i32 %0, i32 %1, double* %2, double* %3) {
%5 = sitofp i32 %0 to double
%6 = fdiv double 2.000000e+00, %5
%7 = fptrunc double %6 to float
%8 = sitofp i32 %1 to double
%9 = fdiv double 2.000000e+00, %8
%10 = fptrunc double %9 to float
%11 = icmp sgt i32 %0, 0
br i1 %11, label %12, label %43
12: ; preds = %4
%13 = fpext float %7 to double
%14 = icmp slt i32 %1, 0
br label %15
15: ; preds = %12, %39
%16 = phi i32 [ 0, %12 ], [ %41, %39 ]
%17 = sitofp i32 %16 to float
%18 = fmul float %7, %17
%19 = fpext float %18 to double
%20 = fadd double %19, -1.000000e+00
%21 = fadd double %20, %13
%22 = load i32, i32* @GL_QUAD_STRIP
%23 = tail call i32 @glBegin(i32 %22)
br i1 %14, label %39, label %24
24: ; preds = %15, %24
%25 = phi i32 [ %37, %24 ], [ 0, %15 ]
%26 = sitofp i32 %25 to float
%27 = fmul float %10, %26
%28 = fpext float %27 to double
%29 = fadd double %28, -1.000000e+00
%30 = xor i32 %25, %16
%31 = and i32 %30, 1
%32 = icmp eq i32 %31, 0
%33 = select i1 %32, double* %3, double* %2
%34 = tail call i32 @glColor4fv(double* %33)
%35 = tail call i32 @glVertex2f(double %20, double %29)
%36 = tail call i32 @glVertex2f(double %21, double %29)
%37 = add nuw i32 %25, 1
%38 = icmp eq i32 %25, %1
br i1 %38, label %39, label %24
39: ; preds = %24, %15
%40 = tail call i32 (...) @glEnd()
%41 = add nuw nsw i32 %16, 1
%42 = icmp eq i32 %41, %0
br i1 %42, label %43, label %15
43: ; preds = %39, %4
ret void
}