#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 M_PI;
double fabs(int /*<<< orphan*/);
int floor(double);
int /*<<< orphan*/ fmod(double, int);
double find_speed_polar(double *polar_tab, double wind_speed,
                        double wind_angle) {
  int intangle;
  int intspeed;
  double valfloor, valceil;
  intspeed = floor(wind_speed);
  if (intspeed > 60) {
    intspeed = 60;
  }
  intangle = floor((((fabs(fmod(wind_angle, M_PI * 2))) * 180.0) / M_PI) + 0.5);
  if (intangle > 180) {
    intangle = 360 - intangle;
  }
  valfloor = polar_tab[intangle * (60 + 1) + intspeed];
  valceil = polar_tab[intangle * (60 + 1) + intspeed + 1];
  return (valfloor + (valceil - valfloor) * (wind_speed - (double)intspeed));
}


x86 assembly (clang, -O0):
<find_speed_polar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <floor@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x3c,-0x20(%rbp)
jle    1164 <find_speed_polar+0x34>
movl   $0x3c,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
shl    $0x1,%edi
call   1030 <fmod@plt>
mov    %eax,%edi
call   1040 <fabs@plt>
movsd  0xe7f(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2e54(%rip),%rax
cvtsi2sdl (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe5c(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <floor@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xb4,-0x1c(%rbp)
jle    11c8 <find_speed_polar+0x98>
mov    $0x168,%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
imul   $0x3d,-0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
imul   $0x3d,-0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
cvtsi2sdl -0x20(%rbp),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_speed_polar>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%rbx
call   1050 <floor@plt>
cmp    $0x3c,%eax
mov    $0x3c,%ebp
cmovl  %eax,%ebp
mov    0x2e8b(%rip),%r14
mov    (%r14),%edi
add    %edi,%edi
movsd  (%rsp),%xmm0
call   1030 <fmod@plt>
mov    %eax,%edi
call   1040 <fabs@plt>
mulsd  0xe85(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl (%r14),%xmm1
divsd  %xmm1,%xmm0
addsd  0xe79(%rip),%xmm0
call   1050 <floor@plt>
mov    $0x168,%ecx
sub    %eax,%ecx
cmp    $0xb5,%eax
cmovl  %eax,%ecx
imul   $0x3d,%ecx,%eax
add    %ebp,%eax
cltq
movsd  (%rbx,%rax,8),%xmm3
movsd  0x8(%rbx,%rax,8),%xmm1
cvtsi2sd %ebp,%xmm2
subsd  %xmm3,%xmm1
movsd  0x8(%rsp),%xmm0
subsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @find_speed_polar(double* %0, double %1, double %2) {
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
store double* %0, double** %4
store double %1, double* %5
store double %2, double* %6
%11 = load double, double* %5
%12 = call i32 @floor(double %11)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp sgt i32 %13, 60
br i1 %14, label %15, label %16
15: ; preds = %3
store i32 60, i32* %8
br label %16
16: ; preds = %15, %3
%17 = load double, double* %6
%18 = load i32, i32* @M_PI
%19 = mul nsw i32 %18, 2
%20 = call i32 @fmod(double %17, i32 %19)
%21 = call double @fabs(i32 %20)
%22 = fmul double %21, 1.800000e+02
%23 = load i32, i32* @M_PI
%24 = sitofp i32 %23 to double
%25 = fdiv double %22, %24
%26 = fadd double %25, 5.000000e-01
%27 = call i32 @floor(double %26)
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = icmp sgt i32 %28, 180
br i1 %29, label %30, label %33
30: ; preds = %16
%31 = load i32, i32* %7
%32 = sub nsw i32 360, %31
store i32 %32, i32* %7
br label %33
33: ; preds = %30, %16
%34 = load double*, double** %4
%35 = load i32, i32* %7
%36 = mul nsw i32 %35, 61
%37 = load i32, i32* %8
%38 = add nsw i32 %36, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %34, i64 %39
%41 = load double, double* %40
store double %41, double* %9
%42 = load double*, double** %4
%43 = load i32, i32* %7
%44 = mul nsw i32 %43, 61
%45 = load i32, i32* %8
%46 = add nsw i32 %44, %45
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %42, i64 %48
%50 = load double, double* %49
store double %50, double* %10
%51 = load double, double* %9
%52 = load double, double* %10
%53 = load double, double* %9
%54 = fsub double %52, %53
%55 = load double, double* %5
%56 = load i32, i32* %8
%57 = sitofp i32 %56 to double
%58 = fsub double %55, %57
%59 = call double @llvm.fmuladd.f64(double %54, double %58, double %51)
ret double %59
}

LLVM IR (-O2):
@M_PI = global i32 0
define double @find_speed_polar(double* nocapture %0, double %1, double %2) {
%4 = tail call i32 @floor(double %1)
%5 = icmp slt i32 %4, 60
%6 = select i1 %5, i32 %4, i32 60
%7 = load i32, i32* @M_PI
%8 = shl nsw i32 %7, 1
%9 = tail call i32 @fmod(double %2, i32 %8)
%10 = tail call double @fabs(i32 %9)
%11 = fmul double %10, 1.800000e+02
%12 = load i32, i32* @M_PI
%13 = sitofp i32 %12 to double
%14 = fdiv double %11, %13
%15 = fadd double %14, 5.000000e-01
%16 = tail call i32 @floor(double %15)
%17 = icmp sgt i32 %16, 180
%18 = sub nsw i32 360, %16
%19 = select i1 %17, i32 %18, i32 %16
%20 = mul nsw i32 %19, 61
%21 = add nsw i32 %20, %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %0, i64 %22
%24 = load double, double* %23
%25 = add nsw i32 %21, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %0, i64 %26
%28 = load double, double* %27
%29 = fsub double %28, %24
%30 = sitofp i32 %6 to double
%31 = fsub double %1, %30
%32 = tail call double @llvm.fmuladd.f64(double %29, double %31, double %24)
ret double %32
}