#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*/ glRasterPos2i(int, int);
int /*<<< orphan*/ glutBitmapCharacter(void *, char);
scalar_t__ strlen(char *);
void draw_text2d(int x, int y, char *string, void *font) {
  int len = 0, i = 0;
  glRasterPos2i(x, y);
  len = (int)strlen(string);
  for (i = 0; i < len; i++)
    glutBitmapCharacter(font, string[i]);
}


x86 assembly (clang, -O0):
<draw_text2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <glRasterPos2i@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11a1 <draw_text2d+0x71>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1030 <glutBitmapCharacter@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1172 <draw_text2d+0x42>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_text2d>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
call   1050 <glRasterPos2i@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1176 <draw_text2d+0x46>
mov    %eax,%r12d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
call   1030 <glutBitmapCharacter@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <draw_text2d+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @draw_text2d(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 0, i32* %9
store i32 0, i32* %10
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = call i32 @glRasterPos2i(i32 %11, i32 %12)
%14 = load i8*, i8** %7
%15 = call i64 @strlen(i8* %14)
%16 = trunc i64 %15 to i32
store i32 %16, i32* %9
store i32 0, i32* %10
br label %17
17: ; preds = %29, %4
%18 = load i32, i32* %10
%19 = load i32, i32* %9
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %32
21: ; preds = %17
%22 = load i8*, i8** %8
%23 = load i8*, i8** %7
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = call i32 @glutBitmapCharacter(i8* %22, i8 signext %27)
br label %29
29: ; preds = %21
%30 = load i32, i32* %10
%31 = add nsw i32 %30, 1
store i32 %31, i32* %10
br label %17
32: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @draw_text2d(i32 %0, i32 %1, i8* nocapture %2, i8* %3) {
%5 = tail call i32 @glRasterPos2i(i32 %0, i32 %1)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%7 = trunc i64 %6 to i32
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %4
%10 = and i64 %6, 4294967295
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %16, %11 ]
%13 = getelementptr inbounds i8, i8* %2, i64 %12
%14 = load i8, i8* %13
%15 = tail call i32 @glutBitmapCharacter(i8* %3, i8 signext %14)
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %10
br i1 %17, label %18, label %11
18: ; preds = %11, %4
ret void
}