#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*/ GLenum;

/* Variables and functions */
int /*<<< orphan*/ GL_ALWAYS;
int /*<<< orphan*/ GL_BACK;
int /*<<< orphan*/ GL_DECR;
int /*<<< orphan*/ GL_DEPTH_TEST;
int /*<<< orphan*/ GL_FALSE;
int /*<<< orphan*/ GL_FRONT;
int /*<<< orphan*/ GL_INCR;
int /*<<< orphan*/ GL_KEEP;
int /*<<< orphan*/ GL_STENCIL_TEST;
int /*<<< orphan*/ GL_TRUE;
int /*<<< orphan*/ glColorMask(int /*<<< orphan*/, int /*<<< orphan*/,
                               int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ glCullFace(int /*<<< orphan*/);
int /*<<< orphan*/ glDepthMask(int /*<<< orphan*/);
int /*<<< orphan*/ glDisable(int /*<<< orphan*/);
int /*<<< orphan*/ glEnable(int /*<<< orphan*/);
int /*<<< orphan*/ glStencilFunc(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ glStencilOp(int /*<<< orphan*/, int /*<<< orphan*/,
                               int /*<<< orphan*/);
void firstInsideSecond(void (*a)(void), void (*b)(void), GLenum face,
                       GLenum test) {
  glEnable(GL_DEPTH_TEST);
  glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
  glCullFace(face);
  a();
  glDepthMask(GL_FALSE);
  glEnable(GL_STENCIL_TEST);
  glStencilFunc(GL_ALWAYS, 0, 0);
  glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
  glCullFace(GL_BACK);
  b();
  glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
  glCullFace(GL_FRONT);
  b();
  glDepthMask(GL_TRUE);
  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
  glStencilFunc(test, 0, 1);
  glDisable(GL_DEPTH_TEST);
  glCullFace(face);
  a();
}


x86 assembly (clang, -O0):
<firstInsideSecond>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
call   1040 <glEnable@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
mov    0x2e3c(%rip),%rax
mov    (%rax),%esi
mov    0x2e33(%rip),%rax
mov    (%rax),%edx
mov    0x2e2a(%rip),%rax
mov    (%rax),%ecx
call   1070 <glColorMask@plt>
mov    -0x14(%rbp),%edi
call   1090 <glCullFace@plt>
call   *-0x8(%rbp)
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
call   1050 <glDepthMask@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
call   1040 <glEnable@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1060 <glStencilFunc@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
mov    0x2dd2(%rip),%rax
mov    (%rax),%esi
mov    0x2db9(%rip),%rax
mov    (%rax),%edx
call   1030 <glStencilOp@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
call   1090 <glCullFace@plt>
call   *-0x10(%rbp)
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
mov    0x2d58(%rip),%rax
mov    (%rax),%edx
call   1030 <glStencilOp@plt>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
call   1090 <glCullFace@plt>
call   *-0x10(%rbp)
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
call   1050 <glDepthMask@plt>
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
mov    0x2d4a(%rip),%rax
mov    (%rax),%esi
mov    0x2d41(%rip),%rax
mov    (%rax),%edx
mov    0x2d38(%rip),%rax
mov    (%rax),%ecx
call   1070 <glColorMask@plt>
mov    -0x18(%rbp),%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <glStencilFunc@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
call   1080 <glDisable@plt>
mov    -0x14(%rbp),%edi
call   1090 <glCullFace@plt>
call   *-0x8(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<firstInsideSecond>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %rdi,%r13
mov    0x2e12(%rip),%r15
mov    (%r15),%edi
call   1040 <glEnable@plt>
mov    0x2e43(%rip),%rbx
mov    (%rbx),%ecx
mov    %ecx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
call   1070 <glColorMask@plt>
mov    %r12d,%edi
call   1090 <glCullFace@plt>
call   *%r13
mov    (%rbx),%edi
call   1050 <glDepthMask@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
call   1040 <glEnable@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <glStencilFunc@plt>
mov    0x2df5(%rip),%rbx
mov    (%rbx),%edi
mov    0x2ddc(%rip),%rax
mov    (%rax),%edx
mov    %edi,%esi
call   1030 <glStencilOp@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
call   1090 <glCullFace@plt>
call   *%rbp
mov    (%rbx),%edi
mov    0x2d8a(%rip),%rax
mov    (%rax),%edx
mov    %edi,%esi
call   1030 <glStencilOp@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1090 <glCullFace@plt>
call   *%rbp
mov    0x2d92(%rip),%rbx
mov    (%rbx),%edi
call   1050 <glDepthMask@plt>
mov    (%rbx),%ecx
mov    %ecx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
call   1070 <glColorMask@plt>
mov    %r14d,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <glStencilFunc@plt>
mov    (%r15),%edi
call   1080 <glDisable@plt>
mov    %r12d,%edi
call   1090 <glCullFace@plt>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    *%rax

LLVM IR (-O0):
@GL_DEPTH_TEST = global i32 0
@GL_FALSE = global i32 0
@GL_STENCIL_TEST = global i32 0
@GL_ALWAYS = global i32 0
@GL_KEEP = global i32 0
@GL_INCR = global i32 0
@GL_BACK = global i32 0
@GL_DECR = global i32 0
@GL_FRONT = global i32 0
@GL_TRUE = global i32 0
define void @firstInsideSecond(void ()* %0, void ()* %1, i32 %2, i32 %3) {
%5 = alloca void ()*
%6 = alloca void ()*
%7 = alloca i32
%8 = alloca i32
store void ()* %0, void ()** %5
store void ()* %1, void ()** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* @GL_DEPTH_TEST
%10 = call i32 @glEnable(i32 %9)
%11 = load i32, i32* @GL_FALSE
%12 = load i32, i32* @GL_FALSE
%13 = load i32, i32* @GL_FALSE
%14 = load i32, i32* @GL_FALSE
%15 = call i32 @glColorMask(i32 %11, i32 %12, i32 %13, i32 %14)
%16 = load i32, i32* %7
%17 = call i32 @glCullFace(i32 %16)
%18 = load void ()*, void ()** %5
%19 = load i32, i32* @GL_FALSE
%20 = call i32 @glDepthMask(i32 %19)
%21 = load i32, i32* @GL_STENCIL_TEST
%22 = call i32 @glEnable(i32 %21)
%23 = load i32, i32* @GL_ALWAYS
%24 = call i32 @glStencilFunc(i32 %23, i32 0, i32 0)
%25 = load i32, i32* @GL_KEEP
%26 = load i32, i32* @GL_KEEP
%27 = load i32, i32* @GL_INCR
%28 = call i32 @glStencilOp(i32 %25, i32 %26, i32 %27)
%29 = load i32, i32* @GL_BACK
%30 = call i32 @glCullFace(i32 %29)
%31 = load void ()*, void ()** %6
%32 = load i32, i32* @GL_KEEP
%33 = load i32, i32* @GL_KEEP
%34 = load i32, i32* @GL_DECR
%35 = call i32 @glStencilOp(i32 %32, i32 %33, i32 %34)
%36 = load i32, i32* @GL_FRONT
%37 = call i32 @glCullFace(i32 %36)
%38 = load void ()*, void ()** %6
%39 = load i32, i32* @GL_TRUE
%40 = call i32 @glDepthMask(i32 %39)
%41 = load i32, i32* @GL_TRUE
%42 = load i32, i32* @GL_TRUE
%43 = load i32, i32* @GL_TRUE
%44 = load i32, i32* @GL_TRUE
%45 = call i32 @glColorMask(i32 %41, i32 %42, i32 %43, i32 %44)
%46 = load i32, i32* %8
%47 = call i32 @glStencilFunc(i32 %46, i32 0, i32 1)
%48 = load i32, i32* @GL_DEPTH_TEST
%49 = call i32 @glDisable(i32 %48)
%50 = load i32, i32* %7
%51 = call i32 @glCullFace(i32 %50)
%52 = load void ()*, void ()** %5
ret void
}

LLVM IR (-O2):
@GL_DEPTH_TEST = global i32 0
@GL_FALSE = global i32 0
@GL_STENCIL_TEST = global i32 0
@GL_ALWAYS = global i32 0
@GL_KEEP = global i32 0
@GL_INCR = global i32 0
@GL_BACK = global i32 0
@GL_DECR = global i32 0
@GL_FRONT = global i32 0
@GL_TRUE = global i32 0
define void @firstInsideSecond(void ()* nocapture %0, void ()* nocapture %1, i32 %2, i32 %3) {
%5 = load i32, i32* @GL_DEPTH_TEST
%6 = tail call i32 @glEnable(i32 %5)
%7 = load i32, i32* @GL_FALSE
%8 = tail call i32 @glColorMask(i32 %7, i32 %7, i32 %7, i32 %7)
%9 = tail call i32 @glCullFace(i32 %2)
tail call void %0()
%10 = load i32, i32* @GL_FALSE
%11 = tail call i32 @glDepthMask(i32 %10)
%12 = load i32, i32* @GL_STENCIL_TEST
%13 = tail call i32 @glEnable(i32 %12)
%14 = load i32, i32* @GL_ALWAYS
%15 = tail call i32 @glStencilFunc(i32 %14, i32 0, i32 0)
%16 = load i32, i32* @GL_KEEP
%17 = load i32, i32* @GL_INCR
%18 = tail call i32 @glStencilOp(i32 %16, i32 %16, i32 %17)
%19 = load i32, i32* @GL_BACK
%20 = tail call i32 @glCullFace(i32 %19)
tail call void %1()
%21 = load i32, i32* @GL_KEEP
%22 = load i32, i32* @GL_DECR
%23 = tail call i32 @glStencilOp(i32 %21, i32 %21, i32 %22)
%24 = load i32, i32* @GL_FRONT
%25 = tail call i32 @glCullFace(i32 %24)
tail call void %1()
%26 = load i32, i32* @GL_TRUE
%27 = tail call i32 @glDepthMask(i32 %26)
%28 = load i32, i32* @GL_TRUE
%29 = tail call i32 @glColorMask(i32 %28, i32 %28, i32 %28, i32 %28)
%30 = tail call i32 @glStencilFunc(i32 %3, i32 0, i32 1)
%31 = load i32, i32* @GL_DEPTH_TEST
%32 = tail call i32 @glDisable(i32 %31)
%33 = tail call i32 @glCullFace(i32 %2)
tail call void %0()
ret void
}