#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, float);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sscanf(char *, char *, ...);
scalar_t__ strncmp(char *, char *, int);
main() {
  int i = 0, j = 0, k = 0, line_length = 1000, atom_numb;
  float numb_1, numb_2, numb_3, bef_int, bef_ext, bef_total, aft_int, aft_ext,
      aft_total, delta_energy;
  char buffer[line_length], *word_1[1000], *word_2[1000], *word_3[1000],
      *word_4[1000], *word_5[1000], *word_6[1000];
  for (i = 0; i < 1000; i++) {
    word_1[i] = (char *)malloc(line_length);
    word_2[i] = (char *)malloc(line_length);
    word_3[i] = (char *)malloc(line_length);
    word_4[i] = (char *)malloc(line_length);
    word_5[i] = (char *)malloc(line_length);
    word_6[i] = (char *)malloc(line_length);
  }
  FILE *before, *after, *final, *fopen();
  after = fopen("after_opt.txt", "r");
  final = fopen("energy.txt", "w");
  for (j = 0; j < 1000; j++) {
    fgets(buffer, line_length, after);
    sscanf(buffer, "%s %s %s %i %s %f %s %f %s %f", word_1[j], word_2[j],
           word_3[j], &atom_numb, word_4[j], &numb_1, word_5[j], &numb_2,
           word_6[j], &numb_3);
    if (strncmp(word_3[j], "internal", 8) == 0)
      break;
    else
      continue;
  }
  sscanf(buffer, "%s %s %s %f", word_1[j], word_2[j], word_3[j], &aft_int);
  fgets(buffer, line_length, after);
  sscanf(buffer, "%s %s %s %f", word_1[j], word_2[j], word_3[j], &aft_ext);
  fgets(buffer, line_length, after);
  sscanf(buffer, "%s %s %f", word_1[j], word_2[j], &aft_total);
  fgets(buffer, line_length, after);
  fgets(buffer, line_length, after);
  sscanf(buffer, "%f %s %s %s", &aft_total, word_1[j], word_2[j], word_3[j]);
  delta_energy = aft_total;
  fprintf(final, " %f ", aft_int);
  fprintf(final, " %f ", delta_energy);
  for (i = 0; i < 1000; ++i) {
    free(word_1[i]);
    free(word_2[i]);
    free(word_3[i]);
    free(word_4[i]);
    free(word_5[i]);
    free(word_6[i]);
  }
  fclose(after);
  fclose(final);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0xbbf8,%rsp
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x3e8,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xbc10(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3e8,-0x20(%rbp)
jge    1288 <main+0x108>
mov    -0x2c(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
mov    %rcx,-0x1fb0(%rbp,%rax,8)
ff
mov    -0x2c(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
mov    %rcx,-0x3ef0(%rbp,%rax,8)
ff
mov    -0x2c(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
mov    %rcx,-0x5e30(%rbp,%rax,8)
ff
mov    -0x2c(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
mov    %rcx,-0x7d70(%rbp,%rax,8)
ff
mov    -0x2c(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
mov    %rcx,-0x9cb0(%rbp,%rax,8)
ff
mov    -0x2c(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
mov    %rcx,-0xbbf0(%rbp,%rax,8)
ff
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e3 <main+0x63>
lea    0xd71(%rip),%rdi
lea    0xd78(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0xbc00(%rbp)
lea    0xd67(%rip),%rdi
lea    0xd6b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0xbc08(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3e8,-0x24(%rbp)
jge    13b7 <main+0x237>
mov    -0xbc10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0xbc00(%rbp),%rdx
call   1060 <fgets@plt>
mov    -0xbc10(%rbp),%rdi
movslq -0x24(%rbp),%rax
mov    -0x1fb0(%rbp,%rax,8),%rdx
ff
movslq -0x24(%rbp),%rax
mov    -0x3ef0(%rbp,%rax,8),%rcx
ff
movslq -0x24(%rbp),%rax
mov    -0x5e30(%rbp,%rax,8),%r8
ff
movslq -0x24(%rbp),%rax
mov    -0x7d70(%rbp,%rax,8),%r15
ff
movslq -0x24(%rbp),%rax
mov    -0x9cb0(%rbp,%rax,8),%rbx
ff
movslq -0x24(%rbp),%rax
mov    -0xbbf0(%rbp,%rax,8),%r10
ff
lea    0xce1(%rip),%rsi
lea    -0x30(%rbp),%r9
lea    -0x34(%rbp),%r14
lea    -0x38(%rbp),%r11
lea    -0x3c(%rbp),%rax
sub    $0x30,%rsp
mov    %r15,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
mov    $0x0,%al
call   1090 <sscanf@plt>
add    $0x30,%rsp
movslq -0x24(%rbp),%rax
mov    -0x5e30(%rbp,%rax,8),%rdi
ff
lea    0xcb0(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    13a4 <main+0x224>
jmp    13b7 <main+0x237>
jmp    13a9 <main+0x229>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12c3 <main+0x143>
mov    -0xbc10(%rbp),%rdi
movslq -0x24(%rbp),%rax
mov    -0x1fb0(%rbp,%rax,8),%rdx
ff
movslq -0x24(%rbp),%rax
mov    -0x3ef0(%rbp,%rax,8),%rcx
ff
movslq -0x24(%rbp),%rax
mov    -0x5e30(%rbp,%rax,8),%r8
ff
lea    0xc5b(%rip),%rsi
lea    -0x4c(%rbp),%r9
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    -0xbc10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0xbc00(%rbp),%rdx
call   1060 <fgets@plt>
mov    -0xbc10(%rbp),%rdi
movslq -0x24(%rbp),%rax
mov    -0x1fb0(%rbp,%rax,8),%rdx
ff
movslq -0x24(%rbp),%rax
mov    -0x3ef0(%rbp,%rax,8),%rcx
ff
movslq -0x24(%rbp),%rax
mov    -0x5e30(%rbp,%rax,8),%r8
ff
lea    0xc08(%rip),%rsi
lea    -0x50(%rbp),%r9
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    -0xbc10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0xbc00(%rbp),%rdx
call   1060 <fgets@plt>
mov    -0xbc10(%rbp),%rdi
movslq -0x24(%rbp),%rax
mov    -0x1fb0(%rbp,%rax,8),%rdx
ff
movslq -0x24(%rbp),%rax
mov    -0x3ef0(%rbp,%rax,8),%rcx
ff
lea    0xbc4(%rip),%rsi
lea    -0x54(%rbp),%r8
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    -0xbc10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0xbc00(%rbp),%rdx
call   1060 <fgets@plt>
mov    -0xbc10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0xbc00(%rbp),%rdx
call   1060 <fgets@plt>
mov    -0xbc10(%rbp),%rdi
movslq -0x24(%rbp),%rax
mov    -0x1fb0(%rbp,%rax,8),%rcx
ff
movslq -0x24(%rbp),%rax
mov    -0x3ef0(%rbp,%rax,8),%r8
ff
movslq -0x24(%rbp),%rax
mov    -0x5e30(%rbp,%rax,8),%r9
ff
lea    0xb64(%rip),%rsi
lea    -0x54(%rbp),%rdx
mov    $0x0,%al
call   1090 <sscanf@plt>
movss  -0x54(%rbp),%xmm0
movss  %xmm0,-0x58(%rbp)
mov    -0xbc08(%rbp),%rdi
movss  -0x4c(%rbp),%xmm0
lea    0xb48(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0xbc08(%rbp),%rdi
movss  -0x58(%rbp),%xmm0
lea    0xb30(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3e8,-0x20(%rbp)
jge    15b9 <main+0x439>
movslq -0x20(%rbp),%rax
mov    -0x1fb0(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
movslq -0x20(%rbp),%rax
mov    -0x3ef0(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
movslq -0x20(%rbp),%rax
mov    -0x5e30(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
movslq -0x20(%rbp),%rax
mov    -0x7d70(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
movslq -0x20(%rbp),%rax
mov    -0x9cb0(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
movslq -0x20(%rbp),%rax
mov    -0xbbf0(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1538 <main+0x3b8>
mov    -0xbc00(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0xbc08(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
mov    -0x1c(%rbp),%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xbfb8,%rsp
mov    %rsp,0x20(%rsp)
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x3e8,%edi
call   1080 <malloc@plt>
mov    %rax,0x42b0(%rsp,%rbx,1)
mov    $0x3e8,%edi
call   1080 <malloc@plt>
mov    %rax,0x2370(%rsp,%rbx,1)
mov    $0x3e8,%edi
call   1080 <malloc@plt>
mov    %rax,0x430(%rsp,%rbx,1)
mov    $0x3e8,%edi
call   1080 <malloc@plt>
mov    %rax,0xa070(%rsp,%rbx,1)
mov    $0x3e8,%edi
call   1080 <malloc@plt>
mov    %rax,0x8130(%rsp,%rbx,1)
mov    $0x3e8,%edi
call   1080 <malloc@plt>
mov    %rax,0x61f0(%rsp,%rbx,1)
add    $0x8,%rbx
cmp    $0x1f40,%rbx
jne    11a0 <main+0x20>
lea    0xde0(%rip),%rdi
lea    0xde7(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,0x8(%rsp)
lea    0xdd8(%rip),%rdi
lea    0xddc(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,0x18(%rsp)
lea    0x40(%rsp),%r15
lea    0x3c(%rsp),%r12
lea    0xde1(%rip),%r13
xor    %r14d,%r14d
nopl   (%rax)
mov    %r15,%rdi
mov    $0x3e8,%esi
mov    0x8(%rsp),%rdx
call   1060 <fgets@plt>
mov    0x42b0(%rsp,%r14,8),%rdx
mov    0x2370(%rsp,%r14,8),%rcx
mov    0x430(%rsp,%r14,8),%rbx
mov    %r15,%rdi
lea    0xd89(%rip),%rsi
mov    %rbx,%r8
mov    %r12,%r9
xor    %eax,%eax
lea    0x30(%rsp),%rbp
push   %rbp
push   0x61f8(%rsp,%r14,8)
lea    0x44(%rsp),%rbp
push   %rbp
push   0x8148(%rsp,%r14,8)
lea    0x58(%rsp),%rbp
push   %rbp
push   0xa098(%rsp,%r14,8)
call   1090 <sscanf@plt>
add    $0x30,%rsp
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     12fb <main+0x17b>
add    $0x1,%r14
cmp    $0x3e8,%r14
jne    1260 <main+0xe0>
mov    $0x3e8,%r14d
mov    %r14d,%eax
shl    $0x3,%rax
mov    0x42b0(%rsp,%rax,1),%r15
mov    0x2370(%rsp,%rax,1),%r12
mov    0x430(%rsp,%rax,1),%r14
lea    0xd23(%rip),%rsi
xor    %r13d,%r13d
lea    0x40(%rsp),%rbp
lea    0x14(%rsp),%r9
mov    %rbp,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    %rbp,%rdi
mov    $0x3e8,%esi
mov    0x8(%rsp),%rbx
mov    %rbx,%rdx
call   1060 <fgets@plt>
lea    0x2c(%rsp),%r9
mov    %rbp,%rdi
lea    0xcdf(%rip),%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    %rbp,%rdi
mov    $0x3e8,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
lea    0xcbb(%rip),%rsi
lea    0x4(%rsp),%r8
mov    %rbp,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    %rbp,%rdi
mov    $0x3e8,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %rbp,%rdi
mov    $0x3e8,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
lea    0xc88(%rip),%rsi
mov    %rbp,%rdi
lea    0x4(%rsp),%rdx
mov    %r15,%rcx
mov    %r12,%r8
mov    %r14,%r9
xor    %eax,%eax
call   1090 <sscanf@plt>
movss  0x4(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x14(%rsp),%xmm0
lea    0xc63(%rip),%rbx
mov    0x18(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <fprintf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
movss  0x10(%rsp),%xmm0
call   1070 <fprintf@plt>
nopw   0x0(%rax,%rax,1)
mov    0x42b0(%rsp,%r13,1),%rdi
call   1030 <free@plt>
mov    0x2370(%rsp,%r13,1),%rdi
call   1030 <free@plt>
mov    0x430(%rsp,%r13,1),%rdi
call   1030 <free@plt>
mov    0xa070(%rsp,%r13,1),%rdi
call   1030 <free@plt>
mov    0x8130(%rsp,%r13,1),%rdi
call   1030 <free@plt>
mov    0x61f0(%rsp,%r13,1),%rdi
call   1030 <free@plt>
add    $0x8,%r13
cmp    $0x1f40,%r13
jne    1420 <main+0x2a0>
mov    0x8(%rsp),%rdi
call   1050 <fclose@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    0x20(%rsp),%rsp
xor    %eax,%eax
add    $0xbfb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"after_opt.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"energy.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [30 x i8] c"%s %s %s %i %s %f %s %f %s %f\00"
@.str.5 = [9 x i8] c"internal\00"
@.str.6 = [12 x i8] c"%s %s %s %f\00"
@.str.7 = [9 x i8] c"%s %s %f\00"
@.str.8 = [12 x i8] c"%f %s %s %s\00"
@.str.9 = [5 x i8] c" %f \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca i8*
%18 = alloca i64
%19 = alloca [1000 x i8*]
%20 = alloca [1000 x i8*]
%21 = alloca [1000 x i8*]
%22 = alloca [1000 x i8*]
%23 = alloca [1000 x i8*]
%24 = alloca [1000 x i8*]
%25 = alloca i32*
%26 = alloca i32*
%27 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 1000, i32* %5
%28 = load i32, i32* %5
%29 = zext i32 %28 to i64
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %17
%31 = alloca i8, i64 %29
store i64 %29, i64* %18
store i32 0, i32* %2
br label %32
32: ; preds = %72, %0
%33 = load i32, i32* %2
%34 = icmp slt i32 %33, 1000
br i1 %34, label %35, label %75
35: ; preds = %32
%36 = load i32, i32* %5
%37 = call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to i8*
%39 = load i32, i32* %2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %19, i64 0, i64 %40
store i8* %38, i8** %41
%42 = load i32, i32* %5
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to i8*
%45 = load i32, i32* %2
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %20, i64 0, i64 %46
store i8* %44, i8** %47
%48 = load i32, i32* %5
%49 = call i64 @malloc(i32 %48)
%50 = inttoptr i64 %49 to i8*
%51 = load i32, i32* %2
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %21, i64 0, i64 %52
store i8* %50, i8** %53
%54 = load i32, i32* %5
%55 = call i64 @malloc(i32 %54)
%56 = inttoptr i64 %55 to i8*
%57 = load i32, i32* %2
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %22, i64 0, i64 %58
store i8* %56, i8** %59
%60 = load i32, i32* %5
%61 = call i64 @malloc(i32 %60)
%62 = inttoptr i64 %61 to i8*
%63 = load i32, i32* %2
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %23, i64 0, i64 %64
store i8* %62, i8** %65
%66 = load i32, i32* %5
%67 = call i64 @malloc(i32 %66)
%68 = inttoptr i64 %67 to i8*
%69 = load i32, i32* %2
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %24, i64 0, i64 %70
store i8* %68, i8** %71
br label %72
72: ; preds = %35
%73 = load i32, i32* %2
%74 = add nsw i32 %73, 1
store i32 %74, i32* %2
br label %32
75: ; preds = %32
%76 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %76, i32** %26
%77 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %77, i32** %27
store i32 0, i32* %3
br label %78
78: ; preds = %118, %75
%79 = load i32, i32* %3
%80 = icmp slt i32 %79, 1000
br i1 %80, label %81, label %121
81: ; preds = %78
%82 = load i32, i32* %5
%83 = load i32*, i32** %26
%84 = call i32 @fgets(i8* %31, i32 %82, i32* %83)
%85 = load i32, i32* %3
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %19, i64 0, i64 %86
%88 = load i8*, i8** %87
%89 = load i32, i32* %3
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %20, i64 0, i64 %90
%92 = load i8*, i8** %91
%93 = load i32, i32* %3
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %21, i64 0, i64 %94
%96 = load i8*, i8** %95
%97 = load i32, i32* %3
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %22, i64 0, i64 %98
%100 = load i8*, i8** %99
%101 = load i32, i32* %3
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %23, i64 0, i64 %102
%104 = load i8*, i8** %103
%105 = load i32, i32* %3
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %24, i64 0, i64 %106
%108 = load i8*, i8** %107
%109 = call i32 (i8*, i8*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %88, i8* %92, i8* %96, i32* %6, i8* %100, float* %7, i8* %104, float* %8, i8* %108, float* %9)
%110 = load i32, i32* %3
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %21, i64 0, i64 %111
%113 = load i8*, i8** %112
%114 = call i64 @strncmp(i8* %113, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 8)
%115 = icmp eq i64 %114, 0
br i1 %115, label %116, label %117
116: ; preds = %81
br label %121
117: ; preds = %81
br label %118
118: ; preds = %117
%119 = load i32, i32* %3
%120 = add nsw i32 %119, 1
store i32 %120, i32* %3
br label %78
121: ; preds = %116, %78
%122 = load i32, i32* %3
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %19, i64 0, i64 %123
%125 = load i8*, i8** %124
%126 = load i32, i32* %3
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %20, i64 0, i64 %127
%129 = load i8*, i8** %128
%130 = load i32, i32* %3
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %21, i64 0, i64 %131
%133 = load i8*, i8** %132
%134 = call i32 (i8*, i8*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %125, i8* %129, i8* %133, float* %13)
%135 = load i32, i32* %5
%136 = load i32*, i32** %26
%137 = call i32 @fgets(i8* %31, i32 %135, i32* %136)
%138 = load i32, i32* %3
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %19, i64 0, i64 %139
%141 = load i8*, i8** %140
%142 = load i32, i32* %3
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %20, i64 0, i64 %143
%145 = load i8*, i8** %144
%146 = load i32, i32* %3
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %21, i64 0, i64 %147
%149 = load i8*, i8** %148
%150 = call i32 (i8*, i8*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %141, i8* %145, i8* %149, float* %14)
%151 = load i32, i32* %5
%152 = load i32*, i32** %26
%153 = call i32 @fgets(i8* %31, i32 %151, i32* %152)
%154 = load i32, i32* %3
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %19, i64 0, i64 %155
%157 = load i8*, i8** %156
%158 = load i32, i32* %3
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %20, i64 0, i64 %159
%161 = load i8*, i8** %160
%162 = call i32 (i8*, i8*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %157, i8* %161, float* %15)
%163 = load i32, i32* %5
%164 = load i32*, i32** %26
%165 = call i32 @fgets(i8* %31, i32 %163, i32* %164)
%166 = load i32, i32* %5
%167 = load i32*, i32** %26
%168 = call i32 @fgets(i8* %31, i32 %166, i32* %167)
%169 = load i32, i32* %3
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %19, i64 0, i64 %170
%172 = load i8*, i8** %171
%173 = load i32, i32* %3
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %20, i64 0, i64 %174
%176 = load i8*, i8** %175
%177 = load i32, i32* %3
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %21, i64 0, i64 %178
%180 = load i8*, i8** %179
%181 = call i32 (i8*, i8*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), float* %15, i8* %172, i8* %176, i8* %180)
%182 = load float, float* %15
store float %182, float* %16
%183 = load i32*, i32** %27
%184 = load float, float* %13
%185 = call i32 @fprintf(i32* %183, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), float %184)
%186 = load i32*, i32** %27
%187 = load float, float* %16
%188 = call i32 @fprintf(i32* %186, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), float %187)
store i32 0, i32* %2
br label %189
189: ; preds = %223, %121
%190 = load i32, i32* %2
%191 = icmp slt i32 %190, 1000
br i1 %191, label %192, label %226
192: ; preds = %189
%193 = load i32, i32* %2
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %19, i64 0, i64 %194
%196 = load i8*, i8** %195
%197 = call i32 @free(i8* %196)
%198 = load i32, i32* %2
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %20, i64 0, i64 %199
%201 = load i8*, i8** %200
%202 = call i32 @free(i8* %201)
%203 = load i32, i32* %2
%204 = sext i32 %203 to i64
%205 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %21, i64 0, i64 %204
%206 = load i8*, i8** %205
%207 = call i32 @free(i8* %206)
%208 = load i32, i32* %2
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %22, i64 0, i64 %209
%211 = load i8*, i8** %210
%212 = call i32 @free(i8* %211)
%213 = load i32, i32* %2
%214 = sext i32 %213 to i64
%215 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %23, i64 0, i64 %214
%216 = load i8*, i8** %215
%217 = call i32 @free(i8* %216)
%218 = load i32, i32* %2
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %24, i64 0, i64 %219
%221 = load i8*, i8** %220
%222 = call i32 @free(i8* %221)
br label %223
223: ; preds = %192
%224 = load i32, i32* %2
%225 = add nsw i32 %224, 1
store i32 %225, i32* %2
br label %189
226: ; preds = %189
%227 = load i32*, i32** %26
%228 = call i32 @fclose(i32* %227)
%229 = load i32*, i32** %27
%230 = call i32 @fclose(i32* %229)
%231 = load i8*, i8** %17
%232 = load i32, i32* %1
ret i32 %232
}

LLVM IR (-O2):
@.str = [14 x i8] c"after_opt.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"energy.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [30 x i8] c"%s %s %s %i %s %f %s %f %s %f\00"
@.str.5 = [9 x i8] c"internal\00"
@.str.6 = [12 x i8] c"%s %s %s %f\00"
@.str.7 = [9 x i8] c"%s %s %f\00"
@.str.8 = [12 x i8] c"%f %s %s %s\00"
@.str.9 = [5 x i8] c" %f \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca [1000 x i8*]
%9 = alloca [1000 x i8*]
%10 = alloca [1000 x i8*]
%11 = alloca [1000 x i8*]
%12 = alloca [1000 x i8*]
%13 = alloca [1000 x i8*]
%14 = bitcast i32* %1 to i8*
%15 = bitcast float* %2 to i8*
%16 = bitcast float* %3 to i8*
%17 = bitcast float* %4 to i8*
%18 = bitcast float* %5 to i8*
%19 = bitcast float* %6 to i8*
%20 = bitcast float* %7 to i8*
%21 = tail call i8* @llvm.stacksave()
%22 = alloca [1000 x i8]
%23 = bitcast [1000 x i8*]* %8 to i8*
%24 = bitcast [1000 x i8*]* %9 to i8*
%25 = bitcast [1000 x i8*]* %10 to i8*
%26 = bitcast [1000 x i8*]* %11 to i8*
%27 = bitcast [1000 x i8*]* %12 to i8*
%28 = bitcast [1000 x i8*]* %13 to i8*
br label %29
29: ; preds = %0, %29
%30 = phi i64 [ 0, %0 ], [ %49, %29 ]
%31 = tail call i64 @malloc(i32 1000)
%32 = inttoptr i64 %31 to i8*
%33 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %8, i64 0, i64 %30
store i8* %32, i8** %33
%34 = tail call i64 @malloc(i32 1000)
%35 = inttoptr i64 %34 to i8*
%36 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %9, i64 0, i64 %30
store i8* %35, i8** %36
%37 = tail call i64 @malloc(i32 1000)
%38 = inttoptr i64 %37 to i8*
%39 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %10, i64 0, i64 %30
store i8* %38, i8** %39
%40 = tail call i64 @malloc(i32 1000)
%41 = inttoptr i64 %40 to i8*
%42 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %11, i64 0, i64 %30
store i8* %41, i8** %42
%43 = tail call i64 @malloc(i32 1000)
%44 = inttoptr i64 %43 to i8*
%45 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %12, i64 0, i64 %30
store i8* %44, i8** %45
%46 = tail call i64 @malloc(i32 1000)
%47 = inttoptr i64 %46 to i8*
%48 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %13, i64 0, i64 %30
store i8* %47, i8** %48
%49 = add nuw nsw i64 %30, 1
%50 = icmp eq i64 %49, 1000
br i1 %50, label %51, label %29
51: ; preds = %29
%52 = getelementptr inbounds [1000 x i8], [1000 x i8]* %22, i64 0, i64 0
%53 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%54 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %51, %73
%56 = phi i64 [ 0, %51 ], [ %74, %73 ]
%57 = call i32 @fgets(i8* %52, i32 1000, i32* %53)
%58 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %8, i64 0, i64 %56
%59 = load i8*, i8** %58
%60 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %9, i64 0, i64 %56
%61 = load i8*, i8** %60
%62 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %10, i64 0, i64 %56
%63 = load i8*, i8** %62
%64 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %11, i64 0, i64 %56
%65 = load i8*, i8** %64
%66 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %12, i64 0, i64 %56
%67 = load i8*, i8** %66
%68 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %13, i64 0, i64 %56
%69 = load i8*, i8** %68
%70 = call i32 (i8*, i8*, ...) @sscanf(i8* %52, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %59, i8* %61, i8* %63, i32* %1, i8* %65, float* %2, i8* %67, float* %3, i8* %69, float* %4)
%71 = call i64 @strncmp(i8* %63, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 8)
%72 = icmp eq i64 %71, 0
br i1 %72, label %76, label %73
73: ; preds = %55
%74 = add nuw nsw i64 %56, 1
%75 = icmp eq i64 %74, 1000
br i1 %75, label %76, label %55
76: ; preds = %55, %73
%77 = phi i64 [ %56, %55 ], [ 1000, %73 ]
%78 = and i64 %77, 4294967295
%79 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %8, i64 0, i64 %78
%80 = load i8*, i8** %79
%81 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %9, i64 0, i64 %78
%82 = load i8*, i8** %81
%83 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %10, i64 0, i64 %78
%84 = load i8*, i8** %83
%85 = call i32 (i8*, i8*, ...) @sscanf(i8* %52, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %80, i8* %82, i8* %84, float* %5)
%86 = call i32 @fgets(i8* %52, i32 1000, i32* %53)
%87 = call i32 (i8*, i8*, ...) @sscanf(i8* %52, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %80, i8* %82, i8* %84, float* %6)
%88 = call i32 @fgets(i8* %52, i32 1000, i32* %53)
%89 = call i32 (i8*, i8*, ...) @sscanf(i8* %52, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %80, i8* %82, float* %7)
%90 = call i32 @fgets(i8* %52, i32 1000, i32* %53)
%91 = call i32 @fgets(i8* %52, i32 1000, i32* %53)
%92 = call i32 (i8*, i8*, ...) @sscanf(i8* %52, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), float* %7, i8* %80, i8* %82, i8* %84)
%93 = load float, float* %7
%94 = load float, float* %5
%95 = call i32 @fprintf(i32* %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), float %94)
%96 = call i32 @fprintf(i32* %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), float %93)
br label %97
97: ; preds = %76, %97
%98 = phi i64 [ 0, %76 ], [ %117, %97 ]
%99 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %8, i64 0, i64 %98
%100 = load i8*, i8** %99
%101 = call i32 @free(i8* %100)
%102 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %9, i64 0, i64 %98
%103 = load i8*, i8** %102
%104 = call i32 @free(i8* %103)
%105 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %10, i64 0, i64 %98
%106 = load i8*, i8** %105
%107 = call i32 @free(i8* %106)
%108 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %11, i64 0, i64 %98
%109 = load i8*, i8** %108
%110 = call i32 @free(i8* %109)
%111 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %12, i64 0, i64 %98
%112 = load i8*, i8** %111
%113 = call i32 @free(i8* %112)
%114 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %13, i64 0, i64 %98
%115 = load i8*, i8** %114
%116 = call i32 @free(i8* %115)
%117 = add nuw nsw i64 %98, 1
%118 = icmp eq i64 %117, 1000
br i1 %118, label %119, label %97
119: ; preds = %97
%120 = call i32 @fclose(i32* %53)
%121 = call i32 @fclose(i32* %54)
ret i32 0
}