#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 */
double RAND_MAX;
double rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int triplet(int, int, int);
int randomColor() {
  static int seeded = 0;
  int a, b, c;
  if (!seeded) {
    srand(time(0));
    seeded = 1;
  }
  a = 1 + (int)(255.0 * rand() / (RAND_MAX + 1.0));
  b = 1 + (int)(255.0 * rand() / (RAND_MAX + 1.0));
  c = 1 + (int)(255.0 * rand() / (RAND_MAX + 1.0));
  return (triplet(a, b, c));
}


x86 assembly (clang, -O0):
<randomColor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpl   $0x0,0x2ef9(%rip)
jne    116d <randomColor+0x2d>
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x1,0x2edb(%rip)
mov    $0x0,%al
call   1050 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xe89(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe75(%rip),%xmm1
mov    0x2e56(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xe52(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe3e(%rip),%xmm1
mov    0x2e1f(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xe1b(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe07(%rip),%xmm1
mov    0x2de8(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1060 <triplet@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomColor>:
push   %rbp
push   %r14
push   %rbx
cmpb   $0x0,0x2efd(%rip)
jne    1162 <randomColor+0x22>
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movb   $0x1,0x2ee6(%rip)
xor    %eax,%eax
call   1050 <rand@plt>
mulsd  0xe8f(%rip),%xmm0
mov    0x2e70(%rip),%r14
movsd  (%r14),%xmm1
addsd  0xe83(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ebx
add    $0x1,%ebx
xor    %eax,%eax
call   1050 <rand@plt>
mulsd  0xe61(%rip),%xmm0
movsd  (%r14),%xmm1
addsd  0xe5c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ebp
add    $0x1,%ebp
xor    %eax,%eax
call   1050 <rand@plt>
mulsd  0xe3a(%rip),%xmm0
movsd  0xe3a(%rip),%xmm1
addsd  (%r14),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
add    $0x1,%edx
mov    %ebx,%edi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <triplet@plt>

LLVM IR (-O0):
@randomColor.seeded = internal global i32 0
@RAND_MAX = global double 0.000000e+00
define i32 @randomColor() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = load i32, i32* @randomColor.seeded
%5 = icmp ne i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = call i32 @time(i32 0)
%8 = call i32 @srand(i32 %7)
store i32 1, i32* @randomColor.seeded
br label %9
9: ; preds = %6, %0
%10 = call double (...) @rand()
%11 = fmul double 2.550000e+02, %10
%12 = load double, double* @RAND_MAX
%13 = fadd double %12, 1.000000e+00
%14 = fdiv double %11, %13
%15 = fptosi double %14 to i32
%16 = add nsw i32 1, %15
store i32 %16, i32* %1
%17 = call double (...) @rand()
%18 = fmul double 2.550000e+02, %17
%19 = load double, double* @RAND_MAX
%20 = fadd double %19, 1.000000e+00
%21 = fdiv double %18, %20
%22 = fptosi double %21 to i32
%23 = add nsw i32 1, %22
store i32 %23, i32* %2
%24 = call double (...) @rand()
%25 = fmul double 2.550000e+02, %24
%26 = load double, double* @RAND_MAX
%27 = fadd double %26, 1.000000e+00
%28 = fdiv double %25, %27
%29 = fptosi double %28 to i32
%30 = add nsw i32 1, %29
store i32 %30, i32* %3
%31 = load i32, i32* %1
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = call i32 @triplet(i32 %31, i32 %32, i32 %33)
ret i32 %34
}

LLVM IR (-O2):
@randomColor.seeded = internal unnamed_addr global i1 false
@RAND_MAX = global double 0.000000e+00
define i32 @randomColor() {
%1 = load i1, i1* @randomColor.seeded
br i1 %1, label %5, label %2
2: ; preds = %0
%3 = tail call i32 @time(i32 0)
%4 = tail call i32 @srand(i32 %3)
store i1 true, i1* @randomColor.seeded
br label %5
5: ; preds = %2, %0
%6 = tail call double (...) @rand()
%7 = fmul double %6, 2.550000e+02
%8 = load double, double* @RAND_MAX
%9 = fadd double %8, 1.000000e+00
%10 = fdiv double %7, %9
%11 = fptosi double %10 to i32
%12 = add nsw i32 %11, 1
%13 = tail call double (...) @rand()
%14 = fmul double %13, 2.550000e+02
%15 = load double, double* @RAND_MAX
%16 = fadd double %15, 1.000000e+00
%17 = fdiv double %14, %16
%18 = fptosi double %17 to i32
%19 = add nsw i32 %18, 1
%20 = tail call double (...) @rand()
%21 = fmul double %20, 2.550000e+02
%22 = load double, double* @RAND_MAX
%23 = fadd double %22, 1.000000e+00
%24 = fdiv double %21, %23
%25 = fptosi double %24 to i32
%26 = add nsw i32 %25, 1
%27 = tail call i32 @triplet(i32 %12, i32 %19, i32 %26)
ret i32 %27
}