#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 /*<<< orphan*/ GL_CURRENT_BIT;
int /*<<< orphan*/ glPopAttrib();
int /*<<< orphan*/ glPushAttrib(int /*<<< orphan*/);
int /*<<< orphan*/ glRasterPos2i(int, int);
int /*<<< orphan*/ text_draw_glyph(char);
void text_draw(int x, int y, char *text) {
  glPushAttrib(GL_CURRENT_BIT);
  glRasterPos2i(x, y);
  char c;
  while ((c = *text++)) {
    text_draw_glyph(c);
  }
  glPopAttrib();
}


x86 assembly (clang, -O0):
<text_draw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
call   1040 <glPushAttrib@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <glRasterPos2i@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x11(%rbp)
cmp    $0x0,%al
je     1195 <text_draw+0x55>
movsbl -0x11(%rbp),%edi
call   1050 <text_draw_glyph@plt>
jmp    116b <text_draw+0x2b>
mov    $0x0,%al
call   1030 <glPopAttrib@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<text_draw>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %edi,%ebp
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
call   1040 <glPushAttrib@plt>
mov    %ebp,%edi
mov    %r14d,%esi
call   1060 <glRasterPos2i@plt>
mov    (%rbx),%al
test   %al,%al
je     1183 <text_draw+0x43>
add    $0x1,%rbx
xchg   %ax,%ax
movsbl %al,%edi
call   1050 <text_draw_glyph@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1170 <text_draw+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <glPopAttrib@plt>

LLVM IR (-O0):
@GL_CURRENT_BIT = global i32 0
define void @text_draw(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i32, i32* @GL_CURRENT_BIT
%9 = call i32 @glPushAttrib(i32 %8)
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = call i32 @glRasterPos2i(i32 %10, i32 %11)
br label %13
13: ; preds = %18, %3
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %6
%16 = load i8, i8* %14
store i8 %16, i8* %7
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i8, i8* %7
%20 = call i32 @text_draw_glyph(i8 signext %19)
br label %13
21: ; preds = %13
%22 = call i32 (...) @glPopAttrib()
ret void
}

LLVM IR (-O2):
@GL_CURRENT_BIT = global i32 0
define void @text_draw(i32 %0, i32 %1, i8* nocapture %2) {
%4 = load i32, i32* @GL_CURRENT_BIT
%5 = tail call i32 @glPushAttrib(i32 %4)
%6 = tail call i32 @glRasterPos2i(i32 %0, i32 %1)
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %3, %9
%10 = phi i8 [ %14, %9 ], [ %7, %3 ]
%11 = phi i8* [ %12, %9 ], [ %2, %3 ]
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = tail call i32 @text_draw_glyph(i8 signext %10)
%14 = load i8, i8* %12
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %9
16: ; preds = %9, %3
%17 = tail call i32 (...) @glPopAttrib()
ret void
}