#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 */
int exp(double);
double fabs(double);
double pow(double, int);
double ipvsolver(double Vpv, int Np, int Ns, double Tpv, double lambdaph,
                 double emax, int itmax, double Ipvguess) {
  double q = 1.6e-19;
  double Ac = 1.6;
  double K = 1.3805e-23;
  double K1 = 0.0017;
  double Ior = 2.0793e-6;
  double Tref = 303;
  double Eg = 1.1;
  double Isc = 3.27;
  double Rspv = 1.0;
  double Irs;
  double Iph;
  Irs =
      Ior * pow((Tpv / Tref), 3) * exp(q * Eg * (1 / Tref - 1 / Tpv) / K / Ac);
  Iph = (Isc + K1 * (Tpv - Tref)) * lambdaph / 100;
  double Ipv = 0;
  double Ipv1;
  int it = 0;
  double error = 10;
  double exponente;
  double f0;
  double df0;
  while (error >= emax && it < itmax) {
    exponente = q * (Vpv / Ns + Ipv * Rspv / Np) / (K * Ac * Tpv);
    f0 = Ipv - Np * Iph + Np * Irs * (exp(exponente) - 1);
    df0 = 1 + Np * Irs * exp(exponente) * q * Rspv / (Np * K * Ac * Tpv);
    Ipv1 = Ipv - f0 / df0;
    it = it + 1;
    error = fabs((Ipv1 - Ipv) / Ipv1);
    Ipv = Ipv1;
  }
  return Ipv;
}


