#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 F(double);
double V(double);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, ...);
double rho(double);
int main(void) {
  int Nr = 10001;
  double rmax = 9.;
  double dr = rmax / (double)Nr;
  int Nrho = 10001;
  double rhomax = rho(0.);
  double drho = rhomax / (double)Nrho;
  int atomic_number = 1;
  double mass = 63.55;
  double lattice_constant = 3.615;
  char lattice_type[] = "FCC";
  int i;
  char LAMMPSFilename[] = "Cu_Mishin1.eam";
  FILE *LAMMPSFile = fopen(LAMMPSFilename, "w");
  if (!LAMMPSFile)
    exit(-1);
  fprintf(LAMMPSFile,
          "#-> LAMMPS Potential File in DYNAMO 86 setfl Format <-#\n"
          "# Mishin Cu EAM1 PRB(2001)63:224106\n"
          "# Implemented by G. Ziegenhain (2007) gerolf@ziegenhain.com \n"
          "%d Cu\n"
          "%d %20.20f %d %20.20f %20.20f\n"
          "%d %20.20f %20.20f %s\n",
          atomic_number, Nrho, drho, Nr, dr, 5.50679, atomic_number, mass,
          lattice_constant, lattice_type);
  for (i = 0; i < Nrho; i++)
    fprintf(LAMMPSFile, "%20.20f\n", F((double)i * drho));
  for (i = 0; i < Nr; i++)
    fprintf(LAMMPSFile, "%20.20f\n", rho((double)i * dr));
  for (i = 0; i < Nr; i++)
    fprintf(LAMMPSFile, "%20.20f\n", V((double)i * dr) * (double)i * dr);
  fclose(LAMMPSFile);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2711,-0x8(%rbp)
movsd  0xe7f(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x2711,-0x1c(%rbp)
xorps  %xmm0,%xmm0
call   1070 <rho@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
movsd  0xe29(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe14(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    0xe29(%rip),%eax
mov    %eax,-0x4c(%rbp)
mov    0xe23(%rip),%rax
mov    %rax,-0x5f(%rbp)
mov    0xe21(%rip),%eax
mov    %eax,-0x57(%rbp)
mov    0xe1b(%rip),%ax
mov    %ax,-0x53(%rbp)
mov    0xe13(%rip),%al
mov    %al,-0x51(%rbp)
lea    -0x5f(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    124b <main+0xdb>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x68(%rbp),%rdi
cvtsi2sdl -0x34(%rbp),%xmm0
mov    -0x1c(%rbp),%edx
movsd  -0x30(%rbp),%xmm1
mov    -0x8(%rbp),%ecx
movsd  -0x18(%rbp),%xmm2
mov    -0x34(%rbp),%r8d
movsd  -0x40(%rbp),%xmm4
movsd  -0x48(%rbp),%xmm5
lea    -0x4c(%rbp),%r9
lea    0xdb8(%rip),%rsi
movsd  0xd93(%rip),%xmm3
mov    $0x6,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12d6 <main+0x166>
mov    -0x68(%rbp),%rax
mov    %rax,-0x70(%rbp)
cvtsi2sdl -0x50(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <F@plt>
mov    -0x70(%rbp),%rdi
lea    0xe48(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1293 <main+0x123>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1320 <main+0x1b0>
mov    -0x68(%rbp),%rax
mov    %rax,-0x78(%rbp)
cvtsi2sdl -0x50(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1070 <rho@plt>
mov    -0x78(%rbp),%rdi
lea    0xdfe(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    12dd <main+0x16d>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1378 <main+0x208>
mov    -0x68(%rbp),%rax
mov    %rax,-0x80(%rbp)
cvtsi2sdl -0x50(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1040 <V@plt>
mov    -0x80(%rbp),%rdi
cvtsi2sdl -0x50(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x18(%rbp),%xmm0
lea    0xda6(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1327 <main+0x1b7>
mov    -0x68(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
call   1070 <rho@plt>
movsd  %xmm0,0x10(%rsp)
movl   $0x434346,0x1c(%rsp)
movabs $0x6d61652e316e69,%rax
mov    %rax,0x27(%rsp)
movabs $0x696873694d5f7543,%rax
73 68 69
mov    %rax,0x20(%rsp)
lea    0xe8c(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     133e <main+0x1ce>
mov    %rax,%rbx
movsd  0x10(%rsp),%xmm1
divsd  0xe29(%rip),%xmm1
lea    0xe63(%rip),%rsi
movsd  0xe22(%rip),%xmm0
mov    $0x2711,%ebp
movsd  0xe1d(%rip),%xmm2
movsd  0xe1d(%rip),%xmm3
movsd  0xe1d(%rip),%xmm4
movsd  0xe1d(%rip),%xmm5
lea    0x1c(%rsp),%r9
mov    %rax,%rdi
mov    $0x2711,%edx
movsd  %xmm1,0x10(%rsp)
mov    $0x2711,%ecx
mov    $0x1,%r8d
mov    $0x6,%al
call   1060 <fprintf@plt>
lea    0xede(%rip),%r14
xorpd  %xmm1,%xmm1
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <F@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
movsd  0x8(%rsp),%xmm1
addsd  0xd98(%rip),%xmm1
add    $0xffffffff,%ebp
jne    1240 <main+0xd0>
xorpd  %xmm2,%xmm2
mov    $0x2711,%ebp
lea    0xe90(%rip),%r14
movsd  0xd83(%rip),%xmm1
nopl   (%rax)
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm0
mulsd  %xmm1,%xmm0
call   1070 <rho@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
movsd  0x8(%rsp),%xmm2
movsd  0xd52(%rip),%xmm1
addsd  0xd42(%rip),%xmm2
add    $0xffffffff,%ebp
jne    1290 <main+0x120>
xorpd  %xmm0,%xmm0
mov    $0x2711,%ebp
lea    0xe3a(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <V@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0xd0d(%rip),%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
movsd  0x8(%rsp),%xmm0
movsd  0xcf2(%rip),%xmm1
addsd  0xce2(%rip),%xmm0
add    $0xffffffff,%ebp
jne    12e0 <main+0x170>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@__const.main.lattice_type = [4 x i8] c"FCC\00"
@__const.main.LAMMPSFilename = [15 x i8] c"Cu_Mishin1.eam\00"
@.str = [2 x i8] c"w\00"
@.str.1 = [212 x i8] c"#-> LAMMPS Potential File in DYNAMO 86 setfl Format <-#\0A# Mishin Cu EAM1 PRB(2001)63:224106\0A# Implemented by G. Ziegenhain (2007) gerolf@ziegenhain.com \0A%d Cu\0A%d %20.20f %d %20.20f %20.20f\0A%d %20.20f %20.20f %s\0A\00"
@.str.2 = [9 x i8] c"%20.20f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca [4 x i8]
%12 = alloca i32
%13 = alloca [15 x i8]
%14 = alloca i32*
store i32 0, i32* %1
store i32 10001, i32* %2
store double 9.000000e+00, double* %3
%15 = load double, double* %3
%16 = load i32, i32* %2
%17 = sitofp i32 %16 to double
%18 = fdiv double %15, %17
store double %18, double* %4
store i32 10001, i32* %5
%19 = call double @rho(double 0.000000e+00)
store double %19, double* %6
%20 = load double, double* %6
%21 = load i32, i32* %5
%22 = sitofp i32 %21 to double
%23 = fdiv double %20, %22
store double %23, double* %7
store i32 1, i32* %8
store double 6.355000e+01, double* %9
store double 3.615000e+00, double* %10
%24 = bitcast [4 x i8]* %11 to i8*
%25 = bitcast [15 x i8]* %13 to i8*
%26 = getelementptr inbounds [15 x i8], [15 x i8]* %13, i64 0, i64 0
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %27, i32** %14
%28 = load i32*, i32** %14
%29 = icmp ne i32* %28, null
br i1 %29, label %32, label %30
30: ; preds = %0
%31 = call i32 @exit(i32 -1)
unreachable
32: ; preds = %0
%33 = load i32*, i32** %14
%34 = load i32, i32* %8
%35 = sitofp i32 %34 to double
%36 = load i32, i32* %5
%37 = load double, double* %7
%38 = load i32, i32* %2
%39 = load double, double* %4
%40 = load i32, i32* %8
%41 = load double, double* %9
%42 = load double, double* %10
%43 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 0
%44 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([212 x i8], [212 x i8]* @.str.1, i64 0, i64 0), double %35, i32 %36, double %37, i32 %38, double %39, double 5.506790e+00, i32 %40, double %41, double %42, i8* %43)
store i32 0, i32* %12
br label %45
45: ; preds = %57, %32
%46 = load i32, i32* %12
%47 = load i32, i32* %5
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %60
49: ; preds = %45
%50 = load i32*, i32** %14
%51 = load i32, i32* %12
%52 = sitofp i32 %51 to double
%53 = load double, double* %7
%54 = fmul double %52, %53
%55 = call double @F(double %54)
%56 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %55)
br label %57
57: ; preds = %49
%58 = load i32, i32* %12
%59 = add nsw i32 %58, 1
store i32 %59, i32* %12
br label %45
60: ; preds = %45
store i32 0, i32* %12
br label %61
61: ; preds = %73, %60
%62 = load i32, i32* %12
%63 = load i32, i32* %2
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %76
65: ; preds = %61
%66 = load i32*, i32** %14
%67 = load i32, i32* %12
%68 = sitofp i32 %67 to double
%69 = load double, double* %4
%70 = fmul double %68, %69
%71 = call double @rho(double %70)
%72 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %66, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %71)
br label %73
73: ; preds = %65
%74 = load i32, i32* %12
%75 = add nsw i32 %74, 1
store i32 %75, i32* %12
br label %61
76: ; preds = %61
store i32 0, i32* %12
br label %77
77: ; preds = %94, %76
%78 = load i32, i32* %12
%79 = load i32, i32* %2
%80 = icmp slt i32 %78, %79
br i1 %80, label %81, label %97
81: ; preds = %77
%82 = load i32*, i32** %14
%83 = load i32, i32* %12
%84 = sitofp i32 %83 to double
%85 = load double, double* %4
%86 = fmul double %84, %85
%87 = call double @V(double %86)
%88 = load i32, i32* %12
%89 = sitofp i32 %88 to double
%90 = fmul double %87, %89
%91 = load double, double* %4
%92 = fmul double %90, %91
%93 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %92)
br label %94
94: ; preds = %81
%95 = load i32, i32* %12
%96 = add nsw i32 %95, 1
store i32 %96, i32* %12
br label %77
97: ; preds = %77
%98 = load i32*, i32** %14
%99 = call i32 @fclose(i32* %98)
ret i32 0
}

LLVM IR (-O2):
@__const.main.LAMMPSFilename = [15 x i8] c"Cu_Mishin1.eam\00"
@.str = [2 x i8] c"w\00"
@.str.1 = [212 x i8] c"#-> LAMMPS Potential File in DYNAMO 86 setfl Format <-#\0A# Mishin Cu EAM1 PRB(2001)63:224106\0A# Implemented by G. Ziegenhain (2007) gerolf@ziegenhain.com \0A%d Cu\0A%d %20.20f %d %20.20f %20.20f\0A%d %20.20f %20.20f %s\0A\00"
@.str.2 = [9 x i8] c"%20.20f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = tail call double @rho(double 0.000000e+00)
%4 = fdiv double %3, 1.000100e+04
%5 = bitcast i32* %1 to i8*
store i32 4408134, i32* %1
%6 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %0
%12 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([212 x i8], [212 x i8]* @.str.1, i64 0, i64 0), double 1.000000e+00, i32 10001, double %4, i32 10001, double 0x3F4D7CFE076C5A9D, double 5.506790e+00, i32 1, double 6.355000e+01, double 3.615000e+00, i32* %1)
br label %13
13: ; preds = %11, %13
%14 = phi i32 [ 0, %11 ], [ %19, %13 ]
%15 = sitofp i32 %14 to double
%16 = fmul double %4, %15
%17 = call double @F(double %16)
%18 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %17)
%19 = add nuw nsw i32 %14, 1
%20 = icmp eq i32 %19, 10001
br i1 %20, label %21, label %13
21: ; preds = %13, %21
%22 = phi i32 [ %27, %21 ], [ 0, %13 ]
%23 = sitofp i32 %22 to double
%24 = fmul double %23, 0x3F4D7CFE076C5A9D
%25 = call double @rho(double %24)
%26 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %25)
%27 = add nuw nsw i32 %22, 1
%28 = icmp eq i32 %27, 10001
br i1 %28, label %29, label %21
29: ; preds = %21, %29
%30 = phi i32 [ %37, %29 ], [ 0, %21 ]
%31 = sitofp i32 %30 to double
%32 = fmul double %31, 0x3F4D7CFE076C5A9D
%33 = call double @V(double %32)
%34 = fmul double %33, %31
%35 = fmul double %34, 0x3F4D7CFE076C5A9D
%36 = call i32 (i32*, i8*, double, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %35)
%37 = add nuw nsw i32 %30, 1
%38 = icmp eq i32 %37, 10001
br i1 %38, label %39, label %29
39: ; preds = %29
%40 = call i32 @fclose(i32* %7)
ret i32 0
}