#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*/ GLUT_BITMAP_HELVETICA_18;
int /*<<< orphan*/ GL_AMBIENT_AND_DIFFUSE;
int /*<<< orphan*/ GL_BLEND;
int /*<<< orphan*/ GL_EMISSION;
int /*<<< orphan*/ GL_FRONT;
int /*<<< orphan*/ GL_ONE_MINUS_SRC_ALPHA;
int /*<<< orphan*/ GL_SRC_ALPHA;
int /*<<< orphan*/ glBlendFunc(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ glDisable(int /*<<< orphan*/);
int /*<<< orphan*/ glEnable(int /*<<< orphan*/);
int /*<<< orphan*/ glLoadIdentity();
int /*<<< orphan*/ glMaterialfv(int /*<<< orphan*/, int /*<<< orphan*/,
                                float const *);
int /*<<< orphan*/ glPopMatrix();
int /*<<< orphan*/ glPushMatrix();
int /*<<< orphan*/ glRasterPos2f(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ glTranslatef(double, double, int);
int /*<<< orphan*/ glutBitmapCharacter(int /*<<< orphan*/, char const);
int strlen(char const *);
void draw_text_in_color(double x, double y, const char *string, double r,
                        double g, double b, double a) {
  static const float emit_off[] = {0, 0, 0, 1};
  float emit0[] = {r, g, b, 1};
  float ad0[] = {0, 0, 0, a};
  int len, i;
  glPushMatrix();
  glLoadIdentity();
  glTranslatef(x, y, -1);
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glMaterialfv(GL_FRONT, GL_EMISSION, emit0);
  glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ad0);
  glRasterPos2f(0, 0);
  len = strlen(string);
  for (i = 0; i < len; ++i)
    glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, string[i]);
  glMaterialfv(GL_FRONT, GL_EMISSION, emit_off);
  glDisable(GL_BLEND);
  glPopMatrix();
  return;
}


