#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*/ sprintf(char *, char *, int, int, int);
int /*<<< orphan*/ strcpy(char *, char *);
int code_color(double red, double green, double blue, char name[64]) {
  int ired, igreen, iblue;
  char cn[64];
  ired = 0.5 + 100.0 * red;
  igreen = 0.5 + 100.0 * green;
  iblue = 0.5 + 100.0 * blue;
  sprintf(cn, "r%3dg%3db%3d", ired, igreen, iblue);
  if (cn[1] == ' ')
    cn[1] = '0';
  if (cn[2] == ' ')
    cn[2] = '0';
  if (cn[5] == ' ')
    cn[5] = '0';
  if (cn[6] == ' ')
    cn[6] = '0';
  if (cn[9] == ' ')
    cn[9] = '0';
  if (cn[10] == ' ')
    cn[10] = '0';
  strcpy(name, cn);
  return (1);
}


x86 assembly (clang, -O0):
<code_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xeb8(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb4(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe94(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe90(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe70(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe6c(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
lea    0xe54(%rip),%rsi
call   1040 <sprintf@plt>
movsbl -0x6f(%rbp),%eax
cmp    $0x20,%eax
jne    11d2 <code_color+0xb2>
movb   $0x30,-0x6f(%rbp)
movsbl -0x6e(%rbp),%eax
cmp    $0x20,%eax
jne    11e3 <code_color+0xc3>
movb   $0x30,-0x6e(%rbp)
movsbl -0x6b(%rbp),%eax
cmp    $0x20,%eax
jne    11f4 <code_color+0xd4>
movb   $0x30,-0x6b(%rbp)
movsbl -0x6a(%rbp),%eax
cmp    $0x20,%eax
jne    1205 <code_color+0xe5>
movb   $0x30,-0x6a(%rbp)
movsbl -0x67(%rbp),%eax
cmp    $0x20,%eax
jne    1216 <code_color+0xf6>
movb   $0x30,-0x67(%rbp)
movsbl -0x66(%rbp),%eax
cmp    $0x20,%eax
jne    1227 <code_color+0x107>
movb   $0x30,-0x66(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1030 <strcpy@plt>
mov    $0x1,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<code_color>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
movsd  0xed0(%rip),%xmm3
mulsd  %xmm3,%xmm0
movsd  0xecc(%rip),%xmm4
addsd  %xmm4,%xmm0
cvttsd2si %xmm0,%edx
mulsd  %xmm3,%xmm1
addsd  %xmm4,%xmm1
cvttsd2si %xmm1,%ecx
mulsd  %xmm3,%xmm2
addsd  %xmm4,%xmm2
cvttsd2si %xmm2,%r8d
lea    0xeac(%rip),%rsi
mov    %rsp,%rdi
call   1040 <sprintf@plt>
cmpb   $0x20,0x1(%rsp)
je     11b1 <code_color+0x91>
cmpb   $0x20,0x2(%rsp)
je     11bd <code_color+0x9d>
cmpb   $0x20,0x5(%rsp)
je     11c9 <code_color+0xa9>
cmpb   $0x20,0x6(%rsp)
je     11d5 <code_color+0xb5>
cmpb   $0x20,0x9(%rsp)
je     11e1 <code_color+0xc1>
cmpb   $0x20,0xa(%rsp)
jne    119b <code_color+0x7b>
movb   $0x30,0xa(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbx
ret
movb   $0x30,0x1(%rsp)
cmpb   $0x20,0x2(%rsp)
jne    117a <code_color+0x5a>
movb   $0x30,0x2(%rsp)
cmpb   $0x20,0x5(%rsp)
jne    1181 <code_color+0x61>
movb   $0x30,0x5(%rsp)
cmpb   $0x20,0x6(%rsp)
jne    1188 <code_color+0x68>
movb   $0x30,0x6(%rsp)
cmpb   $0x20,0x9(%rsp)
jne    118f <code_color+0x6f>
movb   $0x30,0x9(%rsp)
cmpb   $0x20,0xa(%rsp)
je     1196 <code_color+0x76>
jmp    119b <code_color+0x7b>

LLVM IR (-O0):
@.str = [13 x i8] c"r%3dg%3db%3d\00"
define i32 @code_color(double %0, double %1, double %2, i8* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [64 x i8]
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store i8* %3, i8** %8
%13 = load double, double* %5
%14 = call double @llvm.fmuladd.f64(double 1.000000e+02, double %13, double 5.000000e-01)
%15 = fptosi double %14 to i32
store i32 %15, i32* %9
%16 = load double, double* %6
%17 = call double @llvm.fmuladd.f64(double 1.000000e+02, double %16, double 5.000000e-01)
%18 = fptosi double %17 to i32
store i32 %18, i32* %10
%19 = load double, double* %7
%20 = call double @llvm.fmuladd.f64(double 1.000000e+02, double %19, double 5.000000e-01)
%21 = fptosi double %20 to i32
store i32 %21, i32* %11
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%23 = load i32, i32* %9
%24 = load i32, i32* %10
%25 = load i32, i32* %11
%26 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24, i32 %25)
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 32
br i1 %30, label %31, label %33
31: ; preds = %4
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 1
store i8 48, i8* %32
br label %33
33: ; preds = %31, %4
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 2
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 32
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 2
store i8 48, i8* %39
br label %40
40: ; preds = %38, %33
%41 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 5
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 32
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 5
store i8 48, i8* %46
br label %47
47: ; preds = %45, %40
%48 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 6
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 32
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 6
store i8 48, i8* %53
br label %54
54: ; preds = %52, %47
%55 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 9
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 32
br i1 %58, label %59, label %61
59: ; preds = %54
%60 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 9
store i8 48, i8* %60
br label %61
61: ; preds = %59, %54
%62 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 10
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 32
br i1 %65, label %66, label %68
66: ; preds = %61
%67 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 10
store i8 48, i8* %67
br label %68
68: ; preds = %66, %61
%69 = load i8*, i8** %8
%70 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%71 = call i32 @strcpy(i8* %69, i8* %70)
ret i32 1
}

LLVM IR (-O2):
@.str = [13 x i8] c"r%3dg%3db%3d\00"
define i32 @code_color(double %0, double %1, double %2, i8* %3) {
%5 = alloca [64 x i8]
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%7 = tail call double @llvm.fmuladd.f64(double %0, double 1.000000e+02, double 5.000000e-01)
%8 = fptosi double %7 to i32
%9 = tail call double @llvm.fmuladd.f64(double %1, double 1.000000e+02, double 5.000000e-01)
%10 = fptosi double %9 to i32
%11 = tail call double @llvm.fmuladd.f64(double %2, double 1.000000e+02, double 5.000000e-01)
%12 = fptosi double %11 to i32
%13 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %10, i32 %12)
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 32
br i1 %16, label %17, label %18
17: ; preds = %4
store i8 48, i8* %14
br label %18
18: ; preds = %17, %4
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 2
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 32
br i1 %21, label %22, label %23
22: ; preds = %18
store i8 48, i8* %19
br label %23
23: ; preds = %22, %18
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 5
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 32
br i1 %26, label %27, label %28
27: ; preds = %23
store i8 48, i8* %24
br label %28
28: ; preds = %27, %23
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 6
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 32
br i1 %31, label %32, label %33
32: ; preds = %28
store i8 48, i8* %29
br label %33
33: ; preds = %32, %28
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 9
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 32
br i1 %36, label %37, label %38
37: ; preds = %33
store i8 48, i8* %34
br label %38
38: ; preds = %37, %33
%39 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 10
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 32
br i1 %41, label %42, label %43
42: ; preds = %38
store i8 48, i8* %39
br label %43
43: ; preds = %42, %38
%44 = call i32 @strcpy(i8* %3, i8* %6)
ret i32 1
}