#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 sqrt(double);
double r_func_schw_sc(double r, void *args) {
  double M = ((double *)args)[0];
  double rm = ((double *)args)[1];
  double rp = ((double *)args)[2];
  double om = ((double *)args)[3];
  double vp = (r - rm) / (rp - rm) * (sqrt(M / (rp * rp * rp)) - om) + om;
  if (r < rm)
    vp = om;
  return (M - r * r * r * vp * vp) /
         (2 * M * r - r * r + r * r * r * r * vp * vp);
}


x86 assembly (clang, -O0):
<r_func_schw_sc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11cf <r_func_schw_sc+0xbf>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdec(%rip),%xmm2
mulsd  -0x18(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm3
movsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<r_func_schw_sc>:
sub    $0x48,%rsp
movapd %xmm0,%xmm5
movsd  (%rdi),%xmm4
movsd  0x8(%rdi),%xmm3
movsd  0x10(%rdi),%xmm0
movsd  0x18(%rdi),%xmm2
movapd %xmm5,%xmm6
subsd  %xmm3,%xmm6
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
subsd  %xmm3,%xmm0
divsd  %xmm0,%xmm6
movapd %xmm4,%xmm0
divsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     115f <r_func_schw_sc+0x4f>
sqrtsd %xmm0,%xmm0
jmp    119e <r_func_schw_sc+0x8e>
movapd %xmm4,0x30(%rsp)
movsd  %xmm5,0x8(%rsp)
movapd %xmm2,0x20(%rsp)
movsd  %xmm3,(%rsp)
movapd %xmm6,0x10(%rsp)
call   1030 <sqrt@plt>
movapd 0x10(%rsp),%xmm6
movsd  (%rsp),%xmm3
movapd 0x20(%rsp),%xmm2
movsd  0x8(%rsp),%xmm5
movapd 0x30(%rsp),%xmm4
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm6
addsd  %xmm2,%xmm6
movapd %xmm5,%xmm1
cmpltsd %xmm3,%xmm1
movapd %xmm1,%xmm0
andnpd %xmm6,%xmm0
andpd  %xmm2,%xmm1
orpd   %xmm0,%xmm1
movapd %xmm5,%xmm0
mulsd  %xmm5,%xmm0
movapd %xmm4,%xmm2
addsd  %xmm4,%xmm2
mulsd  %xmm5,%xmm2
subsd  %xmm0,%xmm2
movapd %xmm0,%xmm3
mulsd  %xmm5,%xmm3
movapd 0xe15(%rip),%xmm0
xorpd  %xmm3,%xmm0
mulsd  %xmm5,%xmm3
unpcklpd %xmm3,%xmm0
unpcklpd %xmm1,%xmm1
mulpd  %xmm1,%xmm0
unpcklpd %xmm2,%xmm4
mulpd  %xmm1,%xmm0
addpd  %xmm4,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
divsd  %xmm1,%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
define double @r_func_schw_sc(double %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %3
store i8* %1, i8** %4
%10 = load i8*, i8** %4
%11 = bitcast i8* %10 to double*
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
store double %13, double* %5
%14 = load i8*, i8** %4
%15 = bitcast i8* %14 to double*
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
store double %17, double* %6
%18 = load i8*, i8** %4
%19 = bitcast i8* %18 to double*
%20 = getelementptr inbounds double, double* %19, i64 2
%21 = load double, double* %20
store double %21, double* %7
%22 = load i8*, i8** %4
%23 = bitcast i8* %22 to double*
%24 = getelementptr inbounds double, double* %23, i64 3
%25 = load double, double* %24
store double %25, double* %8
%26 = load double, double* %3
%27 = load double, double* %6
%28 = fsub double %26, %27
%29 = load double, double* %7
%30 = load double, double* %6
%31 = fsub double %29, %30
%32 = fdiv double %28, %31
%33 = load double, double* %5
%34 = load double, double* %7
%35 = load double, double* %7
%36 = fmul double %34, %35
%37 = load double, double* %7
%38 = fmul double %36, %37
%39 = fdiv double %33, %38
%40 = call double @sqrt(double %39)
%41 = load double, double* %8
%42 = fsub double %40, %41
%43 = load double, double* %8
%44 = call double @llvm.fmuladd.f64(double %32, double %42, double %43)
store double %44, double* %9
%45 = load double, double* %3
%46 = load double, double* %6
%47 = fcmp olt double %45, %46
br i1 %47, label %48, label %50
48: ; preds = %2
%49 = load double, double* %8
store double %49, double* %9
br label %50
50: ; preds = %48, %2
%51 = load double, double* %5
%52 = load double, double* %3
%53 = load double, double* %3
%54 = fmul double %52, %53
%55 = load double, double* %3
%56 = fmul double %54, %55
%57 = load double, double* %9
%58 = fmul double %56, %57
%59 = load double, double* %9
%60 = fneg double %58
%61 = call double @llvm.fmuladd.f64(double %60, double %59, double %51)
%62 = load double, double* %5
%63 = fmul double 2.000000e+00, %62
%64 = load double, double* %3
%65 = load double, double* %3
%66 = load double, double* %3
%67 = fmul double %65, %66
%68 = fneg double %67
%69 = call double @llvm.fmuladd.f64(double %63, double %64, double %68)
%70 = load double, double* %3
%71 = load double, double* %3
%72 = fmul double %70, %71
%73 = load double, double* %3
%74 = fmul double %72, %73
%75 = load double, double* %3
%76 = fmul double %74, %75
%77 = load double, double* %9
%78 = fmul double %76, %77
%79 = load double, double* %9
%80 = call double @llvm.fmuladd.f64(double %78, double %79, double %69)
%81 = fdiv double %61, %80
ret double %81
}

LLVM IR (-O2):
define double @r_func_schw_sc(double %0, i8* nocapture %1) {
%3 = bitcast i8* %1 to double*
%4 = load double, double* %3
%5 = getelementptr inbounds i8, i8* %1, i64 8
%6 = bitcast i8* %5 to double*
%7 = load double, double* %6
%8 = getelementptr inbounds i8, i8* %1, i64 16
%9 = bitcast i8* %8 to double*
%10 = load double, double* %9
%11 = getelementptr inbounds i8, i8* %1, i64 24
%12 = bitcast i8* %11 to double*
%13 = load double, double* %12
%14 = fsub double %0, %7
%15 = fsub double %10, %7
%16 = fdiv double %14, %15
%17 = fmul double %10, %10
%18 = fmul double %10, %17
%19 = fdiv double %4, %18
%20 = tail call double @sqrt(double %19)
%21 = fsub double %20, %13
%22 = tail call double @llvm.fmuladd.f64(double %16, double %21, double %13)
%23 = fcmp ogt double %7, %0
%24 = select i1 %23, double %13, double %22
%25 = fmul double %0, %0
%26 = fmul double %25, %0
%27 = fneg double %26
%28 = fmul double %4, 2.000000e+00
%29 = fneg double %25
%30 = tail call double @llvm.fmuladd.f64(double %28, double %0, double %29)
%31 = fmul double %26, %0
%32 = insertelement <2 x double> poison, double %24, i64 0
%33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
%34 = insertelement <2 x double> poison, double %27, i64 0
%35 = insertelement <2 x double> %34, double %31, i64 1
%36 = fmul <2 x double> %33, %35
%37 = insertelement <2 x double> poison, double %4, i64 0
%38 = insertelement <2 x double> %37, double %30, i64 1
%39 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> %33, <2 x double> %38)
%40 = extractelement <2 x double> %39, i64 0
%41 = extractelement <2 x double> %39, i64 1
%42 = fdiv double %40, %41
ret double %42
}