#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, float, float, float,
                           float, float, float);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *);
int /*<<< orphan*/ nrerror(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ system(char *);
float solve_model(float *p, char *runstr, FILE *fopti) {
  FILE *fin;
  char *cmdstr;
  char filename[512];
  float Rsqr;
  int i, j;
  if ((p[0] > 0) && (p[1] > 0 && p[1] < 1) && (p[2] > 0 && p[2] < 1) &&
      (p[3] > 0.10) && (p[4] > 0.10)) {
    cmdstr = (char *)calloc(512, sizeof(char));
    sprintf(filename, "R2.simp.%s.txt", runstr);
    sprintf(cmdstr, "%s %f %f %f %f %f %s", runstr, p[0], p[1], p[2], p[3],
            p[4], filename);
    system(cmdstr);
    if ((fin = fopen(filename, "r")) == NULL) {
      nrerror("Unable to open Rsquared file");
    }
    fscanf(fin, "%f", &Rsqr);
    fclose(fin);
    fprintf(fopti, "Rsquared (%f,%f,%f,%f,%f) = %f\n", p[0], p[1], p[2], p[3],
            p[4], Rsqr);
    free((char *)cmdstr);
  } else {
    Rsqr = (float)10;
    fprintf(fopti, "Invalid Parameter Set (%f,%f,%f,%f,%f) -> returning %f\n",
            p[0], p[1], p[2], p[3], p[4], Rsqr);
  }
  fflush(fopti);
  return (Rsqr);
}


x86 assembly (clang, -O0):
<solve_model>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1390 <solve_model+0x1f0>
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1390 <solve_model+0x1f0>
mov    -0x8(%rbp),%rax
movss  0xe14(%rip),%xmm0
ucomiss 0x4(%rax),%xmm0
jbe    1390 <solve_model+0x1f0>
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1390 <solve_model+0x1f0>
mov    -0x8(%rbp),%rax
movss  0xde9(%rip),%xmm0
ucomiss 0x8(%rax),%xmm0
jbe    1390 <solve_model+0x1f0>
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdd2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1390 <solve_model+0x1f0>
mov    -0x8(%rbp),%rax
movss  0x10(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdb3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1390 <solve_model+0x1f0>
mov    $0x200,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x28(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm1
cvtss2sd %xmm1,%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm2
cvtss2sd %xmm2,%xmm2
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm3
cvtss2sd %xmm3,%xmm3
mov    -0x8(%rbp),%rax
movss  0x10(%rax),%xmm4
cvtss2sd %xmm4,%xmm4
lea    -0x230(%rbp),%rcx
lea    0xd3e(%rip),%rsi
mov    $0x5,%al
call   10c0 <sprintf@plt>
mov    -0x28(%rbp),%rdi
call   1060 <system@plt>
lea    -0x230(%rbp),%rdi
lea    0xd35(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    131e <solve_model+0x17e>
lea    0xd1d(%rip),%rdi
call   1040 <nrerror@plt>
mov    -0x20(%rbp),%rdi
lea    0xd2a(%rip),%rsi
lea    -0x234(%rbp),%rdx
call   1070 <fscanf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm3
mov    -0x8(%rbp),%rax
movss  0x10(%rax),%xmm4
movss  -0x234(%rbp),%xmm5
ff
lea    0xcd9(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    13e4 <solve_model+0x244>
movss  0xc6c(%rip),%xmm0
movss  %xmm0,-0x234(%rbp)
ff
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm3
mov    -0x8(%rbp),%rax
movss  0x10(%rax),%xmm4
movss  -0x234(%rbp),%xmm5
ff
lea    0xc97(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <fflush@plt>
movss  -0x234(%rbp),%xmm0
ff
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve_model>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x210,%rsp
mov    %rdx,%r14
mov    %rdi,%rbx
movss  (%rdi),%xmm0
movss  0x4(%rdi),%xmm1
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
jbe    131c <solve_model+0x17c>
ucomiss %xmm2,%xmm1
jbe    131c <solve_model+0x17c>
movss  0xe24(%rip),%xmm2
ucomiss %xmm1,%xmm2
jbe    131c <solve_model+0x17c>
movss  0x8(%rbx),%xmm3
xorps  %xmm4,%xmm4
ucomiss %xmm4,%xmm3
jbe    131c <solve_model+0x17c>
ucomiss %xmm3,%xmm2
jbe    131c <solve_model+0x17c>
movss  0xc(%rbx),%xmm2
cvtss2sd %xmm2,%xmm2
ucomisd 0xdf8(%rip),%xmm2
jbe    131c <solve_model+0x17c>
movss  0x10(%rbx),%xmm2
cvtss2sd %xmm2,%xmm2
ucomisd 0xde1(%rip),%xmm2
jbe    131c <solve_model+0x17c>
mov    %rsi,%r12
mov    $0x200,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%r15
lea    0xdc7(%rip),%rsi
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   10c0 <sprintf@plt>
movss  (%rbx),%xmm0
movss  0x4(%rbx),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  0x8(%rbx),%xmm2
cvtss2sd %xmm2,%xmm2
movss  0xc(%rbx),%xmm3
cvtss2sd %xmm3,%xmm3
movss  0x10(%rbx),%xmm4
cvtss2sd %xmm4,%xmm4
lea    0xd91(%rip),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
mov    %r13,%rcx
mov    $0x5,%al
call   10c0 <sprintf@plt>
mov    %r15,%rdi
call   1060 <system@plt>
lea    0xd87(%rip),%rsi
mov    %r13,%rdi
call   10b0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    12c9 <solve_model+0x129>
lea    0xd72(%rip),%rdi
call   1040 <nrerror@plt>
lea    0xd83(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %r12,%rdi
call   1070 <fscanf@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
movss  (%rbx),%xmm0
movss  0x4(%rbx),%xmm1
movss  0x8(%rbx),%xmm2
movss  0xc(%rbx),%xmm3
movss  0x10(%rbx),%xmm4
movss  0xc(%rsp),%xmm5
lea    0xd4c(%rip),%rsi
mov    %r14,%rdi
call   1090 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    134a <solve_model+0x1aa>
movl   $0x41200000,0xc(%rsp)
41
movss  0x8(%rbx),%xmm2
movss  0xc(%rbx),%xmm3
movss  0x10(%rbx),%xmm4
lea    0xd3c(%rip),%rsi
movss  0xcc2(%rip),%xmm5
mov    %r14,%rdi
call   1090 <fprintf@plt>
mov    %r14,%rdi
call   10a0 <fflush@plt>
movss  0xc(%rsp),%xmm0
add    $0x210,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"R2.simp.%s.txt\00"
@.str.1 = [21 x i8] c"%s %f %f %f %f %f %s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [29 x i8] c"Unable to open Rsquared file\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [32 x i8] c"Rsquared (%f,%f,%f,%f,%f) = %f\0A\00"
@.str.6 = [56 x i8] c"Invalid Parameter Set (%f,%f,%f,%f,%f) -> returning %f\0A\00"
define float @solve_model(float* %0, i8* %1, i32* %2) {
%4 = alloca float*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca [512 x i8]
%10 = alloca float
%11 = alloca i32
%12 = alloca i32
store float* %0, float** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%13 = load float*, float** %4
%14 = getelementptr inbounds float, float* %13, i64 0
%15 = load float, float* %14
%16 = fcmp ogt float %15, 0.000000e+00
br i1 %16, label %17, label %111
17: ; preds = %3
%18 = load float*, float** %4
%19 = getelementptr inbounds float, float* %18, i64 1
%20 = load float, float* %19
%21 = fcmp ogt float %20, 0.000000e+00
br i1 %21, label %22, label %111
22: ; preds = %17
%23 = load float*, float** %4
%24 = getelementptr inbounds float, float* %23, i64 1
%25 = load float, float* %24
%26 = fcmp olt float %25, 1.000000e+00
br i1 %26, label %27, label %111
27: ; preds = %22
%28 = load float*, float** %4
%29 = getelementptr inbounds float, float* %28, i64 2
%30 = load float, float* %29
%31 = fcmp ogt float %30, 0.000000e+00
br i1 %31, label %32, label %111
32: ; preds = %27
%33 = load float*, float** %4
%34 = getelementptr inbounds float, float* %33, i64 2
%35 = load float, float* %34
%36 = fcmp olt float %35, 1.000000e+00
br i1 %36, label %37, label %111
37: ; preds = %32
%38 = load float*, float** %4
%39 = getelementptr inbounds float, float* %38, i64 3
%40 = load float, float* %39
%41 = fpext float %40 to double
%42 = fcmp ogt double %41, 1.000000e-01
br i1 %42, label %43, label %111
43: ; preds = %37
%44 = load float*, float** %4
%45 = getelementptr inbounds float, float* %44, i64 4
%46 = load float, float* %45
%47 = fpext float %46 to double
%48 = fcmp ogt double %47, 1.000000e-01
br i1 %48, label %49, label %111
49: ; preds = %43
%50 = call i64 @calloc(i32 512, i32 1)
%51 = inttoptr i64 %50 to i8*
store i8* %51, i8** %8
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%53 = load i8*, i8** %5
%54 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %53)
%55 = load i8*, i8** %8
%56 = load i8*, i8** %5
%57 = load float*, float** %4
%58 = getelementptr inbounds float, float* %57, i64 0
%59 = load float, float* %58
%60 = fpext float %59 to double
%61 = load float*, float** %4
%62 = getelementptr inbounds float, float* %61, i64 1
%63 = load float, float* %62
%64 = fpext float %63 to double
%65 = load float*, float** %4
%66 = getelementptr inbounds float, float* %65, i64 2
%67 = load float, float* %66
%68 = fpext float %67 to double
%69 = load float*, float** %4
%70 = getelementptr inbounds float, float* %69, i64 3
%71 = load float, float* %70
%72 = fpext float %71 to double
%73 = load float*, float** %4
%74 = getelementptr inbounds float, float* %73, i64 4
%75 = load float, float* %74
%76 = fpext float %75 to double
%77 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%78 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %55, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %56, double %60, double %64, double %68, double %72, double %76, i8* %77)
%79 = load i8*, i8** %8
%80 = call i32 @system(i8* %79)
%81 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%82 = call i32* @fopen(i8* %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %82, i32** %7
%83 = icmp eq i32* %82, null
br i1 %83, label %84, label %86
84: ; preds = %49
%85 = call i32 @nrerror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %86
86: ; preds = %84, %49
%87 = load i32*, i32** %7
%88 = call i32 @fscanf(i32* %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %10)
%89 = load i32*, i32** %7
%90 = call i32 @fclose(i32* %89)
%91 = load i32*, i32** %6
%92 = load float*, float** %4
%93 = getelementptr inbounds float, float* %92, i64 0
%94 = load float, float* %93
%95 = load float*, float** %4
%96 = getelementptr inbounds float, float* %95, i64 1
%97 = load float, float* %96
%98 = load float*, float** %4
%99 = getelementptr inbounds float, float* %98, i64 2
%100 = load float, float* %99
%101 = load float*, float** %4
%102 = getelementptr inbounds float, float* %101, i64 3
%103 = load float, float* %102
%104 = load float*, float** %4
%105 = getelementptr inbounds float, float* %104, i64 4
%106 = load float, float* %105
%107 = load float, float* %10
%108 = call i32 @fprintf(i32* %91, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), float %94, float %97, float %100, float %103, float %106, float %107)
%109 = load i8*, i8** %8
%110 = call i32 @free(i8* %109)
br label %130
111: ; preds = %43, %37, %32, %27, %22, %17, %3
store float 1.000000e+01, float* %10
%112 = load i32*, i32** %6
%113 = load float*, float** %4
%114 = getelementptr inbounds float, float* %113, i64 0
%115 = load float, float* %114
%116 = load float*, float** %4
%117 = getelementptr inbounds float, float* %116, i64 1
%118 = load float, float* %117
%119 = load float*, float** %4
%120 = getelementptr inbounds float, float* %119, i64 2
%121 = load float, float* %120
%122 = load float*, float** %4
%123 = getelementptr inbounds float, float* %122, i64 3
%124 = load float, float* %123
%125 = load float*, float** %4
%126 = getelementptr inbounds float, float* %125, i64 4
%127 = load float, float* %126
%128 = load float, float* %10
%129 = call i32 @fprintf(i32* %112, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), float %115, float %118, float %121, float %124, float %127, float %128)
br label %130
130: ; preds = %111, %86
%131 = load i32*, i32** %6
%132 = call i32 @fflush(i32* %131)
%133 = load float, float* %10
ret float %133
}

LLVM IR (-O2):
@.str = [15 x i8] c"R2.simp.%s.txt\00"
@.str.1 = [21 x i8] c"%s %f %f %f %f %f %s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [29 x i8] c"Unable to open Rsquared file\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [32 x i8] c"Rsquared (%f,%f,%f,%f,%f) = %f\0A\00"
@.str.6 = [56 x i8] c"Invalid Parameter Set (%f,%f,%f,%f,%f) -> returning %f\0A\00"
define float @solve_model(float* nocapture %0, i8* %1, i32* nocapture %2) {
%4 = alloca [512 x i8]
%5 = alloca float
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = bitcast float* %5 to i8*
%8 = load float, float* %0
%9 = fcmp ogt float %8, 0.000000e+00
%10 = getelementptr inbounds float, float* %0, i64 1
%11 = load float, float* %10
br i1 %9, label %12, label %63
12: ; preds = %3
%13 = fcmp ogt float %11, 0.000000e+00
%14 = fcmp olt float %11, 1.000000e+00
%15 = and i1 %13, %14
br i1 %15, label %16, label %63
16: ; preds = %12
%17 = getelementptr inbounds float, float* %0, i64 2
%18 = load float, float* %17
%19 = fcmp ogt float %18, 0.000000e+00
%20 = fcmp olt float %18, 1.000000e+00
%21 = and i1 %19, %20
br i1 %21, label %22, label %63
22: ; preds = %16
%23 = getelementptr inbounds float, float* %0, i64 3
%24 = load float, float* %23
%25 = fpext float %24 to double
%26 = fcmp ogt double %25, 1.000000e-01
br i1 %26, label %27, label %63
27: ; preds = %22
%28 = getelementptr inbounds float, float* %0, i64 4
%29 = load float, float* %28
%30 = fpext float %29 to double
%31 = fcmp ogt double %30, 1.000000e-01
br i1 %31, label %32, label %63
32: ; preds = %27
%33 = tail call i64 @calloc(i32 512, i32 1)
%34 = inttoptr i64 %33 to i8*
%35 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %1)
%36 = load float, float* %0
%37 = fpext float %36 to double
%38 = load float, float* %10
%39 = fpext float %38 to double
%40 = load float, float* %17
%41 = fpext float %40 to double
%42 = load float, float* %23
%43 = fpext float %42 to double
%44 = load float, float* %28
%45 = fpext float %44 to double
%46 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %34, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %1, double %37, double %39, double %41, double %43, double %45, i8* %6)
%47 = call i32 @system(i8* %34)
%48 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %52
50: ; preds = %32
%51 = call i32 @nrerror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %52
52: ; preds = %50, %32
%53 = call i32 @fscanf(i32* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %5)
%54 = call i32 @fclose(i32* %48)
%55 = load float, float* %0
%56 = load float, float* %10
%57 = load float, float* %17
%58 = load float, float* %23
%59 = load float, float* %28
%60 = load float, float* %5
%61 = call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), float %55, float %56, float %57, float %58, float %59, float %60)
%62 = call i32 @free(i8* %34)
br label %71
63: ; preds = %3, %27, %22, %16, %12
store float 1.000000e+01, float* %5
%64 = getelementptr inbounds float, float* %0, i64 2
%65 = load float, float* %64
%66 = getelementptr inbounds float, float* %0, i64 3
%67 = load float, float* %66
%68 = getelementptr inbounds float, float* %0, i64 4
%69 = load float, float* %68
%70 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), float %8, float %11, float %65, float %67, float %69, float 1.000000e+01)
br label %71
71: ; preds = %63, %52
%72 = call i32 @fflush(i32* %2)
%73 = load float, float* %5
ret float %73
}