#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*/ GLsizei;
typedef double GLfloat;

/* Variables and functions */
int /*<<< orphan*/ GL_ALWAYS;
int /*<<< orphan*/ GL_MODELVIEW;
int /*<<< orphan*/ GL_PROJECTION;
int /*<<< orphan*/ GL_QUADS;
int /*<<< orphan*/ GL_REPLACE;
int /*<<< orphan*/ GL_STENCIL_BUFFER_BIT;
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glClear(int /*<<< orphan*/);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glLoadIdentity();
int /*<<< orphan*/ glMatrixMode(int /*<<< orphan*/);
int /*<<< orphan*/ glStencilFunc(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ glStencilOp(int /*<<< orphan*/, int /*<<< orphan*/,
                               int /*<<< orphan*/);
int /*<<< orphan*/ glTranslatef(double, double, double);
int /*<<< orphan*/ glVertex2f(double, double);
int /*<<< orphan*/ glViewport(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ gluOrtho2D(double, double, double, double);
int /*<<< orphan*/ gluPerspective(double, double, double, double);
void stencil_reshape(int w, int h) {
  glViewport(0, 0, (GLsizei)w, (GLsizei)h);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  if (w <= h) {
    gluOrtho2D(-3.0, 3.0, -3.0 * (GLfloat)h / (GLfloat)w,
               3.0 * (GLfloat)h / (GLfloat)w);
  } else {
    gluOrtho2D(-3.0 * (GLfloat)h / (GLfloat)w, 3.0 * (GLfloat)h / (GLfloat)w,
               -3.0, 3.0);
  }
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glClear(GL_STENCIL_BUFFER_BIT);
  glStencilFunc(GL_ALWAYS, 0x1, 0x1);
  glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
  glBegin(GL_QUADS);
  glVertex2f(-1.0, 0.0);
  glVertex2f(0.0, 1.0);
  glVertex2f(1.0, 0.0);
  glVertex2f(0.0, -1.0);
  glEnd();
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(45.0, (GLfloat)w / (GLfloat)h, 3.0, 7.0);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glTranslatef(0.0, 0.0, -5.0);
}


x86 assembly (clang, -O0):
<stencil_reshape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
mov    %esi,%edi
call   10e0 <glViewport@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
call   1050 <glMatrixMode@plt>
mov    $0x0,%al
call   1080 <glLoadIdentity@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     124c <stencil_reshape+0x8c>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xdf5(%rip),%xmm2
mulsd  %xmm0,%xmm2
cvtsi2sdl -0x4(%rbp),%xmm0
divsd  %xmm0,%xmm2
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xde3(%rip),%xmm3
mulsd  %xmm0,%xmm3
cvtsi2sdl -0x4(%rbp),%xmm0
divsd  %xmm0,%xmm3
movsd  0xdc6(%rip),%xmm0
movsd  0xdc6(%rip),%xmm1
call   10b0 <gluOrtho2D@plt>
jmp    1295 <stencil_reshape+0xd5>
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xda7(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm2
movsd  0xd95(%rip),%xmm1
mulsd  %xmm2,%xmm1
cvtsi2sdl -0x4(%rbp),%xmm2
divsd  %xmm2,%xmm1
movsd  0xd78(%rip),%xmm2
movsd  0xd78(%rip),%xmm3
call   10b0 <gluOrtho2D@plt>
mov    0x2d44(%rip),%rax
mov    (%rax),%edi
call   1050 <glMatrixMode@plt>
mov    $0x0,%al
call   1080 <glLoadIdentity@plt>
mov    0x2d1f(%rip),%rax
mov    (%rax),%edi
call   1040 <glClear@plt>
mov    0x2d01(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%edx
mov    %edx,%esi
call   10a0 <glStencilFunc@plt>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
mov    0x2ceb(%rip),%rax
mov    (%rax),%esi
mov    0x2ce2(%rip),%rax
mov    (%rax),%edx
call   1030 <glStencilOp@plt>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
call   10d0 <glBegin@plt>
movsd  0xd25(%rip),%xmm0
xorps  %xmm1,%xmm1
call   1090 <glVertex2f@plt>
xorps  %xmm0,%xmm0
movsd  0xd1a(%rip),%xmm1
call   1090 <glVertex2f@plt>
movsd  0xd0d(%rip),%xmm0
xorps  %xmm1,%xmm1
call   1090 <glVertex2f@plt>
xorps  %xmm0,%xmm0
movsd  0xcf2(%rip),%xmm1
call   1090 <glVertex2f@plt>
mov    $0x0,%al
call   1060 <glEnd@plt>
mov    0x2c6f(%rip),%rax
mov    (%rax),%edi
call   1050 <glMatrixMode@plt>
mov    $0x0,%al
call   1080 <glLoadIdentity@plt>
cvtsi2sdl -0x4(%rbp),%xmm1
cvtsi2sdl -0x8(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xcab(%rip),%xmm0
movsd  0xc93(%rip),%xmm2
movsd  0xca3(%rip),%xmm3
call   1070 <gluPerspective@plt>
mov    0x2c57(%rip),%rax
mov    (%rax),%edi
call   1050 <glMatrixMode@plt>
mov    $0x0,%al
call   1080 <glLoadIdentity@plt>
xorps  %xmm1,%xmm1
movsd  0xc6e(%rip),%xmm2
movaps %xmm1,%xmm0
call   10c0 <glTranslatef@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stencil_reshape>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
xor    %esi,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   10e0 <glViewport@plt>
mov    0x2dd8(%rip),%r14
mov    (%r14),%edi
call   1050 <glMatrixMode@plt>
xor    %eax,%eax
call   1080 <glLoadIdentity@plt>
cvtsi2sd %ebx,%xmm1
movsd  0xe05(%rip),%xmm4
mulsd  %xmm1,%xmm4
cvtsi2sd %ebp,%xmm0
divsd  %xmm0,%xmm4
movsd  0xdf9(%rip),%xmm5
movsd  %xmm1,(%rsp)
mulsd  %xmm1,%xmm5
movsd  %xmm0,0x8(%rsp)
divsd  %xmm0,%xmm5
cmp    %ebx,%ebp
jle    1240 <stencil_reshape+0x80>
movsd  0xdd2(%rip),%xmm2
movsd  0xdd2(%rip),%xmm3
movapd %xmm4,%xmm0
movapd %xmm5,%xmm1
jmp    1258 <stencil_reshape+0x98>
movsd  0xdb8(%rip),%xmm0
movsd  0xdb8(%rip),%xmm1
movapd %xmm4,%xmm2
movapd %xmm5,%xmm3
call   10b0 <gluOrtho2D@plt>
mov    0x2d7c(%rip),%rbx
mov    (%rbx),%edi
call   1050 <glMatrixMode@plt>
xor    %eax,%eax
call   1080 <glLoadIdentity@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
call   1040 <glClear@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   10a0 <glStencilFunc@plt>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
mov    %edi,%esi
mov    %edi,%edx
call   1030 <glStencilOp@plt>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
call   10d0 <glBegin@plt>
movsd  0xd50(%rip),%xmm0
xorpd  %xmm1,%xmm1
call   1090 <glVertex2f@plt>
movsd  0xd47(%rip),%xmm1
xorps  %xmm0,%xmm0
call   1090 <glVertex2f@plt>
xorps  %xmm1,%xmm1
movsd  0xd34(%rip),%xmm0
call   1090 <glVertex2f@plt>
xorps  %xmm0,%xmm0
movsd  0xd1c(%rip),%xmm1
call   1090 <glVertex2f@plt>
xor    %eax,%eax
call   1060 <glEnd@plt>
mov    (%r14),%edi
call   1050 <glMatrixMode@plt>
xor    %eax,%eax
call   1080 <glLoadIdentity@plt>
movsd  0x8(%rsp),%xmm1
divsd  (%rsp),%xmm1
movsd  0xcfe(%rip),%xmm0
movsd  0xcde(%rip),%xmm2
movsd  0xcf6(%rip),%xmm3
call   1070 <gluPerspective@plt>
mov    (%rbx),%edi
call   1050 <glMatrixMode@plt>
xor    %eax,%eax
call   1080 <glLoadIdentity@plt>
movsd  0xce3(%rip),%xmm2
xorps  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    10c0 <glTranslatef@plt>

LLVM IR (-O0):
@GL_PROJECTION = global i32 0
@GL_MODELVIEW = global i32 0
@GL_STENCIL_BUFFER_BIT = global i32 0
@GL_ALWAYS = global i32 0
@GL_REPLACE = global i32 0
@GL_QUADS = global i32 0
define void @stencil_reshape(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* %4
%7 = call i32 @glViewport(i32 0, i32 0, i32 %5, i32 %6)
%8 = load i32, i32* @GL_PROJECTION
%9 = call i32 @glMatrixMode(i32 %8)
%10 = call i32 (...) @glLoadIdentity()
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %28
14: ; preds = %2
%15 = load i32, i32* %4
%16 = sitofp i32 %15 to double
%17 = fmul double -3.000000e+00, %16
%18 = load i32, i32* %3
%19 = sitofp i32 %18 to double
%20 = fdiv double %17, %19
%21 = load i32, i32* %4
%22 = sitofp i32 %21 to double
%23 = fmul double 3.000000e+00, %22
%24 = load i32, i32* %3
%25 = sitofp i32 %24 to double
%26 = fdiv double %23, %25
%27 = call i32 @gluOrtho2D(double -3.000000e+00, double 3.000000e+00, double %20, double %26)
br label %42
28: ; preds = %2
%29 = load i32, i32* %4
%30 = sitofp i32 %29 to double
%31 = fmul double -3.000000e+00, %30
%32 = load i32, i32* %3
%33 = sitofp i32 %32 to double
%34 = fdiv double %31, %33
%35 = load i32, i32* %4
%36 = sitofp i32 %35 to double
%37 = fmul double 3.000000e+00, %36
%38 = load i32, i32* %3
%39 = sitofp i32 %38 to double
%40 = fdiv double %37, %39
%41 = call i32 @gluOrtho2D(double %34, double %40, double -3.000000e+00, double 3.000000e+00)
br label %42
42: ; preds = %28, %14
%43 = load i32, i32* @GL_MODELVIEW
%44 = call i32 @glMatrixMode(i32 %43)
%45 = call i32 (...) @glLoadIdentity()
%46 = load i32, i32* @GL_STENCIL_BUFFER_BIT
%47 = call i32 @glClear(i32 %46)
%48 = load i32, i32* @GL_ALWAYS
%49 = call i32 @glStencilFunc(i32 %48, i32 1, i32 1)
%50 = load i32, i32* @GL_REPLACE
%51 = load i32, i32* @GL_REPLACE
%52 = load i32, i32* @GL_REPLACE
%53 = call i32 @glStencilOp(i32 %50, i32 %51, i32 %52)
%54 = load i32, i32* @GL_QUADS
%55 = call i32 @glBegin(i32 %54)
%56 = call i32 @glVertex2f(double -1.000000e+00, double 0.000000e+00)
%57 = call i32 @glVertex2f(double 0.000000e+00, double 1.000000e+00)
%58 = call i32 @glVertex2f(double 1.000000e+00, double 0.000000e+00)
%59 = call i32 @glVertex2f(double 0.000000e+00, double -1.000000e+00)
%60 = call i32 (...) @glEnd()
%61 = load i32, i32* @GL_PROJECTION
%62 = call i32 @glMatrixMode(i32 %61)
%63 = call i32 (...) @glLoadIdentity()
%64 = load i32, i32* %3
%65 = sitofp i32 %64 to double
%66 = load i32, i32* %4
%67 = sitofp i32 %66 to double
%68 = fdiv double %65, %67
%69 = call i32 @gluPerspective(double 4.500000e+01, double %68, double 3.000000e+00, double 7.000000e+00)
%70 = load i32, i32* @GL_MODELVIEW
%71 = call i32 @glMatrixMode(i32 %70)
%72 = call i32 (...) @glLoadIdentity()
%73 = call i32 @glTranslatef(double 0.000000e+00, double 0.000000e+00, double -5.000000e+00)
ret void
}

LLVM IR (-O2):
@GL_PROJECTION = global i32 0
@GL_MODELVIEW = global i32 0
@GL_STENCIL_BUFFER_BIT = global i32 0
@GL_ALWAYS = global i32 0
@GL_REPLACE = global i32 0
@GL_QUADS = global i32 0
define void @stencil_reshape(i32 %0, i32 %1) {
%3 = tail call i32 @glViewport(i32 0, i32 0, i32 %0, i32 %1)
%4 = load i32, i32* @GL_PROJECTION
%5 = tail call i32 @glMatrixMode(i32 %4)
%6 = tail call i32 (...) @glLoadIdentity()
%7 = icmp sgt i32 %0, %1
%8 = sitofp i32 %1 to double
%9 = fmul double %8, -3.000000e+00
%10 = sitofp i32 %0 to double
%11 = fdiv double %9, %10
%12 = fmul double %8, 3.000000e+00
%13 = fdiv double %12, %10
br i1 %7, label %16, label %14
14: ; preds = %2
%15 = tail call i32 @gluOrtho2D(double -3.000000e+00, double 3.000000e+00, double %11, double %13)
br label %18
16: ; preds = %2
%17 = tail call i32 @gluOrtho2D(double %11, double %13, double -3.000000e+00, double 3.000000e+00)
br label %18
18: ; preds = %16, %14
%19 = load i32, i32* @GL_MODELVIEW
%20 = tail call i32 @glMatrixMode(i32 %19)
%21 = tail call i32 (...) @glLoadIdentity()
%22 = load i32, i32* @GL_STENCIL_BUFFER_BIT
%23 = tail call i32 @glClear(i32 %22)
%24 = load i32, i32* @GL_ALWAYS
%25 = tail call i32 @glStencilFunc(i32 %24, i32 1, i32 1)
%26 = load i32, i32* @GL_REPLACE
%27 = tail call i32 @glStencilOp(i32 %26, i32 %26, i32 %26)
%28 = load i32, i32* @GL_QUADS
%29 = tail call i32 @glBegin(i32 %28)
%30 = tail call i32 @glVertex2f(double -1.000000e+00, double 0.000000e+00)
%31 = tail call i32 @glVertex2f(double 0.000000e+00, double 1.000000e+00)
%32 = tail call i32 @glVertex2f(double 1.000000e+00, double 0.000000e+00)
%33 = tail call i32 @glVertex2f(double 0.000000e+00, double -1.000000e+00)
%34 = tail call i32 (...) @glEnd()
%35 = load i32, i32* @GL_PROJECTION
%36 = tail call i32 @glMatrixMode(i32 %35)
%37 = tail call i32 (...) @glLoadIdentity()
%38 = fdiv double %10, %8
%39 = tail call i32 @gluPerspective(double 4.500000e+01, double %38, double 3.000000e+00, double 7.000000e+00)
%40 = load i32, i32* @GL_MODELVIEW
%41 = tail call i32 @glMatrixMode(i32 %40)
%42 = tail call i32 (...) @glLoadIdentity()
%43 = tail call i32 @glTranslatef(double 0.000000e+00, double 0.000000e+00, double -5.000000e+00)
ret void
}