#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 */
double exp(float);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, double);
double pow(int, double);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, float *);
int main(int argc, char *argv[]) {
  FILE *output_file;
  output_file = fopen("partial_ionization.dat", "w");
  const int num_steps = 1e4;
  const int min_temp = 5e3;
  int temp = min_temp;
  int i = 0;
  const double h_planck = 6.6260689633e-34;
  const double k_eV = 8.61734315e-5;
  const double k_boltz = 1.380650424e-23;
  const int c_light = 299792458;
  const double m_electron = 9.1093821545e-31;
  const double pi = 3.1415926535897932384626433832795028841971693993751;
  double ratio_2_1;
  double first_part;
  double second_part;
  double third_part;
  float chi;
  float Z_I;
  float Z_II;
  float p_e;
  printf("%s", "Please enter the ionization energy in eV\n");
  scanf("%f", &chi);
  printf("%s", "Please enter the first partition function\n");
  scanf("%f", &Z_I);
  printf("%s", "Please enter the second partition function\n");
  scanf("%f", &Z_II);
  printf("%s", "Please enter the electron pressure in N/m^2\n");
  scanf("%f", &p_e);
  while (i < num_steps) {
    temp += 1;
    first_part = 2 * k_boltz * temp * Z_II / (p_e * Z_I);
    second_part =
        pow(2 * pi * m_electron * k_boltz * temp / (h_planck * h_planck), 1.5);
    third_part = exp(-chi / (k_eV * temp));
    ratio_2_1 = first_part * second_part * third_part;
    fprintf(output_file, "%d\t\t%lf\n", temp, ratio_2_1);
    i++;
  }
  printf("%s\n", "The output is in a file called partial_ionization.dat");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xfaa(%rip),%rdi
lea    0xec1(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x2710,-0x1c(%rbp)
movl   $0x1388,-0x20(%rbp)
movl   $0x1388,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movsd  0xe6c(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe57(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe42(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x11de784a,-0x44(%rbp)
movsd  0xe26(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe11(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
lea    0xe4f(%rip),%rdi
lea    0xe4b(%rip),%rsi
call   1030 <printf@plt>
lea    0xe69(%rip),%rdi
lea    -0x7c(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe2c(%rip),%rdi
lea    0xe55(%rip),%rsi
call   1030 <printf@plt>
lea    0xe46(%rip),%rdi
lea    -0x80(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe09(%rip),%rdi
lea    0xe5d(%rip),%rsi
call   1030 <printf@plt>
lea    0xe23(%rip),%rdi
lea    -0x84(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xde3(%rip),%rdi
lea    0xe63(%rip),%rsi
call   1030 <printf@plt>
lea    0xdfd(%rip),%rdi
lea    -0x88(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x2710,-0x28(%rbp)
jge    137d <main+0x21d>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  0xd97(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x84(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movss  -0x88(%rbp),%xmm1
ff
mulss  -0x80(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  0xd54(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd40(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
movsd  0xd28(%rip),%xmm0
call   1080 <pow@plt>
movsd  %xmm0,-0x70(%rbp)
movss  -0x7c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm2
movsd  0xceb(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <exp@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%edx
movsd  -0x60(%rbp),%xmm0
lea    0xd94(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1286 <main+0x126>
lea    0xd83(%rip),%rdi
lea    0xd80(%rip),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
lea    0xf9b(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xea5(%rip),%r14
lea    0xea1(%rip),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0xebc(%rip),%rbp
lea    0x14(%rsp),%rsi
mov    %rbp,%rdi
call   1060 <scanf@plt>
lea    0xeab(%rip),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
call   1060 <scanf@plt>
lea    0xeba(%rip),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbp,%rdi
call   1060 <scanf@plt>
lea    0xeca(%rip),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
call   1060 <scanf@plt>
mov    $0x1389,%ebp
lea    0xed6(%rip),%r14
nopl   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movapd %xmm1,%xmm0
movapd %xmm1,%xmm2
movsd  %xmm1,0x18(%rsp)
mulsd  0xdd3(%rip),%xmm0
movss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
movss  0x8(%rsp),%xmm0
mulss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x28(%rsp)
movapd %xmm2,%xmm0
mulsd  0xda7(%rip),%xmm0
divsd  0xda7(%rip),%xmm0
cvttsd2si %xmm0,%edi
movsd  0xda3(%rip),%xmm0
call   1080 <pow@plt>
movsd  %xmm0,0x20(%rsp)
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  0xd88(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <exp@plt>
movsd  0x20(%rsp),%xmm1
mulsd  0x28(%rsp),%xmm1
mulsd  %xmm1,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <fprintf@plt>
add    $0x1,%ebp
cmp    $0x3a99,%ebp
jne    1210 <main+0xb0>
lea    0xe0f(%rip),%rdi
lea    0xe0c(%rip),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"partial_ionization.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [42 x i8] c"Please enter the ionization energy in eV\0A\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [43 x i8] c"Please enter the first partition function\0A\00"
@.str.6 = [44 x i8] c"Please enter the second partition function\0A\00"
@.str.7 = [45 x i8] c"Please enter the electron pressure in N/m^2\0A\00"
@.str.8 = [9 x i8] c"%d\09\09%lf\0A\00"
@.str.9 = [4 x i8] c"%s\0A\00"
@.str.10 = [54 x i8] c"The output is in a file called partial_ionization.dat\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca float
%22 = alloca float
%23 = alloca float
%24 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%25 = call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %6
store i32 10000, i32* %7
store i32 5000, i32* %8
store i32 5000, i32* %9
store i32 0, i32* %10
store double 0x390B860B8B4EC197, double* %11
store double 0x3F16970047C228C4, double* %12
store double 0x3B30B0E7F630B325, double* %13
store i32 299792458, i32* %14
store double 0x39B279DC941272A4, double* %15
store double 0x400921FB54442D18, double* %16
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %21)
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %22)
%30 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %23)
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %24)
br label %34
34: ; preds = %37, %2
%35 = load i32, i32* %10
%36 = icmp slt i32 %35, 10000
br i1 %36, label %37, label %77
37: ; preds = %34
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
%40 = load i32, i32* %9
%41 = sitofp i32 %40 to double
%42 = fmul double 0x3B40B0E7F630B325, %41
%43 = load float, float* %23
%44 = fpext float %43 to double
%45 = fmul double %42, %44
%46 = load float, float* %24
%47 = load float, float* %22
%48 = fmul float %46, %47
%49 = fpext float %48 to double
%50 = fdiv double %45, %49
store double %50, double* %18
%51 = load i32, i32* %9
%52 = sitofp i32 %51 to double
%53 = fmul double 0x351E46891BD077B1, %52
%54 = fdiv double %53, 0x3227AC64FBC7C469
%55 = fptosi double %54 to i32
%56 = call double @pow(i32 %55, double 1.500000e+00)
store double %56, double* %19
%57 = load float, float* %21
%58 = fneg float %57
%59 = fpext float %58 to double
%60 = load i32, i32* %9
%61 = sitofp i32 %60 to double
%62 = fmul double 0x3F16970047C228C4, %61
%63 = fdiv double %59, %62
%64 = fptrunc double %63 to float
%65 = call double @exp(float %64)
store double %65, double* %20
%66 = load double, double* %18
%67 = load double, double* %19
%68 = fmul double %66, %67
%69 = load double, double* %20
%70 = fmul double %68, %69
store double %70, double* %17
%71 = load i32*, i32** %6
%72 = load i32, i32* %9
%73 = load double, double* %17
%74 = call i32 @fprintf(i32* %71, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %72, double %73)
%75 = load i32, i32* %10
%76 = add nsw i32 %75, 1
store i32 %76, i32* %10
br label %34
77: ; preds = %34
%78 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"partial_ionization.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [42 x i8] c"Please enter the ionization energy in eV\0A\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [43 x i8] c"Please enter the first partition function\0A\00"
@.str.6 = [44 x i8] c"Please enter the second partition function\0A\00"
@.str.7 = [45 x i8] c"Please enter the electron pressure in N/m^2\0A\00"
@.str.8 = [9 x i8] c"%d\09\09%lf\0A\00"
@.str.9 = [4 x i8] c"%s\0A\00"
@.str.10 = [54 x i8] c"The output is in a file called partial_ionization.dat\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = bitcast float* %3 to i8*
%9 = bitcast float* %4 to i8*
%10 = bitcast float* %5 to i8*
%11 = bitcast float* %6 to i8*
%12 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %3)
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %4)
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %5)
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %6)
br label %20
20: ; preds = %2, %20
%21 = phi i32 [ 5000, %2 ], [ %22, %20 ]
%22 = add nuw nsw i32 %21, 1
%23 = sitofp i32 %22 to double
%24 = fmul double %23, 0x3B40B0E7F630B325
%25 = load float, float* %5
%26 = fpext float %25 to double
%27 = fmul double %24, %26
%28 = load float, float* %6
%29 = load float, float* %4
%30 = fmul float %28, %29
%31 = fpext float %30 to double
%32 = fdiv double %27, %31
%33 = fmul double %23, 0x351E46891BD077B1
%34 = fdiv double %33, 0x3227AC64FBC7C469
%35 = fptosi double %34 to i32
%36 = call double @pow(i32 %35, double 1.500000e+00)
%37 = load float, float* %3
%38 = fneg float %37
%39 = fpext float %38 to double
%40 = fmul double %23, 0x3F16970047C228C4
%41 = fdiv double %39, %40
%42 = fptrunc double %41 to float
%43 = call double @exp(float %42)
%44 = fmul double %36, %32
%45 = fmul double %43, %44
%46 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %22, double %45)
%47 = icmp eq i32 %22, 15000
br i1 %47, label %48, label %20
48: ; preds = %20
%49 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}