x86 assembly (clang, -O0):
<draw_text_in_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4c(%rbp)
movsd  -0x30(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x48(%rbp)
movss  0xdf4(%rip),%xmm0
movss  %xmm0,-0x44(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x5c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x54(%rbp)
mov    $0x0,%al
call   10a0 <glPushMatrix@plt>
mov    $0x0,%al
call   1090 <glLoadIdentity@plt>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    $0xffffffff,%edi
call   10b0 <glTranslatef@plt>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
call   1060 <glEnable@plt>
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
mov    0x2d69(%rip),%rax
mov    (%rax),%esi
call   1030 <glBlendFunc@plt>
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
mov    0x2d42(%rip),%rax
mov    (%rax),%esi
lea    -0x50(%rbp),%rdx
call   10d0 <glMaterialfv@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
mov    0x2d0f(%rip),%rax
mov    (%rax),%esi
lea    -0x60(%rbp),%rdx
call   10d0 <glMaterialfv@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1070 <glRasterPos2f@plt>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1304 <draw_text_in_color+0x154>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1040 <glutBitmapCharacter@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    12d0 <draw_text_in_color+0x120>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
mov    0x2cbc(%rip),%rax
mov    (%rax),%esi
lea    0xcf3(%rip),%rdx
call   10d0 <glMaterialfv@plt>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
call   10c0 <glDisable@plt>
mov    $0x0,%al
call   1080 <glPopMatrix@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_text_in_color>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r13
movsd  %xmm1,0x30(%rsp)
movsd  %xmm0,0x28(%rsp)
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
movss  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtsd2ss %xmm3,%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm4,%xmm1
movss  %xmm0,0x4(%rsp)
movss  %xmm1,0x8(%rsp)
movl   $0x3f800000,0xc(%rsp)
3f
movq   $0x0,0x10(%rsp)
movl   $0x0,0x18(%rsp)
xorps  %xmm0,%xmm0
cvtsd2ss %xmm5,%xmm0
movss  %xmm0,0x1c(%rsp)
xor    %eax,%eax
call   10a0 <glPushMatrix@plt>
xor    %eax,%eax
call   1090 <glLoadIdentity@plt>
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
mov    $0xffffffff,%edi
call   10b0 <glTranslatef@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
call   1060 <glEnable@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
mov    0x2d85(%rip),%rax
mov    (%rax),%esi
call   1030 <glBlendFunc@plt>
mov    0x2d7f(%rip),%r15
mov    (%r15),%edi
mov    0x2d5d(%rip),%r12
mov    (%r12),%esi
mov    %rsp,%rdx
call   10d0 <glMaterialfv@plt>
mov    (%r15),%edi
mov    0x2d2f(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
call   10d0 <glMaterialfv@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1070 <glRasterPos2f@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    12d7 <draw_text_in_color+0x127>
mov    %eax,%ebx
xor    %ebp,%ebp
mov    0x2d0b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14),%edi
movsbl 0x0(%r13,%rbp,1),%esi
call   1040 <glutBitmapCharacter@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    12c0 <draw_text_in_color+0x110>
mov    (%r15),%edi
mov    (%r12),%esi
lea    0xd1b(%rip),%rdx
call   10d0 <glMaterialfv@plt>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
call   10c0 <glDisable@plt>
xor    %eax,%eax
call   1080 <glPopMatrix@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@draw_text_in_color.emit_off = internal constant [4 x float] [float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00]
@GL_BLEND = global i32 0
@GL_SRC_ALPHA = global i32 0
@GL_ONE_MINUS_SRC_ALPHA = global i32 0
@GL_FRONT = global i32 0
@GL_EMISSION = global i32 0
@GL_AMBIENT_AND_DIFFUSE = global i32 0
@GLUT_BITMAP_HELVETICA_18 = global i32 0
define void @draw_text_in_color(double %0, double %1, i8* %2, double %3, double %4, double %5, double %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca i8*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca [4 x float]
%16 = alloca [4 x float]
%17 = alloca i32
%18 = alloca i32
store double %0, double* %8
store double %1, double* %9
store i8* %2, i8** %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
store double %6, double* %14
%19 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%20 = load double, double* %11
%21 = fptrunc double %20 to float
store float %21, float* %19
%22 = getelementptr inbounds float, float* %19, i64 1
%23 = load double, double* %12
%24 = fptrunc double %23 to float
store float %24, float* %22
%25 = getelementptr inbounds float, float* %22, i64 1
%26 = load double, double* %13
%27 = fptrunc double %26 to float
store float %27, float* %25
%28 = getelementptr inbounds float, float* %25, i64 1
store float 1.000000e+00, float* %28
%29 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
store float 0.000000e+00, float* %29
%30 = getelementptr inbounds float, float* %29, i64 1
store float 0.000000e+00, float* %30
%31 = getelementptr inbounds float, float* %30, i64 1
store float 0.000000e+00, float* %31
%32 = getelementptr inbounds float, float* %31, i64 1
%33 = load double, double* %14
%34 = fptrunc double %33 to float
store float %34, float* %32
%35 = call i32 (...) @glPushMatrix()
%36 = call i32 (...) @glLoadIdentity()
%37 = load double, double* %8
%38 = load double, double* %9
%39 = call i32 @glTranslatef(double %37, double %38, i32 -1)
%40 = load i32, i32* @GL_BLEND
%41 = call i32 @glEnable(i32 %40)
%42 = load i32, i32* @GL_SRC_ALPHA
%43 = load i32, i32* @GL_ONE_MINUS_SRC_ALPHA
%44 = call i32 @glBlendFunc(i32 %42, i32 %43)
%45 = load i32, i32* @GL_FRONT
%46 = load i32, i32* @GL_EMISSION
%47 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%48 = call i32 @glMaterialfv(i32 %45, i32 %46, float* %47)
%49 = load i32, i32* @GL_FRONT
%50 = load i32, i32* @GL_AMBIENT_AND_DIFFUSE
%51 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%52 = call i32 @glMaterialfv(i32 %49, i32 %50, float* %51)
%53 = call i32 @glRasterPos2f(i32 0, i32 0)
%54 = load i8*, i8** %10
%55 = call i32 @strlen(i8* %54)
store i32 %55, i32* %17
store i32 0, i32* %18
br label %56
56: ; preds = %68, %7
%57 = load i32, i32* %18
%58 = load i32, i32* %17
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %71
60: ; preds = %56
%61 = load i32, i32* @GLUT_BITMAP_HELVETICA_18
%62 = load i8*, i8** %10
%63 = load i32, i32* %18
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = load i8, i8* %65
%67 = call i32 @glutBitmapCharacter(i32 %61, i8 signext %66)
br label %68
68: ; preds = %60
%69 = load i32, i32* %18
%70 = add nsw i32 %69, 1
store i32 %70, i32* %18
br label %56
71: ; preds = %56
%72 = load i32, i32* @GL_FRONT
%73 = load i32, i32* @GL_EMISSION
%74 = call i32 @glMaterialfv(i32 %72, i32 %73, float* getelementptr inbounds ([4 x float], [4 x float]* @draw_text_in_color.emit_off, i64 0, i64 0))
%75 = load i32, i32* @GL_BLEND
%76 = call i32 @glDisable(i32 %75)
%77 = call i32 (...) @glPopMatrix()
ret void
}

LLVM IR (-O2):
@draw_text_in_color.emit_off = internal constant [4 x float] [float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00]
@GL_BLEND = global i32 0
@GL_SRC_ALPHA = global i32 0
@GL_ONE_MINUS_SRC_ALPHA = global i32 0
@GL_FRONT = global i32 0
@GL_EMISSION = global i32 0
@GL_AMBIENT_AND_DIFFUSE = global i32 0
@GLUT_BITMAP_HELVETICA_18 = global i32 0
define void @draw_text_in_color(double %0, double %1, i8* %2, double %3, double %4, double %5, double %6) {
%8 = alloca [4 x float]
%9 = alloca [4 x float]
%10 = bitcast [4 x float]* %8 to i8*
%11 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%12 = fptrunc double %3 to float
store float %12, float* %11
%13 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 1
%14 = fptrunc double %4 to float
store float %14, float* %13
%15 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 2
%16 = fptrunc double %5 to float
store float %16, float* %15
%17 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 3
store float 1.000000e+00, float* %17
%18 = bitcast [4 x float]* %9 to i8*
%19 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 0
store float 0.000000e+00, float* %19
%20 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 1
store float 0.000000e+00, float* %20
%21 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 2
store float 0.000000e+00, float* %21
%22 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 3
%23 = fptrunc double %6 to float
store float %23, float* %22
%24 = tail call i32 (...) @glPushMatrix()
%25 = tail call i32 (...) @glLoadIdentity()
%26 = tail call i32 @glTranslatef(double %0, double %1, i32 -1)
%27 = load i32, i32* @GL_BLEND
%28 = tail call i32 @glEnable(i32 %27)
%29 = load i32, i32* @GL_SRC_ALPHA
%30 = load i32, i32* @GL_ONE_MINUS_SRC_ALPHA
%31 = tail call i32 @glBlendFunc(i32 %29, i32 %30)
%32 = load i32, i32* @GL_FRONT
%33 = load i32, i32* @GL_EMISSION
%34 = call i32 @glMaterialfv(i32 %32, i32 %33, float* %11)
%35 = load i32, i32* @GL_FRONT
%36 = load i32, i32* @GL_AMBIENT_AND_DIFFUSE
%37 = call i32 @glMaterialfv(i32 %35, i32 %36, float* %19)
%38 = call i32 @glRasterPos2f(i32 0, i32 0)
%39 = call i32 @strlen(i8* %2)
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %51
41: ; preds = %7
%42 = zext i32 %39 to i64
br label %43
43: ; preds = %41, %43
%44 = phi i64 [ 0, %41 ], [ %49, %43 ]
%45 = load i32, i32* @GLUT_BITMAP_HELVETICA_18
%46 = getelementptr inbounds i8, i8* %2, i64 %44
%47 = load i8, i8* %46
%48 = call i32 @glutBitmapCharacter(i32 %45, i8 signext %47)
%49 = add nuw nsw i64 %44, 1
%50 = icmp eq i64 %49, %42
br i1 %50, label %51, label %43
51: ; preds = %43, %7
%52 = load i32, i32* @GL_FRONT
%53 = load i32, i32* @GL_EMISSION
%54 = call i32 @glMaterialfv(i32 %52, i32 %53, float* getelementptr inbounds ([4 x float], [4 x float]* @draw_text_in_color.emit_off, i64 0, i64 0))
%55 = load i32, i32* @GL_BLEND
%56 = call i32 @glDisable(i32 %55)
%57 = call i32 (...) @glPopMatrix()
ret void
}