#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 exp(double);
double hammer(double d, double rcut, double tau, double *g) {
  double result, x;
  if (d < rcut) {
    x = d - rcut;
    result = exp(tau / x);
    if (g != NULL)
      *g = -result * tau / x / x;
  } else {
    result = 0.0;
    if (g != NULL)
      *g = 0.0;
  }
  return result;
}


x86 assembly (clang, -O0):
<hammer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
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    11a5 <hammer+0x95>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11a0 <hammer+0x90>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x18(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11c8 <hammer+0xb8>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11c3 <hammer+0xb3>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    11c8 <hammer+0xb8>
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hammer>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
ucomisd %xmm0,%xmm1
jbe    1164 <hammer+0x54>
movapd %xmm0,%xmm3
subsd  %xmm1,%xmm3
movsd  %xmm2,(%rsp)
movapd %xmm2,%xmm0
movsd  %xmm3,0x8(%rsp)
divsd  %xmm3,%xmm0
call   1030 <exp@plt>
test   %rbx,%rbx
je     1175 <hammer+0x65>
movapd 0xeb5(%rip),%xmm1
xorpd  %xmm0,%xmm1
mulsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm2,%xmm1
jmp    1171 <hammer+0x61>
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
test   %rbx,%rbx
je     1175 <hammer+0x65>
movsd  %xmm1,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @hammer(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 %35
14: ; preds = %4
%15 = load double, double* %5
%16 = load double, double* %6
%17 = fsub double %15, %16
store double %17, double* %10
%18 = load double, double* %7
%19 = load double, double* %10
%20 = fdiv double %18, %19
%21 = call double @exp(double %20)
store double %21, double* %9
%22 = load double*, double** %8
%23 = icmp ne double* %22, null
br i1 %23, label %24, label %34
24: ; preds = %14
%25 = load double, double* %9
%26 = fneg double %25
%27 = load double, double* %7
%28 = fmul double %26, %27
%29 = load double, double* %10
%30 = fdiv double %28, %29
%31 = load double, double* %10
%32 = fdiv double %30, %31
%33 = load double*, double** %8
store double %32, double* %33
br label %34
34: ; preds = %24, %14
br label %41
35: ; preds = %4
store double 0.000000e+00, double* %9
%36 = load double*, double** %8
%37 = icmp ne double* %36, null
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load double*, double** %8
store double 0.000000e+00, double* %39
br label %40
40: ; preds = %38, %35
br label %41
41: ; preds = %40, %34
%42 = load double, double* %9
ret double %42
}

LLVM IR (-O2):
define double @hammer(double %0, double %1, double %2, double* writeonly %3) {
%5 = fcmp olt double %0, %1
br i1 %5, label %6, label %16
6: ; preds = %4
%7 = fsub double %0, %1
%8 = fdiv double %2, %7
%9 = tail call double @exp(double %8)
%10 = icmp eq double* %3, null
br i1 %10, label %21, label %11
11: ; preds = %6
%12 = fneg double %9
%13 = fmul double %12, %2
%14 = fdiv double %13, %7
%15 = fdiv double %14, %7
br label %18
16: ; preds = %4
%17 = icmp eq double* %3, null
br i1 %17, label %21, label %18
18: ; preds = %16, %11
%19 = phi double [ %15, %11 ], [ 0.000000e+00, %16 ]
%20 = phi double [ %9, %11 ], [ 0.000000e+00, %16 ]
store double %19, double* %3
br label %21
21: ; preds = %18, %16, %6
%22 = phi double [ %9, %6 ], [ 0.000000e+00, %16 ], [ %20, %18 ]
ret double %22
}