#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
float floorf(float);
float powf(float, float);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  float r;
  uint8_t srgb;
  int i;
  printf("/* THIS FILE WAS AUTOMATICALLY GENERATED - ANY MODIFICATIONS MADE TO "
         "THIS");
  printf(
      "   FILE MAY BE OVERWRITTEN DURING FUTURE BUILDS OF THE SOFTWARE */\n");
  printf("\n");
  printf("static const float srgb_to_linear[256] =\n");
  printf("{\n");
  for (i = 0; i < 256; i++) {
    r = i / 256.0f;
    r = (r > 0.04045f) ? powf((r + 0.055f) / 1.055f, 2.4f) : r / 12.92f;
    printf((i < 255) ? "    %f,\n" : "    %f\n", r);
  }
  printf("};\n");
  printf("static const uint8_t linear_to_srgb[4096] =\n");
  printf("{\n");
  for (i = 0; i < 4096; i++) {
    r = i / 4096.0f;
    r = (r > 0.0031308f) ? (1.055f * powf(r, 1.0f / 2.4f) - 0.055f)
                         : r * 12.92f;
    r = floorf(r * 256.0f);
    srgb = (uint8_t)((r < 0) ? 0 : (r <= 255) ? r : 255);
    printf((i < 4095) ? "    %d,\n" : "    %d\n", srgb);
  }
  printf("};\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xfc7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x100,-0x1c(%rbp)
jge    1255 <main+0x125>
cvtsi2ssl -0x1c(%rbp),%xmm0
movss  0xe6b(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0xe5d(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11fc <main+0xcc>
movss  0xe54(%rip),%xmm0
addss  -0x14(%rbp),%xmm0
movss  0xe2b(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe37(%rip),%xmm1
call   1030 <powf@plt>
movss  %xmm0,-0x20(%rbp)
jmp    1212 <main+0xe2>
movss  -0x14(%rbp),%xmm0
movss  0xdff(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x1c(%rbp),%ecx
lea    0xeca(%rip),%rdi
lea    0xeba(%rip),%rax
cmp    $0xff,%ecx
cmovl  %rax,%rdi
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1193 <main+0x63>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1000,-0x1c(%rbp)
jge    13bc <main+0x28c>
cvtsi2ssl -0x1c(%rbp),%xmm0
movss  0xd64(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0xd4a(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    12f3 <main+0x1c3>
movss  -0x14(%rbp),%xmm0
movss  0xd48(%rip),%xmm1
call   1030 <powf@plt>
movss  0xd33(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xd2b(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
jmp    1305 <main+0x1d5>
movss  0xd0d(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xd01(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
call   1050 <floorf@plt>
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    1340 <main+0x210>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
jmp    137d <main+0x24d>
movss  0xcd4(%rip),%xmm0
ucomiss -0x14(%rbp),%xmm0
jb     1361 <main+0x231>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
jmp    1373 <main+0x243>
movss  0xcb3(%rip),%xmm0
movss  %xmm0,-0x2c(%rbp)
jmp    1373 <main+0x243>
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%ecx
lea    0xd9f(%rip),%rdi
lea    0xd8f(%rip),%rax
cmp    $0xfff,%ecx
cmovl  %rax,%rdi
mov    -0x18(%rbp),%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1286 <main+0x156>
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xed9(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf35(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xf62(%rip),%rdi
call   1040 <puts@plt>
lea    0xfab(%rip),%rdi
call   1040 <puts@plt>
lea    0xee5(%rip),%r14
lea    0xee7(%rip),%rbp
jmp    11db <main+0x8b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
divss  0xe50(%rip),%xmm0
cmp    $0xff,%ebx
mov    %rbp,%rdi
cmovb  %r14,%rdi
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
add    $0x1,%ebx
cmp    $0x100,%ebx
je     1212 <main+0xc2>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0xe16(%rip),%xmm0
ucomiss 0xe13(%rip),%xmm0
jbe    11b0 <main+0x60>
addss  0xe11(%rip),%xmm0
divss  0xe0d(%rip),%xmm0
movss  0xe09(%rip),%xmm1
call   1050 <powf@plt>
jmp    11b8 <main+0x68>
lea    0xf21(%rip),%rdi
call   1040 <puts@plt>
lea    0xee7(%rip),%rdi
call   1040 <puts@plt>
lea    0xf07(%rip),%rdi
call   1040 <puts@plt>
lea    0xe52(%rip),%r14
lea    0xe54(%rip),%rbx
xor    %ebp,%ebp
jmp    129f <main+0x14f>
nopl   0x0(%rax,%rax,1)
mulss  0xdb0(%rip),%xmm0
mulss  0xdc8(%rip),%xmm0
call   1070 <floorf@plt>
movaps %xmm0,%xmm1
minss  0xdbc(%rip),%xmm1
cmpltss 0xdb7(%rip),%xmm0
andnps %xmm1,%xmm0
cvttss2si %xmm0,%esi
cmp    $0xfff,%ebp
mov    %rbx,%rdi
cmovb  %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebp
cmp    $0x1000,%ebp
je     12d6 <main+0x186>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
mulss  0xd6a(%rip),%xmm0
ucomiss 0xd67(%rip),%xmm0
jbe    1250 <main+0x100>
movss  0xd61(%rip),%xmm1
call   1050 <powf@plt>
mulss  0xd44(%rip),%xmm0
addss  0xd50(%rip),%xmm0
jmp    1258 <main+0x108>
lea    0xe5d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [74 x i8] c"/* THIS FILE WAS AUTOMATICALLY GENERATED - ANY MODIFICATIONS MADE TO THIS\00"
@.str.1 = [68 x i8] c" FILE MAY BE OVERWRITTEN DURING FUTURE BUILDS OF THE SOFTWARE */\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [42 x i8] c"static const float srgb_to_linear[256] =\0A\00"
@.str.4 = [3 x i8] c"{\0A\00"
@.str.5 = [9 x i8] c" %f,\0A\00"
@.str.6 = [8 x i8] c" %f\0A\00"
@.str.7 = [4 x i8] c"};\0A\00"
@.str.8 = [45 x i8] c"static const uint8_t linear_to_srgb[4096] =\0A\00"
@.str.9 = [9 x i8] c" %d,\0A\00"
@.str.10 = [8 x i8] c" %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %8
br label %14
14: ; preds = %40, %2
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 256
br i1 %16, label %17, label %43
17: ; preds = %14
%18 = load i32, i32* %8
%19 = sitofp i32 %18 to float
%20 = fdiv float %19, 2.560000e+02
store float %20, float* %6
%21 = load float, float* %6
%22 = fcmp ogt float %21, 0x3FA4B5DCC0000000
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = load float, float* %6
%25 = fadd float %24, 0x3FAC28F5C0000000
%26 = fdiv float %25, 0x3FF0E147A0000000
%27 = call float @powf(float %26, float 0x4003333340000000)
br label %31
28: ; preds = %17
%29 = load float, float* %6
%30 = fdiv float %29, 0x4029D70A40000000
br label %31
31: ; preds = %28, %23
%32 = phi float [ %27, %23 ], [ %30, %28 ]
store float %32, float* %6
%33 = load i32, i32* %8
%34 = icmp slt i32 %33, 255
%35 = zext i1 %34 to i64
%36 = select i1 %34, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0)
%37 = load float, float* %6
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* %36, double %38)
br label %40
40: ; preds = %31
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
br label %14
43: ; preds = %14
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %8
br label %47
47: ; preds = %88, %43
%48 = load i32, i32* %8
%49 = icmp slt i32 %48, 4096
br i1 %49, label %50, label %91
50: ; preds = %47
%51 = load i32, i32* %8
%52 = sitofp i32 %51 to float
%53 = fdiv float %52, 4.096000e+03
store float %53, float* %6
%54 = load float, float* %6
%55 = fcmp ogt float %54, 0x3F69A5C380000000
br i1 %55, label %56, label %60
56: ; preds = %50
%57 = load float, float* %6
%58 = call float @powf(float %57, float 0x3FDAAAAAA0000000)
%59 = call float @llvm.fmuladd.f32(float 0x3FF0E147A0000000, float %58, float 0xBFAC28F5C0000000)
br label %63
60: ; preds = %50
%61 = load float, float* %6
%62 = fmul float %61, 0x4029D70A40000000
br label %63
63: ; preds = %60, %56
%64 = phi float [ %59, %56 ], [ %62, %60 ]
store float %64, float* %6
%65 = load float, float* %6
%66 = fmul float %65, 2.560000e+02
%67 = call float @llvm.floor.f32(float %66)
store float %67, float* %6
%68 = load float, float* %6
%69 = fcmp olt float %68, 0.000000e+00
br i1 %69, label %70, label %71
70: ; preds = %63
br label %79
71: ; preds = %63
%72 = load float, float* %6
%73 = fcmp ole float %72, 2.550000e+02
br i1 %73, label %74, label %76
74: ; preds = %71
%75 = load float, float* %6
br label %77
76: ; preds = %71
br label %77
77: ; preds = %76, %74
%78 = phi float [ %75, %74 ], [ 2.550000e+02, %76 ]
br label %79
79: ; preds = %77, %70
%80 = phi float [ 0.000000e+00, %70 ], [ %78, %77 ]
%81 = fptosi float %80 to i32
store i32 %81, i32* %7
%82 = load i32, i32* %8
%83 = icmp slt i32 %82, 4095
%84 = zext i1 %83 to i64
%85 = select i1 %83, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0)
%86 = load i32, i32* %7
%87 = call i32 (i8*, ...) @printf(i8* %85, i32 %86)
br label %88
88: ; preds = %79
%89 = load i32, i32* %8
%90 = add nsw i32 %89, 1
store i32 %90, i32* %8
br label %47
91: ; preds = %47
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [74 x i8] c"/* THIS FILE WAS AUTOMATICALLY GENERATED - ANY MODIFICATIONS MADE TO THIS\00"
@.str.5 = [9 x i8] c" %f,\0A\00"
@.str.6 = [8 x i8] c" %f\0A\00"
@.str.9 = [9 x i8] c" %d,\0A\00"
@.str.10 = [8 x i8] c" %d\0A\00"
@str = [67 x i8] c" FILE MAY BE OVERWRITTEN DURING FUTURE BUILDS OF THE SOFTWARE */\00"
@str.11 = [41 x i8] c"static const float srgb_to_linear[256] =\00"
@str.14 = [44 x i8] c"static const uint8_t linear_to_srgb[4096] =\00"
@str.15 = [2 x i8] c"{\00"
@str.16 = [3 x i8] c"};\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @putchar(i32 10)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.11, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.15, i64 0, i64 0))
br label %8
8: ; preds = %2, %19
%9 = phi i32 [ 0, %2 ], [ %25, %19 ]
%10 = sitofp i32 %9 to float
%11 = fmul float %10, 3.906250e-03
%12 = fcmp ogt float %11, 0x3FA4B5DCC0000000
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = fadd float %11, 0x3FAC28F5C0000000
%15 = fdiv float %14, 0x3FF0E147A0000000
%16 = tail call float @powf(float %15, float 0x4003333340000000)
br label %19
17: ; preds = %8
%18 = fdiv float %11, 0x4029D70A40000000
br label %19
19: ; preds = %17, %13
%20 = phi float [ %16, %13 ], [ %18, %17 ]
%21 = icmp ult i32 %9, 255
%22 = select i1 %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0)
%23 = fpext float %20 to double
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %22, double %23)
%25 = add nuw nsw i32 %9, 1
%26 = icmp eq i32 %25, 256
br i1 %26, label %27, label %8
27: ; preds = %19
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.16, i64 0, i64 0))
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.14, i64 0, i64 0))
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.15, i64 0, i64 0))
br label %31
31: ; preds = %27, %41
%32 = phi i32 [ 0, %27 ], [ %53, %41 ]
%33 = sitofp i32 %32 to float
%34 = fmul float %33, 0x3F30000000000000
%35 = fcmp ogt float %34, 0x3F69A5C380000000
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = tail call float @powf(float %34, float 0x3FDAAAAAA0000000)
%38 = tail call float @llvm.fmuladd.f32(float %37, float 0x3FF0E147A0000000, float 0xBFAC28F5C0000000)
br label %41
39: ; preds = %31
%40 = fmul float %34, 0x4029D70A40000000
br label %41
41: ; preds = %39, %36
%42 = phi float [ %38, %36 ], [ %40, %39 ]
%43 = fmul float %42, 2.560000e+02
%44 = tail call float @llvm.floor.f32(float %43)
%45 = fcmp olt float %44, 0.000000e+00
%46 = fcmp ole float %44, 2.550000e+02
%47 = select i1 %46, float %44, float 2.550000e+02
%48 = select i1 %45, float 0.000000e+00, float %47
%49 = fptosi float %48 to i32
%50 = icmp ult i32 %32, 4095
%51 = select i1 %50, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0)
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %51, i32 %49)
%53 = add nuw nsw i32 %32, 1
%54 = icmp eq i32 %53, 4096
br i1 %54, label %55, label %31
55: ; preds = %41
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.16, i64 0, i64 0))
ret i32 0
}