#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 GL_COLOR_BUFFER_BIT;
int GL_DEPTH_BUFFER_BIT;
int /*<<< orphan*/ GL_EQUAL;
int /*<<< orphan*/ GL_KEEP;
int /*<<< orphan*/ GL_NOTEQUAL;
int /*<<< orphan*/ glCallList(int);
int /*<<< orphan*/ glClear(int);
int /*<<< orphan*/ glPopMatrix();
int /*<<< orphan*/ glPushMatrix();
int /*<<< orphan*/ glRotatef(double, double, double, double);
int /*<<< orphan*/ glStencilFunc(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ glStencilOp(int /*<<< orphan*/, int /*<<< orphan*/,
                               int /*<<< orphan*/);
int /*<<< orphan*/ glutSolidSphere(double, int, int);
int /*<<< orphan*/ glutSolidTorus(double, double, int, int);
void stencil_display(void) {
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glStencilFunc(GL_EQUAL, 0x1, 0x1);
  glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
  glCallList(2);
  glutSolidSphere(0.5, 15, 15);
  glStencilFunc(GL_NOTEQUAL, 0x1, 0x1);
  glPushMatrix();
  glRotatef(45.0, 0.0, 0.0, 1.0);
  glRotatef(45.0, 0.0, 1.0, 0.0);
  glCallList(1);
  glutSolidTorus(0.275, 0.85, 15, 15);
  glPushMatrix();
  glRotatef(90.0, 1.0, 0.0, 0.0);
  glutSolidTorus(0.275, 0.85, 15, 15);
  glPopMatrix();
  glPopMatrix();
}


x86 assembly (clang, -O0):
<stencil_display>:
push   %rbp
mov    %rsp,%rbp
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    0x2e34(%rip),%rax
or     (%rax),%edi
call   1040 <glClear@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1090 <glStencilFunc@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
mov    0x2e0f(%rip),%rax
mov    (%rax),%edx
call   1030 <glStencilOp@plt>
mov    $0x2,%edi
call   1070 <glCallList@plt>
movsd  0xe36(%rip),%xmm0
mov    $0xf,%esi
mov    %esi,%edi
call   1080 <glutSolidSphere@plt>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1090 <glStencilFunc@plt>
mov    $0x0,%al
call   1060 <glPushMatrix@plt>
movsd  0xdfe(%rip),%xmm0
xorps  %xmm2,%xmm2
movsd  0xdeb(%rip),%xmm3
movaps %xmm2,%xmm1
call   10a0 <glRotatef@plt>
movsd  0xde3(%rip),%xmm0
xorps  %xmm3,%xmm3
movsd  0xdd0(%rip),%xmm2
movaps %xmm3,%xmm1
call   10a0 <glRotatef@plt>
mov    $0x1,%edi
call   1070 <glCallList@plt>
movsd  0xd9e(%rip),%xmm0
movsd  0xd9e(%rip),%xmm1
mov    $0xf,%esi
mov    %esi,%edi
call   10b0 <glutSolidTorus@plt>
mov    $0x0,%al
call   1060 <glPushMatrix@plt>
movsd  0xd8b(%rip),%xmm0
movsd  0xd8b(%rip),%xmm1
xorps  %xmm3,%xmm3
movaps %xmm3,%xmm2
call   10a0 <glRotatef@plt>
movsd  0xd60(%rip),%xmm0
movsd  0xd60(%rip),%xmm1
mov    $0xf,%esi
mov    %esi,%edi
call   10b0 <glutSolidTorus@plt>
mov    $0x0,%al
call   1050 <glPopMatrix@plt>
mov    $0x0,%al
call   1050 <glPopMatrix@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<stencil_display>:
push   %rax
mov    0x2e28(%rip),%rax
mov    0x2e39(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
call   1040 <glClear@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1090 <glStencilFunc@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
mov    %edi,%esi
mov    %edi,%edx
call   1030 <glStencilOp@plt>
mov    $0x2,%edi
call   1070 <glCallList@plt>
movsd  0xe1c(%rip),%xmm0
mov    $0xf,%edi
mov    $0xf,%esi
call   1080 <glutSolidSphere@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1090 <glStencilFunc@plt>
xor    %eax,%eax
call   1060 <glPushMatrix@plt>
movsd  0xdee(%rip),%xmm0
movsd  0xdee(%rip),%xmm3
xorps  %xmm1,%xmm1
xorps  %xmm2,%xmm2
call   10a0 <glRotatef@plt>
xorps  %xmm1,%xmm1
xorps  %xmm3,%xmm3
movsd  0xdcd(%rip),%xmm0
movsd  0xdcd(%rip),%xmm2
call   10a0 <glRotatef@plt>
mov    $0x1,%edi
call   1070 <glCallList@plt>
movsd  0xdbe(%rip),%xmm0
movsd  0xdbe(%rip),%xmm1
mov    $0xf,%edi
mov    $0xf,%esi
call   10b0 <glutSolidTorus@plt>
xor    %eax,%eax
call   1060 <glPushMatrix@plt>
movsd  0xda8(%rip),%xmm0
xorps  %xmm2,%xmm2
xorps  %xmm3,%xmm3
movsd  0xd82(%rip),%xmm1
call   10a0 <glRotatef@plt>
movsd  0xd7d(%rip),%xmm0
movsd  0xd7d(%rip),%xmm1
mov    $0xf,%edi
mov    $0xf,%esi
call   10b0 <glutSolidTorus@plt>
xor    %eax,%eax
call   1050 <glPopMatrix@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <glPopMatrix@plt>

LLVM IR (-O0):
@GL_COLOR_BUFFER_BIT = global i32 0
@GL_DEPTH_BUFFER_BIT = global i32 0
@GL_EQUAL = global i32 0
@GL_KEEP = global i32 0
@GL_NOTEQUAL = global i32 0
define void @stencil_display() {
%1 = load i32, i32* @GL_COLOR_BUFFER_BIT
%2 = load i32, i32* @GL_DEPTH_BUFFER_BIT
%3 = or i32 %1, %2
%4 = call i32 @glClear(i32 %3)
%5 = load i32, i32* @GL_EQUAL
%6 = call i32 @glStencilFunc(i32 %5, i32 1, i32 1)
%7 = load i32, i32* @GL_KEEP
%8 = load i32, i32* @GL_KEEP
%9 = load i32, i32* @GL_KEEP
%10 = call i32 @glStencilOp(i32 %7, i32 %8, i32 %9)
%11 = call i32 @glCallList(i32 2)
%12 = call i32 @glutSolidSphere(double 5.000000e-01, i32 15, i32 15)
%13 = load i32, i32* @GL_NOTEQUAL
%14 = call i32 @glStencilFunc(i32 %13, i32 1, i32 1)
%15 = call i32 (...) @glPushMatrix()
%16 = call i32 @glRotatef(double 4.500000e+01, double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%17 = call i32 @glRotatef(double 4.500000e+01, double 0.000000e+00, double 1.000000e+00, double 0.000000e+00)
%18 = call i32 @glCallList(i32 1)
%19 = call i32 @glutSolidTorus(double 2.750000e-01, double 8.500000e-01, i32 15, i32 15)
%20 = call i32 (...) @glPushMatrix()
%21 = call i32 @glRotatef(double 9.000000e+01, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
%22 = call i32 @glutSolidTorus(double 2.750000e-01, double 8.500000e-01, i32 15, i32 15)
%23 = call i32 (...) @glPopMatrix()
%24 = call i32 (...) @glPopMatrix()
ret void
}

LLVM IR (-O2):
@GL_COLOR_BUFFER_BIT = global i32 0
@GL_DEPTH_BUFFER_BIT = global i32 0
@GL_EQUAL = global i32 0
@GL_KEEP = global i32 0
@GL_NOTEQUAL = global i32 0
define void @stencil_display() {
%1 = load i32, i32* @GL_COLOR_BUFFER_BIT
%2 = load i32, i32* @GL_DEPTH_BUFFER_BIT
%3 = or i32 %2, %1
%4 = tail call i32 @glClear(i32 %3)
%5 = load i32, i32* @GL_EQUAL
%6 = tail call i32 @glStencilFunc(i32 %5, i32 1, i32 1)
%7 = load i32, i32* @GL_KEEP
%8 = tail call i32 @glStencilOp(i32 %7, i32 %7, i32 %7)
%9 = tail call i32 @glCallList(i32 2)
%10 = tail call i32 @glutSolidSphere(double 5.000000e-01, i32 15, i32 15)
%11 = load i32, i32* @GL_NOTEQUAL
%12 = tail call i32 @glStencilFunc(i32 %11, i32 1, i32 1)
%13 = tail call i32 (...) @glPushMatrix()
%14 = tail call i32 @glRotatef(double 4.500000e+01, double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%15 = tail call i32 @glRotatef(double 4.500000e+01, double 0.000000e+00, double 1.000000e+00, double 0.000000e+00)
%16 = tail call i32 @glCallList(i32 1)
%17 = tail call i32 @glutSolidTorus(double 2.750000e-01, double 8.500000e-01, i32 15, i32 15)
%18 = tail call i32 (...) @glPushMatrix()
%19 = tail call i32 @glRotatef(double 9.000000e+01, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
%20 = tail call i32 @glutSolidTorus(double 2.750000e-01, double 8.500000e-01, i32 15, i32 15)
%21 = tail call i32 (...) @glPopMatrix()
%22 = tail call i32 (...) @glPopMatrix()
ret void
}