#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 */
unsigned int const rand_r(unsigned int *);
void rand_color(unsigned int *seed, unsigned char col[3],
                const unsigned int min, const unsigned int max) {
  col[0] = (unsigned char)(min + (rand_r(seed) % (max - min)));
  col[1] = (unsigned char)(min + (rand_r(seed) % (max - min)));
  col[2] = (unsigned char)(min + (rand_r(seed) % (max - min)));
}


x86 assembly (clang, -O0):
<rand_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <rand_r@plt>
mov    -0x18(%rbp),%ecx
sub    -0x14(%rbp),%ecx
xor    %edx,%edx
div    %ecx
mov    -0x24(%rbp),%eax
add    %edx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <rand_r@plt>
mov    -0x18(%rbp),%ecx
sub    -0x14(%rbp),%ecx
xor    %edx,%edx
div    %ecx
mov    -0x20(%rbp),%eax
add    %edx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <rand_r@plt>
mov    -0x18(%rbp),%ecx
sub    -0x14(%rbp),%ecx
xor    %edx,%edx
div    %ecx
mov    -0x1c(%rbp),%eax
add    %edx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_color>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <rand_r@plt>
sub    %ebp,%ebx
xor    %edx,%edx
div    %ebx
add    %ebp,%edx
mov    %dl,(%r14)
mov    %r15,%rdi
call   1030 <rand_r@plt>
xor    %edx,%edx
div    %ebx
add    %ebp,%edx
mov    %dl,0x1(%r14)
mov    %r15,%rdi
call   1030 <rand_r@plt>
xor    %edx,%edx
div    %ebx
add    %ebp,%edx
mov    %dl,0x2(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @rand_color(i32* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %7
%10 = load i32*, i32** %5
%11 = call i32 @rand_r(i32* %10)
%12 = load i32, i32* %8
%13 = load i32, i32* %7
%14 = sub i32 %12, %13
%15 = urem i32 %11, %14
%16 = add i32 %9, %15
%17 = trunc i32 %16 to i8
%18 = load i8*, i8** %6
%19 = getelementptr inbounds i8, i8* %18, i64 0
store i8 %17, i8* %19
%20 = load i32, i32* %7
%21 = load i32*, i32** %5
%22 = call i32 @rand_r(i32* %21)
%23 = load i32, i32* %8
%24 = load i32, i32* %7
%25 = sub i32 %23, %24
%26 = urem i32 %22, %25
%27 = add i32 %20, %26
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8 %28, i8* %30
%31 = load i32, i32* %7
%32 = load i32*, i32** %5
%33 = call i32 @rand_r(i32* %32)
%34 = load i32, i32* %8
%35 = load i32, i32* %7
%36 = sub i32 %34, %35
%37 = urem i32 %33, %36
%38 = add i32 %31, %37
%39 = trunc i32 %38 to i8
%40 = load i8*, i8** %6
%41 = getelementptr inbounds i8, i8* %40, i64 2
store i8 %39, i8* %41
ret void
}

LLVM IR (-O2):
define void @rand_color(i32* %0, i8* nocapture writeonly %1, i32 %2, i32 %3) {
%5 = tail call i32 @rand_r(i32* %0)
%6 = sub i32 %3, %2
%7 = urem i32 %5, %6
%8 = add i32 %7, %2
%9 = trunc i32 %8 to i8
store i8 %9, i8* %1
%10 = tail call i32 @rand_r(i32* %0)
%11 = urem i32 %10, %6
%12 = add i32 %11, %2
%13 = trunc i32 %12 to i8
%14 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %13, i8* %14
%15 = tail call i32 @rand_r(i32* %0)
%16 = urem i32 %15, %6
%17 = add i32 %16, %2
%18 = trunc i32 %17 to i8
%19 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %18, i8* %19
ret void
}