#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 SFMHypot2(double, double);
double sin(double);
double SFMCurrentSpeedForStall(double vel_y, double vel_z, double pitch) {
  double sin_pitch = sin(pitch);
  double meaningful_z = 0.0;
  if (sin_pitch < -0.2 && vel_z > 0)
    meaningful_z += vel_z;
  else if (sin_pitch > -0.2 && vel_z < 0)
    meaningful_z += vel_z;
  return SFMHypot2(vel_y, meaningful_z);
}


x86 assembly (clang, -O0):
<SFMCurrentSpeedForStall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeaa(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1187 <SFMCurrentSpeedForStall+0x67>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1187 <SFMCurrentSpeedForStall+0x67>
movsd  -0x10(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11c0 <SFMCurrentSpeedForStall+0xa0>
movsd  -0x20(%rbp),%xmm0
movsd  0xe6c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11bb <SFMCurrentSpeedForStall+0x9b>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11bb <SFMCurrentSpeedForStall+0x9b>
movsd  -0x10(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11c0 <SFMCurrentSpeedForStall+0xa0>
movsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1040 <SFMHypot2@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SFMCurrentSpeedForStall>:
sub    $0x28,%rsp
movaps %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movapd %xmm2,%xmm0
call   1030 <sin@plt>
movapd 0x10(%rsp),%xmm1
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm1
jbe    1160 <SFMCurrentSpeedForStall+0x40>
movsd  0xeb0(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1160 <SFMCurrentSpeedForStall+0x40>
xorpd  %xmm0,%xmm0
addsd  %xmm0,%xmm1
jmp    1182 <SFMCurrentSpeedForStall+0x62>
movapd %xmm1,%xmm2
addsd  %xmm4,%xmm2
movsd  0xe90(%rip),%xmm3
cmpltsd %xmm0,%xmm3
andpd  %xmm2,%xmm3
cmpltsd %xmm4,%xmm1
andpd  %xmm3,%xmm1
movsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
jmp    1040 <SFMHypot2@plt>

LLVM IR (-O0):
define double @SFMCurrentSpeedForStall(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%9 = load double, double* %6
%10 = call double @sin(double %9)
store double %10, double* %7
store double 0.000000e+00, double* %8
%11 = load double, double* %7
%12 = fcmp olt double %11, -2.000000e-01
br i1 %12, label %13, label %20
13: ; preds = %3
%14 = load double, double* %5
%15 = fcmp ogt double %14, 0.000000e+00
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load double, double* %5
%18 = load double, double* %8
%19 = fadd double %18, %17
store double %19, double* %8
br label %31
20: ; preds = %13, %3
%21 = load double, double* %7
%22 = fcmp ogt double %21, -2.000000e-01
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load double, double* %5
%25 = fcmp olt double %24, 0.000000e+00
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load double, double* %5
%28 = load double, double* %8
%29 = fadd double %28, %27
store double %29, double* %8
br label %30
30: ; preds = %26, %23, %20
br label %31
31: ; preds = %30, %16
%32 = load double, double* %4
%33 = load double, double* %8
%34 = call double @SFMHypot2(double %32, double %33)
ret double %34
}

LLVM IR (-O2):
define double @SFMCurrentSpeedForStall(double %0, double %1, double %2) {
%4 = tail call double @sin(double %2)
%5 = fcmp olt double %4, -2.000000e-01
%6 = fcmp ogt double %1, 0.000000e+00
%7 = and i1 %6, %5
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = fadd double %1, 0.000000e+00
br label %16
10: ; preds = %3
%11 = fcmp ogt double %4, -2.000000e-01
%12 = fcmp olt double %1, 0.000000e+00
%13 = and i1 %12, %11
%14 = fadd double %1, 0.000000e+00
%15 = select i1 %13, double %14, double 0.000000e+00
br label %16
16: ; preds = %10, %8
%17 = phi double [ %9, %8 ], [ %15, %10 ]
%18 = tail call double @SFMHypot2(double %0, double %17)
ret double %18
}