#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(int);
double sin(int);
int kff_synthese_einzelpunkt(double lambda, char winkelmass, double **leg_func,
                             int mindeg, int maxdeg, double **c_lm,
                             double **s_lm, double *f) {
  double fzw;
  int l;
  int m;
  *f = 0.;
  mindeg = (mindeg < 0) ? 0 : mindeg;
  if (winkelmass == 'A')
    lambda *= (3.141592653589793 / 180.0);
  for (l = mindeg; l <= maxdeg; l++) {
    fzw = leg_func[l][0] * c_lm[l][0];
    for (m = 1; m <= l; m++) {
      fzw += (leg_func[l][m] *
              (c_lm[l][m] * cos(m * lambda) + s_lm[l][m] * sin(m * lambda)));
    }
    *f += fzw;
  }
  return 0;
}


x86 assembly (clang, -O0):
<kff_synthese_einzelpunkt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %dil,%al
mov    0x10(%rbp),%rdi
movsd  %xmm0,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
cmpl   $0x0,-0x1c(%rbp)
jge    1168 <kff_synthese_einzelpunkt+0x48>
xor    %eax,%eax
mov    %eax,-0x44(%rbp)
jmp    116e <kff_synthese_einzelpunkt+0x4e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x41,%eax
jne    1193 <kff_synthese_einzelpunkt+0x73>
movsd  0xe77(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     12b8 <kff_synthese_einzelpunkt+0x198>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jg     1299 <kff_synthese_einzelpunkt+0x179>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
cvtsi2sdl -0x40(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
cvtsi2sdl -0x40(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm3
movaps %xmm0,%xmm4
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm4,%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11d1 <kff_synthese_einzelpunkt+0xb1>
movsd  -0x38(%rbp),%xmm0
mov    0x10(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1199 <kff_synthese_einzelpunkt+0x79>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kff_synthese_einzelpunkt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,%r12
mov    %rcx,0x8(%rsp)
mov    0x90(%rsp),%rbx
movq   $0x0,(%rbx)
xor    %eax,%eax
test   %edx,%edx
cmovns %edx,%eax
cmp    $0x41,%dil
jne    115a <kff_synthese_einzelpunkt+0x3a>
mulsd  0xea6(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
cmp    0x8(%rsp),%eax
jle    1177 <kff_synthese_einzelpunkt+0x57>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r13d
cvttsd2si 0x10(%rsp),%eax
mov    %eax,0x44(%rsp)
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
mov    $0x1,%edx
sub    %r13,%rdx
xorpd  %xmm0,%xmm0
jmp    11d2 <kff_synthese_einzelpunkt+0xb2>
nop
mov    %rbx,%r8
mov    %r15,%rsi
mov    0x48(%rsp),%rdx
mov    0x90(%rsp),%rbx
movsd  (%rbx),%xmm0
mov    0x50(%rsp),%r14
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rbx)
add    $0xffffffffffffffff,%rdx
mov    %r14,%r13
cmp    0x8(%rsp),%r14
je     1166 <kff_synthese_einzelpunkt+0x46>
lea    0x1(%r13),%r14
mov    (%rsi,%r13,8),%rax
movsd  (%rax),%xmm1
mov    (%r8,%r13,8),%rcx
mulsd  (%rcx),%xmm1
test   %r13,%r13
je     11bc <kff_synthese_einzelpunkt+0x9c>
mov    %rdx,0x48(%rsp)
mov    %rsi,%r15
mov    %r8,%rbx
movsd  0x8(%rax),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rcx),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    0x44(%rsp),%ebp
mov    %ebp,%edi
movsd  %xmm1,0x28(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x38(%rsp)
mov    (%r12,%r13,8),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,0x18(%rsp)
mov    %ebp,%edi
call   1030 <sin@plt>
movsd  0x38(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
mulsd  0x30(%rsp),%xmm1
addsd  0x28(%rsp),%xmm1
cmp    $0x1,%r13
mov    %r14,0x50(%rsp)
je     11a0 <kff_synthese_einzelpunkt+0x80>
mov    $0x2,%r14d
mov    %rbx,%r8
mov    %r15,%rsi
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm1,0x38(%rsp)
mov    (%rsi,%r13,8),%rax
mov    (%r8,%r13,8),%rcx
movsd  (%rax,%r14,8),%xmm0
movsd  %xmm0,0x30(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movsd  (%rcx,%r14,8),%xmm1
movsd  %xmm1,0x28(%rsp)
mulsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%ebp
mov    %ebp,%edi
call   1040 <cos@plt>
movsd  %xmm0,0x20(%rsp)
mov    (%r12,%r13,8),%rax
movsd  (%rax,%r14,8),%xmm0
movsd  %xmm0,0x18(%rsp)
mov    %ebp,%edi
call   1030 <sin@plt>
movsd  0x38(%rsp),%xmm1
mov    0x48(%rsp),%rdx
mov    %r15,%rsi
mov    %rbx,%r8
mulsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm2
mulsd  0x28(%rsp),%xmm2
addsd  %xmm0,%xmm2
mulsd  0x30(%rsp),%xmm2
addsd  %xmm2,%xmm1
lea    (%rdx,%r14,1),%rax
add    $0x1,%rax
add    $0x1,%r14
cmp    $0x2,%rax
jne    1280 <kff_synthese_einzelpunkt+0x160>
jmp    11ab <kff_synthese_einzelpunkt+0x8b>

LLVM IR (-O0):
define i32 @kff_synthese_einzelpunkt(double %0, i8 signext %1, double** %2, i32 %3, i32 %4, double** %5, double** %6, double* %7) {
%9 = alloca double
%10 = alloca i8
%11 = alloca double**
%12 = alloca i32
%13 = alloca i32
%14 = alloca double**
%15 = alloca double**
%16 = alloca double*
%17 = alloca double
%18 = alloca i32
%19 = alloca i32
store double %0, double* %9
store i8 %1, i8* %10
store double** %2, double*** %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store double** %5, double*** %14
store double** %6, double*** %15
store double* %7, double** %16
%20 = load double*, double** %16
store double 0.000000e+00, double* %20
%21 = load i32, i32* %12
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %8
br label %26
24: ; preds = %8
%25 = load i32, i32* %12
br label %26
26: ; preds = %24, %23
%27 = phi i32 [ 0, %23 ], [ %25, %24 ]
store i32 %27, i32* %12
%28 = load i8, i8* %10
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 65
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load double, double* %9
%33 = fmul double %32, 0x3F91DF46A2529D39
store double %33, double* %9
br label %34
34: ; preds = %31, %26
%35 = load i32, i32* %12
store i32 %35, i32* %18
br label %36
36: ; preds = %112, %34
%37 = load i32, i32* %18
%38 = load i32, i32* %13
%39 = icmp sle i32 %37, %38
br i1 %39, label %40, label %115
40: ; preds = %36
%41 = load double**, double*** %11
%42 = load i32, i32* %18
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double*, double** %41, i64 %43
%45 = load double*, double** %44
%46 = getelementptr inbounds double, double* %45, i64 0
%47 = load double, double* %46
%48 = load double**, double*** %14
%49 = load i32, i32* %18
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double*, double** %48, i64 %50
%52 = load double*, double** %51
%53 = getelementptr inbounds double, double* %52, i64 0
%54 = load double, double* %53
%55 = fmul double %47, %54
store double %55, double* %17
store i32 1, i32* %19
br label %56
56: ; preds = %104, %40
%57 = load i32, i32* %19
%58 = load i32, i32* %18
%59 = icmp sle i32 %57, %58
br i1 %59, label %60, label %107
60: ; preds = %56
%61 = load double**, double*** %11
%62 = load i32, i32* %18
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds double*, double** %61, i64 %63
%65 = load double*, double** %64
%66 = load i32, i32* %19
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
%69 = load double, double* %68
%70 = load double**, double*** %14
%71 = load i32, i32* %18
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double*, double** %70, i64 %72
%74 = load double*, double** %73
%75 = load i32, i32* %19
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %74, i64 %76
%78 = load double, double* %77
%79 = load i32, i32* %19
%80 = sitofp i32 %79 to double
%81 = load double, double* %9
%82 = fmul double %80, %81
%83 = fptosi double %82 to i32
%84 = call double @cos(i32 %83)
%85 = load double**, double*** %15
%86 = load i32, i32* %18
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds double*, double** %85, i64 %87
%89 = load double*, double** %88
%90 = load i32, i32* %19
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %89, i64 %91
%93 = load double, double* %92
%94 = load i32, i32* %19
%95 = sitofp i32 %94 to double
%96 = load double, double* %9
%97 = fmul double %95, %96
%98 = fptosi double %97 to i32
%99 = call double @sin(i32 %98)
%100 = fmul double %93, %99
%101 = call double @llvm.fmuladd.f64(double %78, double %84, double %100)
%102 = load double, double* %17
%103 = call double @llvm.fmuladd.f64(double %69, double %101, double %102)
store double %103, double* %17
br label %104
104: ; preds = %60
%105 = load i32, i32* %19
%106 = add nsw i32 %105, 1
store i32 %106, i32* %19
br label %56
107: ; preds = %56
%108 = load double, double* %17
%109 = load double*, double** %16
%110 = load double, double* %109
%111 = fadd double %110, %108
store double %111, double* %109
br label %112
112: ; preds = %107
%113 = load i32, i32* %18
%114 = add nsw i32 %113, 1
store i32 %114, i32* %18
br label %36
115: ; preds = %36
ret i32 0
}

LLVM IR (-O2):
define i32 @kff_synthese_einzelpunkt(double %0, i8 signext %1, double** nocapture %2, i32 %3, i32 %4, double** nocapture %5, double** nocapture %6, double* nocapture %7) {
store double 0.000000e+00, double* %7
%9 = icmp sgt i32 %3, 0
%10 = select i1 %9, i32 %3, i32 0
%11 = icmp eq i8 %1, 65
%12 = fmul double %0, 0x3F91DF46A2529D39
%13 = select i1 %11, double %12, double %0
%14 = icmp sgt i32 %10, %4
br i1 %14, label %80, label %15
15: ; preds = %8
%16 = zext i32 %10 to i64
%17 = add i32 %4, 1
%18 = zext i32 %17 to i64
%19 = fptosi double %13 to i32
br label %20
20: ; preds = %15, %74
%21 = phi double [ 0.000000e+00, %15 ], [ %77, %74 ]
%22 = phi i64 [ %16, %15 ], [ %78, %74 ]
%23 = phi i64 [ %16, %15 ], [ %24, %74 ]
%24 = add nuw nsw i64 %23, 1
%25 = getelementptr inbounds double*, double** %2, i64 %22
%26 = load double*, double** %25
%27 = load double, double* %26
%28 = getelementptr inbounds double*, double** %5, i64 %22
%29 = load double*, double** %28
%30 = load double, double* %29
%31 = fmul double %27, %30
%32 = icmp eq i64 %22, 0
br i1 %32, label %74, label %33
33: ; preds = %20
%34 = getelementptr inbounds double*, double** %6, i64 %22
%35 = getelementptr inbounds double, double* %26, i64 1
%36 = load double, double* %35
%37 = getelementptr inbounds double, double* %29, i64 1
%38 = load double, double* %37
%39 = tail call double @cos(i32 %19)
%40 = load double*, double** %34
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = tail call double @sin(i32 %19)
%44 = fmul double %42, %43
%45 = tail call double @llvm.fmuladd.f64(double %38, double %39, double %44)
%46 = tail call double @llvm.fmuladd.f64(double %36, double %45, double %31)
%47 = icmp eq i64 %23, 1
br i1 %47, label %71, label %48
48: ; preds = %33, %48
%49 = phi double [ %69, %48 ], [ %46, %33 ]
%50 = phi i64 [ %51, %48 ], [ 1, %33 ]
%51 = add nuw nsw i64 %50, 1
%52 = load double*, double** %25
%53 = load double*, double** %28
%54 = getelementptr inbounds double, double* %52, i64 %51
%55 = load double, double* %54
%56 = getelementptr inbounds double, double* %53, i64 %51
%57 = load double, double* %56
%58 = trunc i64 %51 to i32
%59 = sitofp i32 %58 to double
%60 = fmul double %13, %59
%61 = fptosi double %60 to i32
%62 = tail call double @cos(i32 %61)
%63 = load double*, double** %34
%64 = getelementptr inbounds double, double* %63, i64 %51
%65 = load double, double* %64
%66 = tail call double @sin(i32 %61)
%67 = fmul double %65, %66
%68 = tail call double @llvm.fmuladd.f64(double %57, double %62, double %67)
%69 = tail call double @llvm.fmuladd.f64(double %55, double %68, double %49)
%70 = icmp eq i64 %51, %23
br i1 %70, label %71, label %48
71: ; preds = %48, %33
%72 = phi double [ %46, %33 ], [ %69, %48 ]
%73 = load double, double* %7
br label %74
74: ; preds = %71, %20
%75 = phi double [ %21, %20 ], [ %73, %71 ]
%76 = phi double [ %31, %20 ], [ %72, %71 ]
%77 = fadd double %76, %75
store double %77, double* %7
%78 = add nuw nsw i64 %22, 1
%79 = icmp eq i64 %78, %18
br i1 %79, label %80, label %20
80: ; preds = %74, %8
ret i32 0
}