#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 log(double);
double sqrt(double);
double ion(int NA, int polymer, double naConc, double mgConc) {
  if (NA == 0)
    return 0;
  else if (polymer) {
    return -(0.2 + 0.175 * log(naConc));
  } else
    return -0.114 * log(naConc + 3.3 * sqrt(mgConc));
}


x86 assembly (clang, -O0):
<ion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    114f <ion+0x2f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11de <ion+0xbe>
cmpl   $0x0,-0x10(%rbp)
je     119c <ion+0x7c>
movsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
movsd  0xea5(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea1(%rip),%xmm1
addsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11de <ion+0xbe>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  -0x28(%rbp),%xmm1
movsd  0xe4b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe2b(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ion>:
push   %rax
test   %edi,%edi
je     1150 <ion+0x30>
movapd %xmm0,%xmm2
test   %esi,%esi
je     1155 <ion+0x35>
movapd %xmm2,%xmm0
call   1030 <log@plt>
mulsd  0xec2(%rip),%xmm0
addsd  0xec2(%rip),%xmm0
xorpd  0xed2(%rip),%xmm0
pop    %rax
ret
xorps  %xmm0,%xmm0
pop    %rax
ret
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     1168 <ion+0x48>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    117b <ion+0x5b>
movapd %xmm1,%xmm0
movsd  %xmm2,(%rsp)
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm2
mulsd  0xe8d(%rip),%xmm0
addsd  %xmm2,%xmm0
call   1030 <log@plt>
mulsd  0xe84(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @ion(i32 %0, i32 %1, double %2, double %3) {
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
store i32 %0, i32* %6
store i32 %1, i32* %7
store double %2, double* %8
store double %3, double* %9
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %4
store double 0.000000e+00, double* %5
br label %28
13: ; preds = %4
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load double, double* %8
%18 = call double @log(double %17)
%19 = call double @llvm.fmuladd.f64(double 1.750000e-01, double %18, double 2.000000e-01)
%20 = fneg double %19
store double %20, double* %5
br label %28
21: ; preds = %13
%22 = load double, double* %8
%23 = load double, double* %9
%24 = call double @sqrt(double %23)
%25 = call double @llvm.fmuladd.f64(double 3.300000e+00, double %24, double %22)
%26 = call double @log(double %25)
%27 = fmul double -1.140000e-01, %26
store double %27, double* %5
br label %28
28: ; preds = %21, %16, %12
%29 = load double, double* %5
ret double %29
}

LLVM IR (-O2):
define double @ion(i32 %0, i32 %1, double %2, double %3) {
%5 = icmp eq i32 %0, 0
br i1 %5, label %17, label %6
6: ; preds = %4
%7 = icmp eq i32 %1, 0
br i1 %7, label %12, label %8
8: ; preds = %6
%9 = tail call double @log(double %2)
%10 = tail call double @llvm.fmuladd.f64(double %9, double 1.750000e-01, double 2.000000e-01)
%11 = fneg double %10
br label %17
12: ; preds = %6
%13 = tail call double @sqrt(double %3)
%14 = tail call double @llvm.fmuladd.f64(double %13, double 3.300000e+00, double %2)
%15 = tail call double @log(double %14)
%16 = fmul double %15, -1.140000e-01
br label %17
17: ; preds = %4, %12, %8
%18 = phi double [ %11, %8 ], [ %16, %12 ], [ 0.000000e+00, %4 ]
ret double %18
}