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

/* Variables and functions */
int /*<<< orphan*/ GL_COMPILE_AND_EXECUTE;
int /*<<< orphan*/ draw_frame();
int /*<<< orphan*/ draw_objects();
int /*<<< orphan*/ glCallList(int /*<<< orphan*/);
int /*<<< orphan*/ glEndList();
int /*<<< orphan*/ glGenLists(int);
int /*<<< orphan*/ glNewList(int /*<<< orphan*/, int /*<<< orphan*/);
void draw(void) {
  static bool bFirstCall = true;
  static GLint displayList = 0;
  if (bFirstCall) {
    bFirstCall = false;
    displayList = glGenLists(1);
    glNewList(displayList, GL_COMPILE_AND_EXECUTE);
    draw_frame();
    draw_objects();
    glEndList();
  } else {
    glCallList(displayList);
  }
  return;
}


x86 assembly (clang, -O0):
<draw>:
push   %rbp
mov    %rsp,%rbp
cmpl   $0x0,0x2ee5(%rip)
je     11b9 <draw+0x59>
movl   $0x0,0x2ed5(%rip)
mov    $0x1,%edi
call   1070 <glGenLists@plt>
mov    %eax,0x2ecd(%rip)
mov    0x2ec7(%rip),%edi
mov    0x2e48(%rip),%rax
mov    (%rax),%esi
call   1040 <glNewList@plt>
mov    $0x0,%al
call   1030 <draw_frame@plt>
mov    $0x0,%al
call   1050 <draw_objects@plt>
mov    $0x0,%al
call   1080 <glEndList@plt>
jmp    11c4 <draw+0x64>
mov    0x2e99(%rip),%edi
call   1060 <glCallList@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw>:
push   %rax
cmpb   $0x0,0x2eec(%rip)
je     1176 <draw+0x16>
mov    0x2ee8(%rip),%edi
pop    %rax
jmp    1060 <glCallList@plt>
movb   $0x1,0x2ed7(%rip)
mov    $0x1,%edi
call   1070 <glGenLists@plt>
mov    %eax,0x2ecb(%rip)
mov    0x2e4c(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1040 <glNewList@plt>
xor    %eax,%eax
call   1030 <draw_frame@plt>
xor    %eax,%eax
call   1050 <draw_objects@plt>
xor    %eax,%eax
pop    %rcx
jmp    1080 <glEndList@plt>

LLVM IR (-O0):
@draw.bFirstCall = internal global i32 1
@draw.displayList = internal global i32 0
@GL_COMPILE_AND_EXECUTE = global i32 0
define void @draw() {
%1 = load i32, i32* @draw.bFirstCall
%2 = icmp ne i32 %1, 0
br i1 %2, label %3, label %11
3: ; preds = %0
store i32 0, i32* @draw.bFirstCall
%4 = call i32 @glGenLists(i32 1)
store i32 %4, i32* @draw.displayList
%5 = load i32, i32* @draw.displayList
%6 = load i32, i32* @GL_COMPILE_AND_EXECUTE
%7 = call i32 @glNewList(i32 %5, i32 %6)
%8 = call i32 (...) @draw_frame()
%9 = call i32 (...) @draw_objects()
%10 = call i32 (...) @glEndList()
br label %14
11: ; preds = %0
%12 = load i32, i32* @draw.displayList
%13 = call i32 @glCallList(i32 %12)
br label %14
14: ; preds = %11, %3
ret void
}

LLVM IR (-O2):
@draw.bFirstCall = internal unnamed_addr global i1 false
@draw.displayList = internal unnamed_addr global i32 0
@GL_COMPILE_AND_EXECUTE = global i32 0
define void @draw() {
%1 = load i1, i1* @draw.bFirstCall
br i1 %1, label %9, label %2
2: ; preds = %0
store i1 true, i1* @draw.bFirstCall
%3 = tail call i32 @glGenLists(i32 1)
store i32 %3, i32* @draw.displayList
%4 = load i32, i32* @GL_COMPILE_AND_EXECUTE
%5 = tail call i32 @glNewList(i32 %3, i32 %4)
%6 = tail call i32 (...) @draw_frame()
%7 = tail call i32 (...) @draw_objects()
%8 = tail call i32 (...) @glEndList()
br label %12
9: ; preds = %0
%10 = load i32, i32* @draw.displayList
%11 = tail call i32 @glCallList(i32 %10)
br label %12
12: ; preds = %9, %2
ret void
}