#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 cos(double);
double fabs(int);
double log(double);
double sin(double);
void hypfm(double *result_real, double *result_imag, double f1, double f2,
           int n) {
  int i;
  double phi;
  int type = 1;
  double beta0, f0;
  beta0 = (2. * (f1 - f2)) / ((f1 + f2) * (double)n);
  f0 = f1 * (1. - beta0 * (double)n / 2.);
  if (result_imag == NULL)
    for (i = 0; i < n; i++) {
      if (type == 1) {
        phi = (f0 / beta0) *
              log(fabs(1. + beta0 * ((double)i - (double)n / 2.0)));
        result_real[i] = cos(2.0 * 3.14159265358979323846 * phi);
      } else {
        phi = f1 * log((double)i + 1.);
        result_real[i] = cos(2.0 * 3.14159265358979323846 * phi);
      }
    }
  else
    for (i = 0; i < n; i++) {
      if (type == 1) {
        phi = (f0 / beta0) *
              log(fabs(1. + beta0 * ((double)i - (double)n / 2.0)));
        result_real[i] = cos(2.0 * 3.14159265358979323846 * phi);
        result_imag[i] = sin(2.0 * 3.14159265358979323846 * phi);
      } else {
        phi = f1 * log((double)i + 1.0);
        result_real[i] = cos(2.0 * 3.14159265358979323846 * phi);
        result_imag[i] = sin(2.0 * 3.14159265358979323846 * phi);
      }
    }
}


