#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*/ GLubyte;
typedef int GLsizei;
typedef int /*<<< orphan*/ GLdouble;

/* Variables and functions */
int /*<<< orphan*/ GL_ALPHA;
int GL_CURRENT_BIT;
int GL_DEPTH_BUFFER_BIT;
int /*<<< orphan*/ GL_DEPTH_TEST;
int /*<<< orphan*/ GL_LUMINANCE;
int /*<<< orphan*/ GL_MODELVIEW;
int /*<<< orphan*/ GL_PACK_ALIGNMENT;
int /*<<< orphan*/ GL_PROJECTION;
int GL_STENCIL;
int /*<<< orphan*/ GL_STENCIL_TEST;
int GL_TRANSFORM_BIT;
int /*<<< orphan*/ GL_UNPACK_ALIGNMENT;
int /*<<< orphan*/ GL_UNSIGNED_BYTE;
int GL_VIEWPORT_BIT;
int /*<<< orphan*/ assert(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ glDisable(int /*<<< orphan*/);
int /*<<< orphan*/ glDrawPixels(int, int, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ glLoadIdentity();
int /*<<< orphan*/ glMatrixMode(int /*<<< orphan*/);
int /*<<< orphan*/ glOrtho(double, int /*<<< orphan*/, double,
                           int /*<<< orphan*/, double, double);
int /*<<< orphan*/ glPixelStorei(int /*<<< orphan*/, int);
int /*<<< orphan*/ glPopAttrib();
int /*<<< orphan*/ glPopMatrix();
int /*<<< orphan*/ glPushAttrib(int);
int /*<<< orphan*/ glPushMatrix();
int /*<<< orphan*/ glRasterPos2f(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ glReadPixels(int /*<<< orphan*/, int /*<<< orphan*/, int,
                                int, int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/ *);
int /*<<< orphan*/ glViewport(int /*<<< orphan*/, int /*<<< orphan*/, int, int);
scalar_t__ malloc(int);
void ShowAlphaBuffer(GLsizei winWidth, GLsizei winHeight) {
  GLubyte *alphaValues;
  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  glPixelStorei(GL_PACK_ALIGNMENT, 1);
  alphaValues = (GLubyte *)malloc(winWidth * winHeight * sizeof(GLubyte));
  assert(alphaValues);
  glReadPixels(0, 0, winWidth, winHeight, GL_ALPHA, GL_UNSIGNED_BYTE,
               alphaValues);
  glPushAttrib(GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL |
               GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();
  glOrtho(0.0, (GLdouble)winWidth, 0.0, (GLdouble)winHeight, -1.0, 1.0);
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();
  glViewport(0, 0, winWidth, winHeight);
  glDisable(GL_STENCIL_TEST);
  glDisable(GL_DEPTH_TEST);
  glRasterPos2f(0, 0);
  glDrawPixels(winWidth, winHeight, GL_LUMINANCE, GL_UNSIGNED_BYTE,
               alphaValues);
  glPopMatrix();
  glMatrixMode(GL_PROJECTION);
  glPopMatrix();
  free(alphaValues);
  glPopAttrib();
}


x86 assembly (clang, -O0):
<ShowAlphaBuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1070 <glPixelStorei@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1070 <glPixelStorei@plt>
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <assert@plt>
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    0x2d46(%rip),%rax
mov    (%rax),%r8d
mov    0x2d14(%rip),%rax
mov    (%rax),%r9d
mov    -0x10(%rbp),%rax
xor    %esi,%esi
mov    %esi,%edi
mov    %rax,(%rsp)
call   10d0 <glReadPixels@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
mov    0x2d38(%rip),%rax
or     (%rax),%edi
mov    0x2cff(%rip),%rax
or     (%rax),%edi
mov    0x2cfe(%rip),%rax
or     (%rax),%edi
mov    0x2d35(%rip),%rax
or     (%rax),%edi
call   1100 <glPushAttrib@plt>
mov    0x2cd7(%rip),%rax
mov    (%rax),%edi
call   1050 <glMatrixMode@plt>
mov    $0x0,%al
call   10c0 <glPushMatrix@plt>
mov    $0x0,%al
call   10b0 <glLoadIdentity@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
xorps  %xmm1,%xmm1
movsd  0xd21(%rip),%xmm2
movsd  0xd21(%rip),%xmm3
movaps %xmm1,%xmm0
call   1060 <glOrtho@plt>
mov    0x2cca(%rip),%rax
mov    (%rax),%edi
call   1050 <glMatrixMode@plt>
mov    $0x0,%al
call   10c0 <glPushMatrix@plt>
mov    $0x0,%al
call   10b0 <glLoadIdentity@plt>
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
mov    %esi,%edi
call   1120 <glViewport@plt>
mov    0x2c67(%rip),%rax
mov    (%rax),%edi
call   1110 <glDisable@plt>
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
call   1110 <glDisable@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1080 <glRasterPos2f@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x2c64(%rip),%rax
mov    (%rax),%edx
mov    0x2c2b(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%r8
call   1030 <glDrawPixels@plt>
mov    $0x0,%al
call   10a0 <glPopMatrix@plt>
mov    0x2c22(%rip),%rax
mov    (%rax),%edi
call   1050 <glMatrixMode@plt>
mov    $0x0,%al
call   10a0 <glPopMatrix@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
mov    $0x0,%al
call   10f0 <glPopAttrib@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShowAlphaBuffer>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1070 <glPixelStorei@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1070 <glPixelStorei@plt>
mov    %ebp,%edi
imul   %ebx,%edi
shl    $0x2,%edi
call   10e0 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1090 <assert@plt>
mov    0x2d53(%rip),%rax
mov    (%rax),%r8d
mov    0x2d21(%rip),%r15
mov    (%r15),%r9d
mov    %r14,(%rsp)
xor    %edi,%edi
xor    %esi,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   10d0 <glReadPixels@plt>
mov    0x2d76(%rip),%rax
mov    0x2d47(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
mov    0x2d0c(%rip),%rax
or     (%rax),%edi
mov    0x2d0b(%rip),%rax
or     (%rax),%edi
mov    0x2d42(%rip),%rax
or     (%rax),%edi
call   1100 <glPushAttrib@plt>
mov    0x2ce4(%rip),%r12
mov    (%r12),%edi
call   1050 <glMatrixMode@plt>
xor    %eax,%eax
call   10c0 <glPushMatrix@plt>
xor    %eax,%eax
call   10b0 <glLoadIdentity@plt>
movsd  0xd35(%rip),%xmm2
movsd  0xd35(%rip),%xmm3
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <glOrtho@plt>
mov    0x2cd7(%rip),%rax
mov    (%rax),%edi
call   1050 <glMatrixMode@plt>
xor    %eax,%eax
call   10c0 <glPushMatrix@plt>
xor    %eax,%eax
call   10b0 <glLoadIdentity@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1120 <glViewport@plt>
mov    0x2c76(%rip),%rax
mov    (%rax),%edi
call   1110 <glDisable@plt>
mov    0x2c58(%rip),%rax
mov    (%rax),%edi
call   1110 <glDisable@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1080 <glRasterPos2f@plt>
mov    0x2c79(%rip),%rax
mov    (%rax),%edx
mov    (%r15),%ecx
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r14,%r8
call   1030 <glDrawPixels@plt>
xor    %eax,%eax
call   10a0 <glPopMatrix@plt>
mov    (%r12),%edi
call   1050 <glMatrixMode@plt>
xor    %eax,%eax
call   10a0 <glPopMatrix@plt>
mov    %r14,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10f0 <glPopAttrib@plt>

LLVM IR (-O0):
@GL_UNPACK_ALIGNMENT = global i32 0
@GL_PACK_ALIGNMENT = global i32 0
@GL_ALPHA = global i32 0
@GL_UNSIGNED_BYTE = global i32 0
@GL_CURRENT_BIT = global i32 0
@GL_DEPTH_BUFFER_BIT = global i32 0
@GL_STENCIL = global i32 0
@GL_TRANSFORM_BIT = global i32 0
@GL_VIEWPORT_BIT = global i32 0
@GL_PROJECTION = global i32 0
@GL_MODELVIEW = global i32 0
@GL_STENCIL_TEST = global i32 0
@GL_DEPTH_TEST = global i32 0
@GL_LUMINANCE = global i32 0
define void @ShowAlphaBuffer(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* @GL_UNPACK_ALIGNMENT
%7 = call i32 @glPixelStorei(i32 %6, i32 1)
%8 = load i32, i32* @GL_PACK_ALIGNMENT
%9 = call i32 @glPixelStorei(i32 %8, i32 1)
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = mul nsw i32 %10, %11
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %5
%18 = load i32*, i32** %5
%19 = call i32 @assert(i32* %18)
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = load i32, i32* @GL_ALPHA
%23 = load i32, i32* @GL_UNSIGNED_BYTE
%24 = load i32*, i32** %5
%25 = call i32 @glReadPixels(i32 0, i32 0, i32 %20, i32 %21, i32 %22, i32 %23, i32* %24)
%26 = load i32, i32* @GL_CURRENT_BIT
%27 = load i32, i32* @GL_DEPTH_BUFFER_BIT
%28 = or i32 %26, %27
%29 = load i32, i32* @GL_STENCIL
%30 = or i32 %28, %29
%31 = load i32, i32* @GL_TRANSFORM_BIT
%32 = or i32 %30, %31
%33 = load i32, i32* @GL_VIEWPORT_BIT
%34 = or i32 %32, %33
%35 = call i32 @glPushAttrib(i32 %34)
%36 = load i32, i32* @GL_PROJECTION
%37 = call i32 @glMatrixMode(i32 %36)
%38 = call i32 (...) @glPushMatrix()
%39 = call i32 (...) @glLoadIdentity()
%40 = load i32, i32* %3
%41 = load i32, i32* %4
%42 = call i32 @glOrtho(double 0.000000e+00, i32 %40, double 0.000000e+00, i32 %41, double -1.000000e+00, double 1.000000e+00)
%43 = load i32, i32* @GL_MODELVIEW
%44 = call i32 @glMatrixMode(i32 %43)
%45 = call i32 (...) @glPushMatrix()
%46 = call i32 (...) @glLoadIdentity()
%47 = load i32, i32* %3
%48 = load i32, i32* %4
%49 = call i32 @glViewport(i32 0, i32 0, i32 %47, i32 %48)
%50 = load i32, i32* @GL_STENCIL_TEST
%51 = call i32 @glDisable(i32 %50)
%52 = load i32, i32* @GL_DEPTH_TEST
%53 = call i32 @glDisable(i32 %52)
%54 = call i32 @glRasterPos2f(i32 0, i32 0)
%55 = load i32, i32* %3
%56 = load i32, i32* %4
%57 = load i32, i32* @GL_LUMINANCE
%58 = load i32, i32* @GL_UNSIGNED_BYTE
%59 = load i32*, i32** %5
%60 = call i32 @glDrawPixels(i32 %55, i32 %56, i32 %57, i32 %58, i32* %59)
%61 = call i32 (...) @glPopMatrix()
%62 = load i32, i32* @GL_PROJECTION
%63 = call i32 @glMatrixMode(i32 %62)
%64 = call i32 (...) @glPopMatrix()
%65 = load i32*, i32** %5
%66 = call i32 @free(i32* %65)
%67 = call i32 (...) @glPopAttrib()
ret void
}

LLVM IR (-O2):
@GL_UNPACK_ALIGNMENT = global i32 0
@GL_PACK_ALIGNMENT = global i32 0
@GL_ALPHA = global i32 0
@GL_UNSIGNED_BYTE = global i32 0
@GL_CURRENT_BIT = global i32 0
@GL_DEPTH_BUFFER_BIT = global i32 0
@GL_STENCIL = global i32 0
@GL_TRANSFORM_BIT = global i32 0
@GL_VIEWPORT_BIT = global i32 0
@GL_PROJECTION = global i32 0
@GL_MODELVIEW = global i32 0
@GL_STENCIL_TEST = global i32 0
@GL_DEPTH_TEST = global i32 0
@GL_LUMINANCE = global i32 0
define void @ShowAlphaBuffer(i32 %0, i32 %1) {
%3 = load i32, i32* @GL_UNPACK_ALIGNMENT
%4 = tail call i32 @glPixelStorei(i32 %3, i32 1)
%5 = load i32, i32* @GL_PACK_ALIGNMENT
%6 = tail call i32 @glPixelStorei(i32 %5, i32 1)
%7 = shl i32 %0, 2
%8 = mul i32 %7, %1
%9 = tail call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i32*
%11 = tail call i32 @assert(i32* %10)
%12 = load i32, i32* @GL_ALPHA
%13 = load i32, i32* @GL_UNSIGNED_BYTE
%14 = tail call i32 @glReadPixels(i32 0, i32 0, i32 %0, i32 %1, i32 %12, i32 %13, i32* %10)
%15 = load i32, i32* @GL_CURRENT_BIT
%16 = load i32, i32* @GL_DEPTH_BUFFER_BIT
%17 = or i32 %16, %15
%18 = load i32, i32* @GL_STENCIL
%19 = or i32 %17, %18
%20 = load i32, i32* @GL_TRANSFORM_BIT
%21 = or i32 %19, %20
%22 = load i32, i32* @GL_VIEWPORT_BIT
%23 = or i32 %21, %22
%24 = tail call i32 @glPushAttrib(i32 %23)
%25 = load i32, i32* @GL_PROJECTION
%26 = tail call i32 @glMatrixMode(i32 %25)
%27 = tail call i32 (...) @glPushMatrix()
%28 = tail call i32 (...) @glLoadIdentity()
%29 = tail call i32 @glOrtho(double 0.000000e+00, i32 %0, double 0.000000e+00, i32 %1, double -1.000000e+00, double 1.000000e+00)
%30 = load i32, i32* @GL_MODELVIEW
%31 = tail call i32 @glMatrixMode(i32 %30)
%32 = tail call i32 (...) @glPushMatrix()
%33 = tail call i32 (...) @glLoadIdentity()
%34 = tail call i32 @glViewport(i32 0, i32 0, i32 %0, i32 %1)
%35 = load i32, i32* @GL_STENCIL_TEST
%36 = tail call i32 @glDisable(i32 %35)
%37 = load i32, i32* @GL_DEPTH_TEST
%38 = tail call i32 @glDisable(i32 %37)
%39 = tail call i32 @glRasterPos2f(i32 0, i32 0)
%40 = load i32, i32* @GL_LUMINANCE
%41 = load i32, i32* @GL_UNSIGNED_BYTE
%42 = tail call i32 @glDrawPixels(i32 %0, i32 %1, i32 %40, i32 %41, i32* %10)
%43 = tail call i32 (...) @glPopMatrix()
%44 = load i32, i32* @GL_PROJECTION
%45 = tail call i32 @glMatrixMode(i32 %44)
%46 = tail call i32 (...) @glPopMatrix()
%47 = tail call i32 @free(i32* %10)
%48 = tail call i32 (...) @glPopAttrib()
ret void
}