#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 */
double mandelbrot_iter(double, double, double, double, int);
double mandelbrot_range(double zx, double zy, double cx, double cy, int maxiter,
                        double offset) {
  double i = mandelbrot_iter(zx, zy, cx, cy, maxiter);
  return (i * (offset + maxiter)) / ((i + offset) * maxiter);
}


x86 assembly (clang, -O0):
<mandelbrot_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
mov    -0x24(%rbp),%edi
call   1030 <mandelbrot_iter@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm1
addsd  -0x30(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mandelbrot_range>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm4,0x8(%rsp)
mov    %edi,%ebx
call   1030 <mandelbrot_iter@plt>
xorps  %xmm2,%xmm2
cvtsi2sd %ebx,%xmm2
movapd %xmm2,%xmm1
movsd  0x8(%rsp),%xmm3
addsd  %xmm3,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @mandelbrot_range(double %0, double %1, double %2, double %3, i32 %4, double %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store i32 %4, i32* %11
store double %5, double* %12
%14 = load double, double* %7
%15 = load double, double* %8
%16 = load double, double* %9
%17 = load double, double* %10
%18 = load i32, i32* %11
%19 = call double @mandelbrot_iter(double %14, double %15, double %16, double %17, i32 %18)
store double %19, double* %13
%20 = load double, double* %13
%21 = load double, double* %12
%22 = load i32, i32* %11
%23 = sitofp i32 %22 to double
%24 = fadd double %21, %23
%25 = fmul double %20, %24
%26 = load double, double* %13
%27 = load double, double* %12
%28 = fadd double %26, %27
%29 = load i32, i32* %11
%30 = sitofp i32 %29 to double
%31 = fmul double %28, %30
%32 = fdiv double %25, %31
ret double %32
}

LLVM IR (-O2):
define double @mandelbrot_range(double %0, double %1, double %2, double %3, i32 %4, double %5) {
%7 = tail call double @mandelbrot_iter(double %0, double %1, double %2, double %3, i32 %4)
%8 = sitofp i32 %4 to double
%9 = fadd double %8, %5
%10 = fmul double %9, %7
%11 = fadd double %7, %5
%12 = fmul double %11, %8
%13 = fdiv double %10, %12
ret double %13
}