#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 log(double);
double pow(double, int);
double envelope_norm(double a, double xmin, double xmax) {
  if (a == 1) {
    return log(xmax / xmin);
  } else {
    return (pow(xmin, 1. - a) - pow(xmax, 1. - a)) / (a - 1.);
  }
}


x86 assembly (clang, -O0):
<envelope_norm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xebc(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    116d <envelope_norm+0x4d>
jp     116d <envelope_norm+0x4d>
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11ce <envelope_norm+0xae>
movsd  -0x18(%rbp),%xmm0
movsd  0xe86(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
cvttsd2si %xmm1,%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe66(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
cvttsd2si %xmm1,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe3f(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<envelope_norm>:
push   %rbx
sub    $0x20,%rsp
ucomisd 0xed3(%rip),%xmm0
jne    1143 <envelope_norm+0x23>
jp     1143 <envelope_norm+0x23>
divsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
add    $0x20,%rsp
pop    %rbx
jmp    1030 <log@plt>
movapd %xmm0,%xmm3
movsd  0xeb1(%rip),%xmm0
subsd  %xmm3,%xmm0
cvttsd2si %xmm0,%ebx
movaps %xmm1,%xmm0
mov    %ebx,%edi
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x8(%rsp)
call   1040 <pow@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mov    %ebx,%edi
call   1040 <pow@plt>
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x18(%rsp),%xmm0
addsd  0xe70(%rip),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @envelope_norm(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%8 = load double, double* %5
%9 = fcmp oeq double %8, 1.000000e+00
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = load double, double* %7
%12 = load double, double* %6
%13 = fdiv double %11, %12
%14 = call double @log(double %13)
store double %14, double* %4
br label %30
15: ; preds = %3
%16 = load double, double* %6
%17 = load double, double* %5
%18 = fsub double 1.000000e+00, %17
%19 = fptosi double %18 to i32
%20 = call double @pow(double %16, i32 %19)
%21 = load double, double* %7
%22 = load double, double* %5
%23 = fsub double 1.000000e+00, %22
%24 = fptosi double %23 to i32
%25 = call double @pow(double %21, i32 %24)
%26 = fsub double %20, %25
%27 = load double, double* %5
%28 = fsub double %27, 1.000000e+00
%29 = fdiv double %26, %28
store double %29, double* %4
br label %30
30: ; preds = %15, %10
%31 = load double, double* %4
ret double %31
}

LLVM IR (-O2):
define double @envelope_norm(double %0, double %1, double %2) {
%4 = fcmp oeq double %0, 1.000000e+00
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = fdiv double %2, %1
%7 = tail call double @log(double %6)
br label %16
8: ; preds = %3
%9 = fsub double 1.000000e+00, %0
%10 = fptosi double %9 to i32
%11 = tail call double @pow(double %1, i32 %10)
%12 = tail call double @pow(double %2, i32 %10)
%13 = fsub double %11, %12
%14 = fadd double %0, -1.000000e+00
%15 = fdiv double %13, %14
br label %16
16: ; preds = %8, %5
%17 = phi double [ %7, %5 ], [ %15, %8 ]
ret double %17
}