#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int pow(double, double);
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  FILE *f;
  int i, v;
  double x;
  f = fopen("compressor_lut.hex", "wt");
  for (i = 0; i < 256; i++) {
    if (i <= 186) {
      x = i / 186.0;
      v = 255 * pow(x, 0.75);
    } else
      v = 255;
    printf("%4d -> %4d\n", i, v);
    fprintf(f, "%.2X\n", v);
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    1207 <main+0xb7>
cmpl   $0xba,-0x14(%rbp)
jg     11cd <main+0x7d>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe64(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe46(%rip),%xmm1
call   1070 <pow@plt>
imul   $0xff,%eax,%eax
mov    %eax,-0x18(%rbp)
jmp    11d4 <main+0x84>
movl   $0xff,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe45(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe3e(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117d <main+0x2d>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeb5(%rip),%rdi
lea    0xec1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xea9(%rip),%r14
lea    0xeae(%rip),%r15
jmp    11c8 <main+0x78>
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1050 <fprintf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe59(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0x1,%ebp
cmp    $0x100,%ebp
je     11f9 <main+0xa9>
mov    $0xff,%ebx
cmp    $0xba,%ebp
ja     1190 <main+0x40>
movsd  0x8(%rsp),%xmm0
divsd  0xe1d(%rip),%xmm0
movsd  0xe1d(%rip),%xmm1
call   1070 <pow@plt>
mov    %eax,%ebx
shl    $0x8,%ebx
sub    %eax,%ebx
jmp    1190 <main+0x40>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"compressor_lut.hex\00"
@.str.1 = [3 x i8] c"wt\00"
@.str.2 = [12 x i8] c"%4d -> %4d\0A\00"
@.str.3 = [6 x i8] c"%.2X\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
store i32 0, i32* %3
br label %7
7: ; preds = %28, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 256
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = load i32, i32* %3
%12 = icmp sle i32 %11, 186
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %3
%15 = sitofp i32 %14 to double
%16 = fdiv double %15, 1.860000e+02
store double %16, double* %5
%17 = load double, double* %5
%18 = call i32 @pow(double %17, double 7.500000e-01)
%19 = mul nsw i32 255, %18
store i32 %19, i32* %4
br label %21
20: ; preds = %10
store i32 255, i32* %4
br label %21
21: ; preds = %20, %13
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %23)
%25 = load i32*, i32** %2
%26 = load i32, i32* %4
%27 = call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %21
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %7
31: ; preds = %7
%32 = load i32*, i32** %2
%33 = call i32 @fclose(i32* %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"compressor_lut.hex\00"
@.str.1 = [3 x i8] c"wt\00"
@.str.2 = [12 x i8] c"%4d -> %4d\0A\00"
@.str.3 = [6 x i8] c"%.2X\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %2
2: ; preds = %0, %10
%3 = phi i32 [ 0, %0 ], [ %14, %10 ]
%4 = icmp ult i32 %3, 187
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = sitofp i32 %3 to double
%7 = fdiv double %6, 1.860000e+02
%8 = tail call i32 @pow(double %7, double 7.500000e-01)
%9 = mul nsw i32 %8, 255
br label %10
10: ; preds = %2, %5
%11 = phi i32 [ %9, %5 ], [ 255, %2 ]
%12 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 %11)
%13 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%14 = add nuw nsw i32 %3, 1
%15 = icmp eq i32 %14, 256
br i1 %15, label %16, label %2
16: ; preds = %10
%17 = tail call i32 @fclose(i32* %1)
ret i32 0
}