#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 switch3(double d, double rcut, double width, double *g) {
  double result, x;
  if (d < rcut) {
    x = rcut - d;
    if (x > width) {
      result = 1.0;
      if (g != NULL)
        *g = 0.0;
    } else {
      x /= width;
      result = (3 - 2 * x) * x * x;
      if (g != NULL)
        *g = -6 * x * (1 - x) / width;
    }
  } else {
    result = 0.0;
    if (g != NULL)
      *g = 0.0;
  }
  return result;
}


x86 assembly (clang, -O0):
<switch3>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11e9 <switch3+0xe9>
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1172 <switch3+0x72>
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     116d <switch3+0x6d>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    11e4 <switch3+0xe4>
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xe6a(%rip),%xmm0
subsd  %xmm1,%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11df <switch3+0xdf>
movsd  0xe54(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  0xe3f(%rip),%xmm1
subsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11e4 <switch3+0xe4>
jmp    120c <switch3+0x10c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1207 <switch3+0x107>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    120c <switch3+0x10c>
movsd  -0x28(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<switch3>:
ucomisd %xmm0,%xmm1
jbe    1122 <switch3+0x22>
subsd  %xmm0,%xmm1
ucomisd %xmm2,%xmm1
jbe    1134 <switch3+0x34>
xorpd  %xmm3,%xmm3
movsd  0xef4(%rip),%xmm0
test   %rdi,%rdi
jne    112f <switch3+0x2f>
ret
xorpd  %xmm3,%xmm3
xorpd  %xmm0,%xmm0
test   %rdi,%rdi
je     1121 <switch3+0x21>
movsd  %xmm3,(%rdi)
ret
divsd  %xmm2,%xmm1
movapd %xmm1,%xmm3
addsd  %xmm1,%xmm3
movsd  0xeb8(%rip),%xmm0
subsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
test   %rdi,%rdi
je     1121 <switch3+0x21>
movsd  0xea7(%rip),%xmm4
mulsd  %xmm1,%xmm4
movsd  0xea3(%rip),%xmm3
subsd  %xmm1,%xmm3
mulsd  %xmm4,%xmm3
divsd  %xmm2,%xmm3
movsd  %xmm3,(%rdi)
ret

LLVM IR (-O0):
define double @switch3(double %0, double %1, double %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double*
%9 = alloca double
%10 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double* %3, double** %8
%11 = load double, double* %5
%12 = load double, double* %6
%13 = fcmp olt double %11, %12
br i1 %13, label %14, label %50
14: ; preds = %4
%15 = load double, double* %6
%16 = load double, double* %5
%17 = fsub double %15, %16
store double %17, double* %10
%18 = load double, double* %10
%19 = load double, double* %7
%20 = fcmp ogt double %18, %19
br i1 %20, label %21, label %27
21: ; preds = %14
store double 1.000000e+00, double* %9
%22 = load double*, double** %8
%23 = icmp ne double* %22, null
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = load double*, double** %8
store double 0.000000e+00, double* %25
br label %26
26: ; preds = %24, %21
br label %49
27: ; preds = %14
%28 = load double, double* %7
%29 = load double, double* %10
%30 = fdiv double %29, %28
store double %30, double* %10
%31 = load double, double* %10
%32 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %31, double 3.000000e+00)
%33 = load double, double* %10
%34 = fmul double %32, %33
%35 = load double, double* %10
%36 = fmul double %34, %35
store double %36, double* %9
%37 = load double*, double** %8
%38 = icmp ne double* %37, null
br i1 %38, label %39, label %48
39: ; preds = %27
%40 = load double, double* %10
%41 = fmul double -6.000000e+00, %40
%42 = load double, double* %10
%43 = fsub double 1.000000e+00, %42
%44 = fmul double %41, %43
%45 = load double, double* %7
%46 = fdiv double %44, %45
%47 = load double*, double** %8
store double %46, double* %47
br label %48
48: ; preds = %39, %27
br label %49
49: ; preds = %48, %26
br label %56
50: ; preds = %4
store double 0.000000e+00, double* %9
%51 = load double*, double** %8
%52 = icmp ne double* %51, null
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = load double*, double** %8
store double 0.000000e+00, double* %54
br label %55
55: ; preds = %53, %50
br label %56
56: ; preds = %55, %49
%57 = load double, double* %9
ret double %57
}

LLVM IR (-O2):
define double @switch3(double %0, double %1, double %2, double* writeonly %3) {
%5 = fcmp olt double %0, %1
br i1 %5, label %6, label %22
6: ; preds = %4
%7 = fsub double %1, %0
%8 = fcmp ogt double %7, %2
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = icmp eq double* %3, null
br i1 %10, label %27, label %24
11: ; preds = %6
%12 = fdiv double %7, %2
%13 = tail call double @llvm.fmuladd.f64(double %12, double -2.000000e+00, double 3.000000e+00)
%14 = fmul double %12, %13
%15 = fmul double %12, %14
%16 = icmp eq double* %3, null
br i1 %16, label %27, label %17
17: ; preds = %11
%18 = fmul double %12, -6.000000e+00
%19 = fsub double 1.000000e+00, %12
%20 = fmul double %18, %19
%21 = fdiv double %20, %2
br label %24
22: ; preds = %4
%23 = icmp eq double* %3, null
br i1 %23, label %27, label %24
24: ; preds = %22, %9, %17
%25 = phi double [ %21, %17 ], [ 0.000000e+00, %9 ], [ 0.000000e+00, %22 ]
%26 = phi double [ %15, %17 ], [ 1.000000e+00, %9 ], [ 0.000000e+00, %22 ]
store double %25, double* %3
br label %27
27: ; preds = %24, %22, %9, %11
%28 = phi double [ 1.000000e+00, %9 ], [ %15, %11 ], [ 0.000000e+00, %22 ], [ %26, %24 ]
ret double %28
}