#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 pow(double, double);
double sin(int);
int color_func(int iterations, int max_iter) {
  double val = (double)(5 + iterations) / (5 + max_iter);
  double sinus = sin(20 * pow(val, 0.1));
  double sinus2 = sin(13 * pow(val, 0.125));
  double sinus3 = sin(17 * pow(val, 0.07));
  return (unsigned char)((sinus + 1) * 127.5) +
         ((unsigned char)((sinus2 + 1) * 127.5) << 8) +
         ((unsigned char)((sinus3 + 1) * 127.5) << 16);
}


x86 assembly (clang, -O0):
<color_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x5,%eax
cvtsi2sd %eax,%xmm0
mov    -0x8(%rbp),%eax
add    $0x5,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xea8(%rip),%xmm1
call   1040 <pow@plt>
mov    %eax,%ecx
shl    $0x2,%ecx
mov    %ecx,%eax
lea    (%rax,%rax,4),%edi
call   1030 <sin@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe8a(%rip),%xmm1
call   1040 <pow@plt>
mov    %eax,%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%edx
mov    %edx,%ecx
lea    (%rax,%rcx,4),%edi
call   1030 <sin@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe6a(%rip),%xmm1
call   1040 <pow@plt>
mov    %eax,%edi
mov    %edi,%eax
shl    $0x4,%eax
add    %eax,%edi
call   1030 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe4d(%rip),%xmm2
addsd  %xmm2,%xmm0
movsd  0xe49(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movzbl %al,%eax
movsd  -0x20(%rbp),%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
movzbl %cl,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movsd  -0x28(%rbp),%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
movzbl %cl,%ecx
shl    $0x10,%ecx
add    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<color_func>:
sub    $0x18,%rsp
add    $0x5,%edi
cvtsi2sd %edi,%xmm0
add    $0x5,%esi
cvtsi2sd %esi,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  0xebd(%rip),%xmm1
call   1040 <pow@plt>
shl    $0x2,%eax
lea    (%rax,%rax,4),%edi
call   1030 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xea7(%rip),%xmm1
movsd  (%rsp),%xmm0
call   1040 <pow@plt>
lea    (%rax,%rax,2),%ecx
lea    (%rax,%rcx,4),%edi
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe8c(%rip),%xmm1
movsd  (%rsp),%xmm0
call   1040 <pow@plt>
mov    %eax,%edi
shl    $0x4,%edi
add    %eax,%edi
call   1030 <sin@plt>
movsd  0xe76(%rip),%xmm1
movsd  0x10(%rsp),%xmm3
addsd  %xmm1,%xmm3
movsd  0xe6c(%rip),%xmm2
mulsd  %xmm2,%xmm3
cvttsd2si %xmm3,%eax
movzbl %al,%eax
movsd  0x8(%rsp),%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
cvttsd2si %xmm3,%ecx
movzbl %cl,%ecx
shl    $0x8,%ecx
addsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edx
or     %eax,%ecx
movzbl %dl,%eax
shl    $0x10,%eax
or     %ecx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @color_func(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %3
%10 = add nsw i32 5, %9
%11 = sitofp i32 %10 to double
%12 = load i32, i32* %4
%13 = add nsw i32 5, %12
%14 = sitofp i32 %13 to double
%15 = fdiv double %11, %14
store double %15, double* %5
%16 = load double, double* %5
%17 = call i32 @pow(double %16, double 1.000000e-01)
%18 = mul nsw i32 20, %17
%19 = call double @sin(i32 %18)
store double %19, double* %6
%20 = load double, double* %5
%21 = call i32 @pow(double %20, double 1.250000e-01)
%22 = mul nsw i32 13, %21
%23 = call double @sin(i32 %22)
store double %23, double* %7
%24 = load double, double* %5
%25 = call i32 @pow(double %24, double 7.000000e-02)
%26 = mul nsw i32 17, %25
%27 = call double @sin(i32 %26)
store double %27, double* %8
%28 = load double, double* %6
%29 = fadd double %28, 1.000000e+00
%30 = fmul double %29, 1.275000e+02
%31 = fptoui double %30 to i8
%32 = zext i8 %31 to i32
%33 = load double, double* %7
%34 = fadd double %33, 1.000000e+00
%35 = fmul double %34, 1.275000e+02
%36 = fptoui double %35 to i8
%37 = zext i8 %36 to i32
%38 = shl i32 %37, 8
%39 = add nsw i32 %32, %38
%40 = load double, double* %8
%41 = fadd double %40, 1.000000e+00
%42 = fmul double %41, 1.275000e+02
%43 = fptoui double %42 to i8
%44 = zext i8 %43 to i32
%45 = shl i32 %44, 16
%46 = add nsw i32 %39, %45
ret i32 %46
}

LLVM IR (-O2):
define i32 @color_func(i32 %0, i32 %1) {
%3 = add nsw i32 %0, 5
%4 = sitofp i32 %3 to double
%5 = add nsw i32 %1, 5
%6 = sitofp i32 %5 to double
%7 = fdiv double %4, %6
%8 = tail call i32 @pow(double %7, double 1.000000e-01)
%9 = mul nsw i32 %8, 20
%10 = tail call double @sin(i32 %9)
%11 = tail call i32 @pow(double %7, double 1.250000e-01)
%12 = mul nsw i32 %11, 13
%13 = tail call double @sin(i32 %12)
%14 = tail call i32 @pow(double %7, double 7.000000e-02)
%15 = mul nsw i32 %14, 17
%16 = tail call double @sin(i32 %15)
%17 = fadd double %10, 1.000000e+00
%18 = fmul double %17, 1.275000e+02
%19 = fptoui double %18 to i8
%20 = zext i8 %19 to i32
%21 = fadd double %13, 1.000000e+00
%22 = fmul double %21, 1.275000e+02
%23 = fptoui double %22 to i8
%24 = zext i8 %23 to i32
%25 = shl nuw nsw i32 %24, 8
%26 = or i32 %25, %20
%27 = fadd double %16, 1.000000e+00
%28 = fmul double %27, 1.275000e+02
%29 = fptoui double %28 to i8
%30 = zext i8 %29 to i32
%31 = shl nuw nsw i32 %30, 16
%32 = or i32 %31, %26
ret i32 %32
}