x86 assembly (clang, -O0):
<hypfm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
movl   $0x1,-0x34(%rbp)
movsd  -0x18(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  0xe92(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
cvtsi2sdl -0x24(%rbp),%xmm1
mulsd  %xmm1,%xmm2
movsd  0xe57(%rip),%xmm1
divsd  %xmm1,%xmm2
movsd  0xe43(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    12db <hypfm+0x19b>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12d6 <hypfm+0x196>
cmpl   $0x1,-0x34(%rbp)
jne    1273 <hypfm+0x133>
movsd  -0x48(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x28(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm2
movsd  0xdf0(%rip),%xmm3
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdd4(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <fabs@plt>
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xdb9(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    12c3 <hypfm+0x183>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
movsd  0xd76(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xd64(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    12c8 <hypfm+0x188>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11dc <hypfm+0x9c>
jmp    141f <hypfm+0x2df>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    141a <hypfm+0x2da>
cmpl   $0x1,-0x34(%rbp)
jne    1398 <hypfm+0x258>
movsd  -0x48(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x28(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm2
movsd  0xcea(%rip),%xmm3
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xcce(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <fabs@plt>
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xcb3(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xc94(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1040 <sin@plt>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1407 <hypfm+0x2c7>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
movsd  0xc51(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xc3f(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xc20(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1040 <sin@plt>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    140c <hypfm+0x2cc>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12e2 <hypfm+0x1a2>
jmp    141f <hypfm+0x2df>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hypfm>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r14
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
addsd  %xmm2,%xmm2
addsd  %xmm0,%xmm1
cvtsi2sd %edx,%xmm3
mulsd  %xmm3,%xmm1
divsd  %xmm1,%xmm2
movapd %xmm2,%xmm1
mulsd  %xmm3,%xmm1
mulsd  0xe86(%rip),%xmm1
addsd  0xe86(%rip),%xmm1
mulsd  %xmm0,%xmm1
test   %rsi,%rsi
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x8(%rsp)
je     123f <hypfm+0xff>
test   %edx,%edx
jle    12c3 <hypfm+0x183>
mov    %rsi,%r15
movsd  0x8(%rsp),%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  0xe52(%rip),%xmm3
mov    %edx,%r12d
xor    %ebx,%ebx
movsd  %xmm3,0x10(%rsp)
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
subsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm0
addsd  0xe21(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <fabs@plt>
call   1060 <log@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0xe15(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
call   1050 <cos@plt>
movsd  %xmm0,(%r14,%rbx,8)
movsd  0x20(%rsp),%xmm0
call   1040 <sin@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm2
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11d0 <hypfm+0x90>
jmp    12c3 <hypfm+0x183>
test   %edx,%edx
jle    12c3 <hypfm+0x183>
movsd  0x8(%rsp),%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  0xdb1(%rip),%xmm3
mov    %edx,%r15d
xor    %ebx,%ebx
movsd  %xmm3,0x10(%rsp)
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
subsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm0
addsd  0xd81(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <fabs@plt>
call   1060 <log@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0xd75(%rip),%xmm0
call   1050 <cos@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm2
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1270 <hypfm+0x130>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @hypfm(double* %0, double* %1, double %2, double %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca i32
%14 = alloca double
%15 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store double %2, double* %8
store double %3, double* %9
store i32 %4, i32* %10
store i32 1, i32* %13
%16 = load double, double* %8
%17 = load double, double* %9
%18 = fsub double %16, %17
%19 = fmul double 2.000000e+00, %18
%20 = load double, double* %8
%21 = load double, double* %9
%22 = fadd double %20, %21
%23 = load i32, i32* %10
%24 = sitofp i32 %23 to double
%25 = fmul double %22, %24
%26 = fdiv double %19, %25
store double %26, double* %14
%27 = load double, double* %8
%28 = load double, double* %14
%29 = load i32, i32* %10
%30 = sitofp i32 %29 to double
%31 = fmul double %28, %30
%32 = fdiv double %31, 2.000000e+00
%33 = fsub double 1.000000e+00, %32
%34 = fmul double %27, %33
store double %34, double* %15
%35 = load double*, double** %7
%36 = icmp eq double* %35, null
br i1 %36, label %37, label %87
37: ; preds = %5
store i32 0, i32* %11
br label %38
38: ; preds = %83, %37
%39 = load i32, i32* %11
%40 = load i32, i32* %10
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %86
42: ; preds = %38
%43 = load i32, i32* %13
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %68
45: ; preds = %42
%46 = load double, double* %15
%47 = load double, double* %14
%48 = fdiv double %46, %47
%49 = load double, double* %14
%50 = load i32, i32* %11
%51 = sitofp i32 %50 to double
%52 = load i32, i32* %10
%53 = sitofp i32 %52 to double
%54 = fdiv double %53, 2.000000e+00
%55 = fsub double %51, %54
%56 = call double @llvm.fmuladd.f64(double %49, double %55, double 1.000000e+00)
%57 = fptosi double %56 to i32
%58 = call double @fabs(i32 %57)
%59 = call double @log(double %58)
%60 = fmul double %48, %59
store double %60, double* %12
%61 = load double, double* %12
%62 = fmul double 0x401921FB54442D18, %61
%63 = call double @cos(double %62)
%64 = load double*, double** %6
%65 = load i32, i32* %11
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
store double %63, double* %67
br label %82
68: ; preds = %42
%69 = load double, double* %8
%70 = load i32, i32* %11
%71 = sitofp i32 %70 to double
%72 = fadd double %71, 1.000000e+00
%73 = call double @log(double %72)
%74 = fmul double %69, %73
store double %74, double* %12
%75 = load double, double* %12
%76 = fmul double 0x401921FB54442D18, %75
%77 = call double @cos(double %76)
%78 = load double*, double** %6
%79 = load i32, i32* %11
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %78, i64 %80
store double %77, double* %81
br label %82
82: ; preds = %68, %45
br label %83
83: ; preds = %82
%84 = load i32, i32* %11
%85 = add nsw i32 %84, 1
store i32 %85, i32* %11
br label %38
86: ; preds = %38
br label %151
87: ; preds = %5
store i32 0, i32* %11
br label %88
88: ; preds = %147, %87
%89 = load i32, i32* %11
%90 = load i32, i32* %10
%91 = icmp slt i32 %89, %90
br i1 %91, label %92, label %150
92: ; preds = %88
%93 = load i32, i32* %13
%94 = icmp eq i32 %93, 1
br i1 %94, label %95, label %125
95: ; preds = %92
%96 = load double, double* %15
%97 = load double, double* %14
%98 = fdiv double %96, %97
%99 = load double, double* %14
%100 = load i32, i32* %11
%101 = sitofp i32 %100 to double
%102 = load i32, i32* %10
%103 = sitofp i32 %102 to double
%104 = fdiv double %103, 2.000000e+00
%105 = fsub double %101, %104
%106 = call double @llvm.fmuladd.f64(double %99, double %105, double 1.000000e+00)
%107 = fptosi double %106 to i32
%108 = call double @fabs(i32 %107)
%109 = call double @log(double %108)
%110 = fmul double %98, %109
store double %110, double* %12
%111 = load double, double* %12
%112 = fmul double 0x401921FB54442D18, %111
%113 = call double @cos(double %112)
%114 = load double*, double** %6
%115 = load i32, i32* %11
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds double, double* %114, i64 %116
store double %113, double* %117
%118 = load double, double* %12
%119 = fmul double 0x401921FB54442D18, %118
%120 = call double @sin(double %119)
%121 = load double*, double** %7
%122 = load i32, i32* %11
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds double, double* %121, i64 %123
store double %120, double* %124
br label %146
125: ; preds = %92
%126 = load double, double* %8
%127 = load i32, i32* %11
%128 = sitofp i32 %127 to double
%129 = fadd double %128, 1.000000e+00
%130 = call double @log(double %129)
%131 = fmul double %126, %130
store double %131, double* %12
%132 = load double, double* %12
%133 = fmul double 0x401921FB54442D18, %132
%134 = call double @cos(double %133)
%135 = load double*, double** %6
%136 = load i32, i32* %11
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds double, double* %135, i64 %137
store double %134, double* %138
%139 = load double, double* %12
%140 = fmul double 0x401921FB54442D18, %139
%141 = call double @sin(double %140)
%142 = load double*, double** %7
%143 = load i32, i32* %11
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds double, double* %142, i64 %144
store double %141, double* %145
br label %146
146: ; preds = %125, %95
br label %147
147: ; preds = %146
%148 = load i32, i32* %11
%149 = add nsw i32 %148, 1
store i32 %149, i32* %11
br label %88
150: ; preds = %88
br label %151
151: ; preds = %150, %86
ret void
}

LLVM IR (-O2):
define void @hypfm(double* nocapture writeonly %0, double* writeonly %1, double %2, double %3, i32 %4) {
%6 = fsub double %2, %3
%7 = fmul double %6, 2.000000e+00
%8 = fadd double %2, %3
%9 = sitofp i32 %4 to double
%10 = fmul double %8, %9
%11 = fdiv double %7, %10
%12 = fmul double %11, %9
%13 = fmul double %12, 5.000000e-01
%14 = fsub double 1.000000e+00, %13
%15 = fmul double %14, %2
%16 = icmp eq double* %1, null
%17 = icmp sgt i32 %4, 0
br i1 %16, label %23, label %18
18: ; preds = %5
br i1 %17, label %19, label %60
19: ; preds = %18
%20 = fdiv double %15, %11
%21 = fmul double %9, 5.000000e-01
%22 = zext i32 %4 to i64
br label %43
23: ; preds = %5
br i1 %17, label %24, label %60
24: ; preds = %23
%25 = fdiv double %15, %11
%26 = fmul double %9, 5.000000e-01
%27 = zext i32 %4 to i64
br label %28
28: ; preds = %24, %28
%29 = phi i64 [ 0, %24 ], [ %41, %28 ]
%30 = trunc i64 %29 to i32
%31 = sitofp i32 %30 to double
%32 = fsub double %31, %26
%33 = tail call double @llvm.fmuladd.f64(double %11, double %32, double 1.000000e+00)
%34 = fptosi double %33 to i32
%35 = tail call double @fabs(i32 %34)
%36 = tail call double @log(double %35)
%37 = fmul double %25, %36
%38 = fmul double %37, 0x401921FB54442D18
%39 = tail call double @cos(double %38)
%40 = getelementptr inbounds double, double* %0, i64 %29
store double %39, double* %40
%41 = add nuw nsw i64 %29, 1
%42 = icmp eq i64 %41, %27
br i1 %42, label %60, label %28
43: ; preds = %19, %43
%44 = phi i64 [ 0, %19 ], [ %58, %43 ]
%45 = trunc i64 %44 to i32
%46 = sitofp i32 %45 to double
%47 = fsub double %46, %21
%48 = tail call double @llvm.fmuladd.f64(double %11, double %47, double 1.000000e+00)
%49 = fptosi double %48 to i32
%50 = tail call double @fabs(i32 %49)
%51 = tail call double @log(double %50)
%52 = fmul double %20, %51
%53 = fmul double %52, 0x401921FB54442D18
%54 = tail call double @cos(double %53)
%55 = getelementptr inbounds double, double* %0, i64 %44
store double %54, double* %55
%56 = tail call double @sin(double %53)
%57 = getelementptr inbounds double, double* %1, i64 %44
store double %56, double* %57
%58 = add nuw nsw i64 %44, 1
%59 = icmp eq i64 %58, %22
br i1 %59, label %60, label %43
60: ; preds = %43, %28, %18, %23
ret void
}