x86 assembly (clang, -O0):
<ipvsolver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    %edx,-0x2c(%rbp)
movsd  %xmm4,-0x38(%rbp)
movsd  0xefb(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xee6(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xed1(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xea7(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe92(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe7d(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xe68(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xe53(%rip),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
divsd  -0x68(%rbp),%xmm0
mov    $0x3,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0xd8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
movsd  0xe04(%rip),%xmm1
divsd  -0x68(%rbp),%xmm1
movsd  0xdf7(%rip),%xmm2
divsd  -0x18(%rbp),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
call   1030 <exp@plt>
movsd  -0xd0(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x78(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
subsd  -0x68(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xd92(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movl   $0x0,-0xa4(%rbp)
movsd  0xd61(%rip),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
xor    %eax,%eax
ucomisd -0x28(%rbp),%xmm0
mov    %al,-0xd9(%rbp)
jb     12d4 <ipvsolver+0x1b4>
mov    -0xa4(%rbp),%eax
cmp    -0x2c(%rbp),%eax
setl   %al
mov    %al,-0xd9(%rbp)
mov    -0xd9(%rbp),%al
test   $0x1,%al
jne    12e7 <ipvsolver+0x1c7>
jmp    1493 <ipvsolver+0x373>
movsd  -0x40(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
cvtsi2sdl -0x10(%rbp),%xmm2
divsd  %xmm2,%xmm1
movsd  -0x98(%rbp),%xmm2
ff
mulsd  -0x80(%rbp),%xmm2
cvtsi2sdl -0xc(%rbp),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x50(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x98(%rbp),%xmm1
ff
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  -0x90(%rbp),%xmm2
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
cvtsi2sdl -0xc(%rbp),%xmm0
mulsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  -0xb8(%rbp),%xmm0
ff
call   1030 <exp@plt>
movsd  -0xf8(%rbp),%xmm0
ff
movsd  -0xf0(%rbp),%xmm1
ff
sub    $0x1,%eax
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
cvtsi2sdl -0xc(%rbp),%xmm0
mulsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  -0xb8(%rbp),%xmm0
ff
call   1030 <exp@plt>
movsd  -0xe8(%rbp),%xmm1
ff
cvtsi2sd %eax,%xmm0
mulsd  %xmm0,%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  -0x80(%rbp),%xmm1
cvtsi2sdl -0xc(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xbfc(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  -0xc0(%rbp),%xmm1
ff
divsd  -0xc8(%rbp),%xmm1
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
subsd  -0x98(%rbp),%xmm0
ff
divsd  -0xa0(%rbp),%xmm0
ff
movaps 0xbee(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0x98(%rbp)
ff
jmp    12a7 <ipvsolver+0x187>
movsd  -0x98(%rbp),%xmm0
ff
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipvsolver>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %edx,%ebx
movsd  %xmm3,0x30(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
mov    %esi,%ebp
mov    %edi,%r14d
movsd  %xmm0,0x18(%rsp)
movapd %xmm1,%xmm0
divsd  0xead(%rip),%xmm0
mov    $0x3,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0xe9d(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
addsd  0xe97(%rip),%xmm0
mulsd  0xe97(%rip),%xmm0
divsd  0xe97(%rip),%xmm0
divsd  0xe97(%rip),%xmm0
call   1030 <exp@plt>
movsd  0xeb2(%rip),%xmm0
ucomisd 0x30(%rsp),%xmm0
xorpd  %xmm0,%xmm0
jb     135a <ipvsolver+0x23a>
test   %ebx,%ebx
jle    135a <ipvsolver+0x23a>
movsd  0xe72(%rip),%xmm4
movsd  0x8(%rsp),%xmm5
addsd  %xmm5,%xmm4
mulsd  0xe68(%rip),%xmm4
addsd  0xe68(%rip),%xmm4
mulsd  0x10(%rsp),%xmm4
divsd  0xe62(%rip),%xmm4
movsd  0x28(%rsp),%xmm0
mulsd  0xe64(%rip),%xmm0
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
mulsd  %xmm0,%xmm3
movsd  0x18(%rsp),%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,0x18(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
movsd  0xe3a(%rip),%xmm2
mulsd  %xmm5,%xmm2
movsd  %xmm2,0x40(%rsp)
movapd 0xe48(%rip),%xmm2
xorpd  %xmm1,%xmm2
movsd  0xddc(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  0xdd8(%rip),%xmm0
movapd %xmm1,0x60(%rsp)
mulsd  %xmm1,%xmm3
movsd  %xmm3,0x10(%rsp)
mulsd  %xmm5,%xmm0
movsd  %xmm0,0x38(%rsp)
xorpd  %xmm0,%xmm0
mov    $0x1,%ebp
mulsd  %xmm4,%xmm2
movapd %xmm2,0x50(%rsp)
nopl   (%rax)
movsd  %xmm0,0x8(%rsp)
movapd %xmm0,%xmm1
movsd  %xmm0,0x28(%rsp)
movapd %xmm0,%xmm2
divsd  0x60(%rsp),%xmm2
addsd  0x18(%rsp),%xmm2
movsd  0xdc0(%rip),%xmm0
mulsd  %xmm0,%xmm2
divsd  0x40(%rsp),%xmm2
movsd  %xmm2,0x48(%rsp)
movapd 0x50(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rsp)
movapd %xmm2,%xmm0
call   1030 <exp@plt>
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x48(%rsp),%xmm0
call   1030 <exp@plt>
movsd  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0x10(%rsp),%xmm1
mulsd  0xd55(%rip),%xmm1
divsd  0x38(%rsp),%xmm1
addsd  0xd4f(%rip),%xmm1
movsd  0x20(%rsp),%xmm2
divsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
movapd %xmm0,%xmm1
subsd  0x28(%rsp),%xmm1
divsd  %xmm0,%xmm1
andpd  0xd4b(%rip),%xmm1
ucomisd 0x30(%rsp),%xmm1
jb     135a <ipvsolver+0x23a>
lea    0x1(%rbp),%eax
cmp    %ebx,%ebp
mov    %eax,%ebp
jl     1280 <ipvsolver+0x160>
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @ipvsolver(double %0, i32 %1, i32 %2, double %3, double %4, double %5, i32 %6, double %7) {
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca i32
%31 = alloca double
%32 = alloca double
%33 = alloca double
%34 = alloca double
store double %0, double* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store double %3, double* %12
store double %4, double* %13
store double %5, double* %14
store i32 %6, i32* %15
store double %7, double* %16
store double 1.600000e-19, double* %17
store double 1.600000e+00, double* %18
store double 1.380500e-23, double* %19
store double 1.700000e-03, double* %20
store double 2.079300e-06, double* %21
store double 3.030000e+02, double* %22
store double 1.100000e+00, double* %23
store double 3.270000e+00, double* %24
store double 1.000000e+00, double* %25
%35 = load double, double* %21
%36 = load double, double* %12
%37 = load double, double* %22
%38 = fdiv double %36, %37
%39 = call double @pow(double %38, i32 3)
%40 = fmul double %35, %39
%41 = load double, double* %17
%42 = load double, double* %23
%43 = fmul double %41, %42
%44 = load double, double* %22
%45 = fdiv double 1.000000e+00, %44
%46 = load double, double* %12
%47 = fdiv double 1.000000e+00, %46
%48 = fsub double %45, %47
%49 = fmul double %43, %48
%50 = load double, double* %19
%51 = fdiv double %49, %50
%52 = load double, double* %18
%53 = fdiv double %51, %52
%54 = call i32 @exp(double %53)
%55 = sitofp i32 %54 to double
%56 = fmul double %40, %55
store double %56, double* %26
%57 = load double, double* %24
%58 = load double, double* %20
%59 = load double, double* %12
%60 = load double, double* %22
%61 = fsub double %59, %60
%62 = call double @llvm.fmuladd.f64(double %58, double %61, double %57)
%63 = load double, double* %13
%64 = fmul double %62, %63
%65 = fdiv double %64, 1.000000e+02
store double %65, double* %27
store double 0.000000e+00, double* %28
store i32 0, i32* %30
store double 1.000000e+01, double* %31
br label %66
66: ; preds = %76, %8
%67 = load double, double* %31
%68 = load double, double* %14
%69 = fcmp oge double %67, %68
br i1 %69, label %70, label %74
70: ; preds = %66
%71 = load i32, i32* %30
%72 = load i32, i32* %15
%73 = icmp slt i32 %71, %72
br label %74
74: ; preds = %70, %66
%75 = phi i1 [ false, %66 ], [ %73, %70 ]
br i1 %75, label %76, label %147
76: ; preds = %74
%77 = load double, double* %17
%78 = load double, double* %9
%79 = load i32, i32* %11
%80 = sitofp i32 %79 to double
%81 = fdiv double %78, %80
%82 = load double, double* %28
%83 = load double, double* %25
%84 = fmul double %82, %83
%85 = load i32, i32* %10
%86 = sitofp i32 %85 to double
%87 = fdiv double %84, %86
%88 = fadd double %81, %87
%89 = fmul double %77, %88
%90 = load double, double* %19
%91 = load double, double* %18
%92 = fmul double %90, %91
%93 = load double, double* %12
%94 = fmul double %92, %93
%95 = fdiv double %89, %94
store double %95, double* %32
%96 = load double, double* %28
%97 = load i32, i32* %10
%98 = sitofp i32 %97 to double
%99 = load double, double* %27
%100 = fneg double %98
%101 = call double @llvm.fmuladd.f64(double %100, double %99, double %96)
%102 = load i32, i32* %10
%103 = sitofp i32 %102 to double
%104 = load double, double* %26
%105 = fmul double %103, %104
%106 = load double, double* %32
%107 = call i32 @exp(double %106)
%108 = sub nsw i32 %107, 1
%109 = sitofp i32 %108 to double
%110 = call double @llvm.fmuladd.f64(double %105, double %109, double %101)
store double %110, double* %33
%111 = load i32, i32* %10
%112 = sitofp i32 %111 to double
%113 = load double, double* %26
%114 = fmul double %112, %113
%115 = load double, double* %32
%116 = call i32 @exp(double %115)
%117 = sitofp i32 %116 to double
%118 = fmul double %114, %117
%119 = load double, double* %17
%120 = fmul double %118, %119
%121 = load double, double* %25
%122 = fmul double %120, %121
%123 = load i32, i32* %10
%124 = sitofp i32 %123 to double
%125 = load double, double* %19
%126 = fmul double %124, %125
%127 = load double, double* %18
%128 = fmul double %126, %127
%129 = load double, double* %12
%130 = fmul double %128, %129
%131 = fdiv double %122, %130
%132 = fadd double 1.000000e+00, %131
store double %132, double* %34
%133 = load double, double* %28
%134 = load double, double* %33
%135 = load double, double* %34
%136 = fdiv double %134, %135
%137 = fsub double %133, %136
store double %137, double* %29
%138 = load i32, i32* %30
%139 = add nsw i32 %138, 1
store i32 %139, i32* %30
%140 = load double, double* %29
%141 = load double, double* %28
%142 = fsub double %140, %141
%143 = load double, double* %29
%144 = fdiv double %142, %143
%145 = call double @llvm.fabs.f64(double %144)
store double %145, double* %31
%146 = load double, double* %29
store double %146, double* %28
br label %66
147: ; preds = %74
%148 = load double, double* %28
ret double %148
}

LLVM IR (-O2):
define double @ipvsolver(double %0, i32 %1, i32 %2, double %3, double %4, double %5, i32 %6, double %7) {
%9 = fdiv double %3, 3.030000e+02
%10 = tail call double @pow(double %9, i32 3)
%11 = fdiv double 1.000000e+00, %3
%12 = fsub double 0x3F6B094B31D922A4, %11
%13 = fmul double %12, 1.760000e-19
%14 = fdiv double %13, 1.380500e-23
%15 = fdiv double %14, 1.600000e+00
%16 = tail call i32 @exp(double %15)
%17 = fadd double %3, -3.030000e+02
%18 = tail call double @llvm.fmuladd.f64(double %17, double 1.700000e-03, double 3.270000e+00)
%19 = fmul double %18, %4
%20 = fdiv double %19, 1.000000e+02
%21 = fcmp ole double %5, 1.000000e+01
%22 = icmp sgt i32 %6, 0
%23 = and i1 %21, %22
br i1 %23, label %24, label %64
24: ; preds = %8
%25 = fmul double %10, 2.079300e-06
%26 = sitofp i32 %16 to double
%27 = fmul double %25, %26
%28 = sitofp i32 %2 to double
%29 = fdiv double %0, %28
%30 = sitofp i32 %1 to double
%31 = fmul double %3, 0x3B3AB3E7A7535138
%32 = fneg double %30
%33 = fmul double %27, %30
%34 = fmul double %30, 1.380500e-23
%35 = fmul double %34, 1.600000e+00
%36 = fmul double %35, %3
br label %37
37: ; preds = %24, %37
%38 = phi double [ 0.000000e+00, %24 ], [ %56, %37 ]
%39 = phi i32 [ 0, %24 ], [ %57, %37 ]
%40 = fdiv double %38, %30
%41 = fadd double %29, %40
%42 = fmul double %41, 1.600000e-19
%43 = fdiv double %42, %31
%44 = tail call double @llvm.fmuladd.f64(double %32, double %20, double %38)
%45 = tail call i32 @exp(double %43)
%46 = add nsw i32 %45, -1
%47 = sitofp i32 %46 to double
%48 = tail call double @llvm.fmuladd.f64(double %33, double %47, double %44)
%49 = tail call i32 @exp(double %43)
%50 = sitofp i32 %49 to double
%51 = fmul double %33, %50
%52 = fmul double %51, 1.600000e-19
%53 = fdiv double %52, %36
%54 = fadd double %53, 1.000000e+00
%55 = fdiv double %48, %54
%56 = fsub double %38, %55
%57 = add nuw nsw i32 %39, 1
%58 = fsub double %56, %38
%59 = fdiv double %58, %56
%60 = tail call double @llvm.fabs.f64(double %59)
%61 = fcmp oge double %60, %5
%62 = icmp slt i32 %57, %6
%63 = select i1 %61, i1 %62, i1 false
br i1 %63, label %37, label %64
64: ; preds = %37, %8
%65 = phi double [ 0.000000e+00, %8 ], [ %56, %37 ]
ret double %65
}