#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 scalar_t__ GLuint;

/* Variables and functions */
int /*<<< orphan*/ glCallList(scalar_t__);
scalar_t__ glGenLists(int);
int /*<<< orphan*/ wglGetCurrentDC();
int /*<<< orphan*/ wglUseFontBitmaps(int /*<<< orphan*/, int /*<<< orphan*/,
                                     int, scalar_t__);
void drawString(const char *str) {
  static int isFirstCall = 1;
  static GLuint lists;
  if (isFirstCall) {
    isFirstCall = 0;
    lists = glGenLists(128);
    wglUseFontBitmaps(wglGetCurrentDC(), 0, 128, lists);
  }
  for (; *str != '\0'; ++str) {
    glCallList(lists + *str);
  }
}


x86 assembly (clang, -O0):
<drawString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpl   $0x0,0x2eed(%rip)
je     1190 <drawString+0x50>
movl   $0x0,0x2edd(%rip)
mov    $0x80,%edi
call   1040 <glGenLists@plt>
mov    %rax,0x2edc(%rip)
mov    $0x0,%al
call   1050 <wglGetCurrentDC@plt>
mov    %eax,%edi
mov    0x2ecc(%rip),%rcx
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <wglUseFontBitmaps@plt>
jmp    1195 <drawString+0x55>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11cd <drawString+0x8d>
mov    0x2ea4(%rip),%rdi
mov    -0x8(%rbp),%rax
movsbq (%rax),%rax
add    %rax,%rdi
call   1030 <glCallList@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1195 <drawString+0x55>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawString>:
push   %rbx
mov    %rdi,%rbx
cmpb   $0x0,0x2efd(%rip)
jne    1181 <drawString+0x41>
movb   $0x1,0x2ef4(%rip)
mov    $0x80,%edi
call   1040 <glGenLists@plt>
mov    %rax,0x2eeb(%rip)
xor    %eax,%eax
call   1050 <wglGetCurrentDC@plt>
mov    0x2edd(%rip),%rcx
mov    %eax,%edi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <wglUseFontBitmaps@plt>
mov    (%rbx),%al
test   %al,%al
je     11ab <drawString+0x6b>
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
movsbq %al,%rdi
add    0x2eb5(%rip),%rdi
call   1030 <glCallList@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1190 <drawString+0x50>
pop    %rbx
ret

LLVM IR (-O0):
@drawString.isFirstCall = internal global i32 1
@drawString.lists = internal global i64 0
define void @drawString(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @drawString.isFirstCall
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %1
store i32 0, i32* @drawString.isFirstCall
%6 = call i64 @glGenLists(i32 128)
store i64 %6, i64* @drawString.lists
%7 = call i32 (...) @wglGetCurrentDC()
%8 = load i64, i64* @drawString.lists
%9 = call i32 @wglUseFontBitmaps(i32 %7, i32 0, i32 128, i64 %8)
br label %10
10: ; preds = %5, %1
br label %11
11: ; preds = %23, %10
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %11
%17 = load i64, i64* @drawString.lists
%18 = load i8*, i8** %2
%19 = load i8, i8* %18
%20 = sext i8 %19 to i64
%21 = add nsw i64 %17, %20
%22 = call i32 @glCallList(i64 %21)
br label %23
23: ; preds = %16
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %2
br label %11
26: ; preds = %11
ret void
}

LLVM IR (-O2):
@drawString.isFirstCall = internal unnamed_addr global i1 false
@drawString.lists = internal unnamed_addr global i64 0
define void @drawString(i8* nocapture %0) {
%2 = load i1, i1* @drawString.isFirstCall
br i1 %2, label %8, label %3
3: ; preds = %1
store i1 true, i1* @drawString.isFirstCall
%4 = tail call i64 @glGenLists(i32 128)
store i64 %4, i64* @drawString.lists
%5 = tail call i32 (...) @wglGetCurrentDC()
%6 = load i64, i64* @drawString.lists
%7 = tail call i32 @wglUseFontBitmaps(i32 %5, i32 0, i32 128, i64 %6)
br label %8
8: ; preds = %3, %1
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %8, %11
%12 = phi i8 [ %19, %11 ], [ %9, %8 ]
%13 = phi i8* [ %18, %11 ], [ %0, %8 ]
%14 = load i64, i64* @drawString.lists
%15 = sext i8 %12 to i64
%16 = add nsw i64 %14, %15
%17 = tail call i32 @glCallList(i64 %16)
%18 = getelementptr inbounds i8, i8* %13, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %11
21: ; preds = %11, %8
ret void
}