#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int find_color(int, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, int);
int /*<<< orphan*/ stderr;
int rgb_to_color(int r, int g, int b) {
  int color = find_color(r, g, b);
  if (color != -1)
    return color;
  fprintf(stderr, "color #%02x%02x%02x not declared\n", r, g, b);
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<rgb_to_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <find_color@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
je     1165 <rgb_to_color+0x35>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xe81(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<rgb_to_color>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1040 <find_color@plt>
cmp    $0xffffffff,%eax
je     114a <rgb_to_color+0x1a>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r14d,%r8d
call   1030 <fprintf@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"color #%02x%02x%02x not declared\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @rgb_to_color(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = call i32 @find_color(i32 %8, i32 %9, i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = load i32, i32* %7
ret i32 %15
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19, i32 %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"color #%02x%02x%02x not declared\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @rgb_to_color(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @find_color(i32 %0, i32 %1, i32 %2)
%5 = icmp eq i32 %4, -1
br i1 %5, label %7, label %6
6: ; preds = %3
ret i32 %4
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 %2)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
}