#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 floor(double);
double pow(double, double);
int component_rgb_to_srgb(int c) {
  double cl = (double)c / 255.0;
  double cs;
  if (cl < 0.0031308) {
    cs = 12.92 * cl;
  } else {
    cs = 1.055 * pow(cl, 0.41666) - 0.055;
  }
  return floor(255.0 * cs + 0.5);
}


x86 assembly (clang, -O0):
<component_rgb_to_srgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xed0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xeb7(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    116b <component_rgb_to_srgb+0x4b>
movsd  0xecc(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    119a <component_rgb_to_srgb+0x7a>
movsd  -0x10(%rbp),%xmm0
movsd  0xea8(%rip),%xmm1
call   1030 <pow@plt>
movsd  0xe8b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe87(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe61(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe7d(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <floor@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<component_rgb_to_srgb>:
push   %rax
cvtsi2sd %edi,%xmm0
divsd  0xed3(%rip),%xmm0
movsd  0xed3(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1145 <component_rgb_to_srgb+0x25>
mulsd  0xee5(%rip),%xmm0
jmp    1162 <component_rgb_to_srgb+0x42>
movsd  0xec3(%rip),%xmm1
call   1030 <pow@plt>
mulsd  0xebe(%rip),%xmm0
addsd  0xebe(%rip),%xmm0
mulsd  0xe96(%rip),%xmm0
addsd  0xebe(%rip),%xmm0
pop    %rax
jmp    1040 <floor@plt>

LLVM IR (-O0):
define i32 @component_rgb_to_srgb(i32 %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = sitofp i32 %5 to double
%7 = fdiv double %6, 2.550000e+02
store double %7, double* %3
%8 = load double, double* %3
%9 = fcmp olt double %8, 3.130800e-03
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load double, double* %3
%12 = fmul double 1.292000e+01, %11
store double %12, double* %4
br label %17
13: ; preds = %1
%14 = load double, double* %3
%15 = call double @pow(double %14, double 4.166600e-01)
%16 = call double @llvm.fmuladd.f64(double 1.055000e+00, double %15, double -5.500000e-02)
store double %16, double* %4
br label %17
17: ; preds = %13, %10
%18 = load double, double* %4
%19 = call double @llvm.fmuladd.f64(double 2.550000e+02, double %18, double 5.000000e-01)
%20 = call i32 @floor(double %19)
ret i32 %20
}

LLVM IR (-O2):
define i32 @component_rgb_to_srgb(i32 %0) {
%2 = sitofp i32 %0 to double
%3 = fdiv double %2, 2.550000e+02
%4 = fcmp olt double %3, 3.130800e-03
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = fmul double %3, 1.292000e+01
br label %10
7: ; preds = %1
%8 = tail call double @pow(double %3, double 4.166600e-01)
%9 = tail call double @llvm.fmuladd.f64(double %8, double 1.055000e+00, double -5.500000e-02)
br label %10
10: ; preds = %7, %5
%11 = phi double [ %6, %5 ], [ %9, %7 ]
%12 = tail call double @llvm.fmuladd.f64(double %11, double 2.550000e+02, double 5.000000e-01)
%13 = tail call i32 @floor(double %12)
ret i32 %13
}