#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 pow(double, double);
void DiodeEq(double V, double Is, double N, double T, double Eg, double XTI,
             double gmin, double *I, double *dI) {
  double nVt, fTs;
  nVt = N * 8.6173323478e-5 * T;
  fTs = exp((T / 300 - 1) * Eg / nVt) * pow((T / 300), XTI);
  if (I)
    (*I) = fTs * Is * (exp(V / nVt) - 1) + V * gmin;
  if (dI)
    (*dI) = fTs * Is * exp(V / nVt) / nVt + gmin;
}


x86 assembly (clang, -O0):
<DiodeEq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
mov    %rdi,-0x40(%rbp)
mov    %rsi,-0x48(%rbp)
movsd  0xeb5(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe89(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe85(%rip),%xmm1
subsd  %xmm1,%xmm0
mulsd  -0x28(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe58(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     121e <DiodeEq+0xfe>
movsd  -0x58(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
movsd  0xe08(%rip),%xmm1
subsd  %xmm1,%xmm2
movsd  -0x8(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,-0x48(%rbp)
je     1265 <DiodeEq+0x145>
movsd  -0x58(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DiodeEq>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mulsd  0xed1(%rip),%xmm2
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm6,0x18(%rsp)
movsd  %xmm5,(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x28(%rsp)
mulsd  %xmm3,%xmm2
divsd  0xeb0(%rip),%xmm3
movsd  %xmm3,0x8(%rsp)
movsd  0xeaa(%rip),%xmm0
addsd  %xmm3,%xmm0
mulsd  %xmm4,%xmm0
movsd  %xmm2,0x10(%rsp)
divsd  %xmm2,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1040 <pow@plt>
movsd  0x28(%rsp),%xmm2
movapd %xmm0,%xmm3
mulsd  0x30(%rsp),%xmm3
test   %rbx,%rbx
je     11f7 <DiodeEq+0xd7>
movapd %xmm3,%xmm0
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
divsd  0x10(%rsp),%xmm2
movapd %xmm2,%xmm0
movsd  %xmm3,(%rsp)
call   1030 <exp@plt>
movsd  (%rsp),%xmm3
movsd  0x28(%rsp),%xmm2
addsd  0xe31(%rip),%xmm0
mulsd  0x8(%rsp),%xmm0
movapd %xmm2,%xmm1
mulsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
movsd  0x20(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
test   %r14,%r14
je     1234 <DiodeEq+0x114>
mulsd  %xmm1,%xmm3
movsd  %xmm3,(%rsp)
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
call   1030 <exp@plt>
mulsd  (%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @DiodeEq(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double* %7, double* %8) {
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double*
%18 = alloca double*
%19 = alloca double
%20 = alloca double
store double %0, double* %10
store double %1, double* %11
store double %2, double* %12
store double %3, double* %13
store double %4, double* %14
store double %5, double* %15
store double %6, double* %16
store double* %7, double** %17
store double* %8, double** %18
%21 = load double, double* %12
%22 = fmul double %21, 0x3F1696FE6CAC3313
%23 = load double, double* %13
%24 = fmul double %22, %23
store double %24, double* %19
%25 = load double, double* %13
%26 = fdiv double %25, 3.000000e+02
%27 = fsub double %26, 1.000000e+00
%28 = load double, double* %14
%29 = fmul double %27, %28
%30 = load double, double* %19
%31 = fdiv double %29, %30
%32 = call double @exp(double %31)
%33 = load double, double* %13
%34 = fdiv double %33, 3.000000e+02
%35 = load double, double* %15
%36 = call double @pow(double %34, double %35)
%37 = fmul double %32, %36
store double %37, double* %20
%38 = load double*, double** %17
%39 = icmp ne double* %38, null
br i1 %39, label %40, label %54
40: ; preds = %9
%41 = load double, double* %20
%42 = load double, double* %11
%43 = fmul double %41, %42
%44 = load double, double* %10
%45 = load double, double* %19
%46 = fdiv double %44, %45
%47 = call double @exp(double %46)
%48 = fsub double %47, 1.000000e+00
%49 = load double, double* %10
%50 = load double, double* %16
%51 = fmul double %49, %50
%52 = call double @llvm.fmuladd.f64(double %43, double %48, double %51)
%53 = load double*, double** %17
store double %52, double* %53
br label %54
54: ; preds = %40, %9
%55 = load double*, double** %18
%56 = icmp ne double* %55, null
br i1 %56, label %57, label %71
57: ; preds = %54
%58 = load double, double* %20
%59 = load double, double* %11
%60 = fmul double %58, %59
%61 = load double, double* %10
%62 = load double, double* %19
%63 = fdiv double %61, %62
%64 = call double @exp(double %63)
%65 = fmul double %60, %64
%66 = load double, double* %19
%67 = fdiv double %65, %66
%68 = load double, double* %16
%69 = fadd double %67, %68
%70 = load double*, double** %18
store double %69, double* %70
br label %71
71: ; preds = %57, %54
ret void
}

LLVM IR (-O2):
define void @DiodeEq(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double* writeonly %7, double* writeonly %8) {
%10 = fmul double %2, 0x3F1696FE6CAC3313
%11 = fmul double %10, %3
%12 = fdiv double %3, 3.000000e+02
%13 = fadd double %12, -1.000000e+00
%14 = fmul double %13, %4
%15 = fdiv double %14, %11
%16 = tail call double @exp(double %15)
%17 = tail call double @pow(double %12, double %5)
%18 = fmul double %16, %17
%19 = icmp eq double* %7, null
br i1 %19, label %27, label %20
20: ; preds = %9
%21 = fmul double %18, %1
%22 = fdiv double %0, %11
%23 = tail call double @exp(double %22)
%24 = fadd double %23, -1.000000e+00
%25 = fmul double %0, %6
%26 = tail call double @llvm.fmuladd.f64(double %21, double %24, double %25)
store double %26, double* %7
br label %27
27: ; preds = %20, %9
%28 = icmp eq double* %8, null
br i1 %28, label %36, label %29
29: ; preds = %27
%30 = fmul double %18, %1
%31 = fdiv double %0, %11
%32 = tail call double @exp(double %31)
%33 = fmul double %30, %32
%34 = fdiv double %33, %11
%35 = fadd double %34, %6
store double %35, double* %8
br label %36
36: ; preds = %29, %27
ret void
}