#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*/ dump(char *, size_t);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
scalar_t__ realloc(char *, size_t);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ *stdout;
size_t strlen(char *);
scalar_t__ strstr(char *, char *);
int strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  size_t bufsize = (1024 * 1024), currsize = (1024 * 1024), bytesread = 0, i,
         nase;
  char *buf, *p;
  FILE *log;
  if (argc != 3) {
    fputs("Expecting number of atoms and log filename as parameters.\n",
          stderr);
    return 1;
  }
  nase = strtol(argv[1], NULL, 10) * 2;
  log = fopen(argv[2], "a");
  if (!log) {
    fprintf(stderr, "Cannot open log file %s for writing.\n", argv[2]);
    return 1;
  }
  buf = (char *)malloc((1024 * 1024));
  if (!buf) {
    fputs("Buffer memory allocation error!\n", stderr);
    return 1;
  }
  p = buf;
  while (fgets(p, 65536, stdin)) {
    fputs(p, log);
    fflush(log);
    if (strstr(p, "   total energy") || strstr(p, "     stopping") ||
        strstr(p, "     convergence NOT")) {
      fputs(p, stderr);
      fflush(stderr);
    } else if (strstr(p, "     Writing output data file")) {
      dump(buf, bytesread + strlen(p));
      p = buf;
      bytesread = 0;
      continue;
    } else if (strstr(p, "!ASE")) {
      dump(buf, bytesread + strlen(p));
      p = buf;
      bytesread = 0;
      for (i = 0; i < nase; i++) {
        fgets(buf, 65536, stdin);
        fputs(buf, stdout);
      }
      fflush(stdout);
      continue;
    }
    i = strlen(p);
    p += i;
    bytesread += i;
    if (bytesread + 65536 >= currsize) {
      currsize += (1024 * 1024);
      buf = (char *)realloc(buf, currsize);
      if (!buf) {
        fputs("Buffer memory re-allocation error!\n", stderr);
        return 1;
      }
      p = buf + bytesread;
    }
  }
  if (bytesread > 0)
    dump(buf, bytesread);
  fclose(log);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x100000,-0x18(%rbp)
movq   $0x100000,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     121a <main+0x5a>
mov    0x2dd9(%rip),%rax
mov    (%rax),%rsi
lea    0xdf7(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    154d <main+0x38d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
shl    $0x1,%eax
cltq
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdf3(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1286 <main+0xc6>
mov    0x2d75(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdc8(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    154d <main+0x38d>
mov    $0x100000,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    12c1 <main+0x101>
mov    0x2d32(%rip),%rax
mov    (%rax),%rsi
lea    0xdb3(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    154d <main+0x38d>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    0x2d14(%rip),%rax
mov    (%rax),%edx
mov    $0x10000,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1525 <main+0x365>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x50(%rbp),%rdi
call   10b0 <fflush@plt>
mov    -0x48(%rbp),%rdi
lea    0xd79(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
jne    134e <main+0x18e>
mov    -0x48(%rbp),%rdi
lea    0xd6f(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
jne    134e <main+0x18e>
mov    -0x48(%rbp),%rdi
lea    0xd63(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
je     1375 <main+0x1b5>
mov    -0x48(%rbp),%rdi
mov    0x2c7f(%rip),%rax
mov    (%rax),%rsi
call   1050 <fputs@plt>
mov    0x2c70(%rip),%rax
mov    (%rax),%rdi
call   10b0 <fflush@plt>
jmp    148f <main+0x2cf>
mov    -0x48(%rbp),%rdi
lea    0xd37(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
je     13cd <main+0x20d>
mov    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x48(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x60(%rbp),%rsi
mov    -0x58(%rbp),%rdi
add    %rax,%rsi
call   1060 <dump@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x28(%rbp)
jmp    12c9 <main+0x109>
mov    -0x48(%rbp),%rdi
lea    0xcfd(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
je     1485 <main+0x2c5>
mov    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x48(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x70(%rbp),%rsi
mov    -0x68(%rbp),%rdi
add    %rax,%rsi
call   1060 <dump@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    1471 <main+0x2b1>
mov    -0x40(%rbp),%rdi
mov    0x2ba7(%rip),%rax
mov    (%rax),%edx
mov    $0x10000,%esi
call   1070 <fgets@plt>
mov    -0x40(%rbp),%rdi
mov    0x2b78(%rip),%rax
mov    (%rax),%rsi
call   1050 <fputs@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1428 <main+0x268>
mov    0x2b58(%rip),%rax
mov    (%rax),%rdi
call   10b0 <fflush@plt>
jmp    12c9 <main+0x109>
jmp    148a <main+0x2ca>
jmp    148f <main+0x2cf>
mov    -0x48(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x10000,%rax
cmp    -0x20(%rbp),%rax
jb     1520 <main+0x360>
mov    -0x20(%rbp),%rax
add    $0x100000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10c0 <realloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1514 <main+0x354>
mov    0x2adf(%rip),%rax
mov    (%rax),%rsi
lea    0xbd7(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    154d <main+0x38d>
mov    -0x40(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    12c9 <main+0x109>
cmpq   $0x0,-0x28(%rbp)
jbe    153d <main+0x37d>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <dump@plt>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x3,%edi
jne    127f <main+0xaf>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,0x10(%rsp)
mov    0x10(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1482 <main+0x2b2>
mov    %rax,%rbx
mov    $0x100000,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     14a3 <main+0x2d3>
mov    %rax,%r15
mov    0x2db0(%rip),%r12
mov    (%r12),%edx
mov    %rax,%rdi
mov    $0x10000,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     14cb <main+0x2fb>
mov    0x10(%rsp),%rax
add    %eax,%eax
cmp    $0x2,%eax
mov    $0x1,%ecx
cmovae %eax,%ecx
movslq %ecx,%rax
mov    %rax,0x20(%rsp)
mov    $0x100000,%ebp
xor    %esi,%esi
mov    0x2d56(%rip),%r13
mov    %r15,%r14
jmp    12cb <main+0xfb>
mov    0x2d52(%rip),%rax
mov    (%rax),%rcx
lea    0xd70(%rip),%rdi
mov    $0x3a,%esi
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    $0x1,%eax
jmp    14d5 <main+0x305>
add    %rax,%r15
mov    (%r12),%edx
mov    %r15,%rdi
mov    $0x10000,%esi
call   1070 <fgets@plt>
test   %rax,%rax
mov    0x8(%rsp),%rsi
je     14be <main+0x2ee>
mov    %rbp,0x18(%rsp)
mov    %rsi,%rbp
jmp    1318 <main+0x148>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %rax,%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <dump@plt>
mov    (%r12),%edx
mov    %r14,%rdi
mov    $0x10000,%esi
call   1070 <fgets@plt>
mov    %r14,%r15
mov    $0x0,%ebp
test   %rax,%rax
je     14cb <main+0x2fb>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
mov    %rbx,%rdi
call   10b0 <fflush@plt>
mov    %r15,%rdi
lea    0xd4f(%rip),%rsi
call   10f0 <strstr@plt>
test   %rax,%rax
jne    1410 <main+0x240>
mov    %r15,%rdi
lea    0xd47(%rip),%rsi
call   10f0 <strstr@plt>
test   %rax,%rax
jne    1410 <main+0x240>
mov    %r15,%rdi
lea    0xd3d(%rip),%rsi
call   10f0 <strstr@plt>
test   %rax,%rax
jne    1410 <main+0x240>
mov    %r15,%rdi
lea    0xd3a(%rip),%rsi
call   10f0 <strstr@plt>
test   %rax,%rax
jne    12e0 <main+0x110>
mov    %r15,%rdi
lea    0xd40(%rip),%rsi
call   10f0 <strstr@plt>
test   %rax,%rax
je     1431 <main+0x261>
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %rax,%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <dump@plt>
cmpl   $0x0,0x10(%rsp)
je     13f3 <main+0x223>
mov    0x20(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12),%edx
mov    %r14,%rdi
mov    $0x10000,%esi
call   1070 <fgets@plt>
mov    0x0(%r13),%rsi
mov    %r14,%rdi
call   1050 <fputs@plt>
add    $0xffffffffffffffff,%rbp
jne    13d0 <main+0x200>
mov    0x0(%r13),%rdi
call   10b0 <fflush@plt>
jmp    12f6 <main+0x126>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x2bc1(%rip),%rax
mov    (%rax),%rsi
mov    %r15,%rdi
call   1050 <fputs@plt>
mov    0x2baf(%rip),%rax
mov    (%rax),%rdi
call   10b0 <fflush@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    (%rax,%rbp,1),%rdx
lea    (%rax,%rbp,1),%rcx
add    $0x10000,%rcx
mov    0x18(%rsp),%rbp
cmp    %rbp,%rcx
mov    %rdx,0x8(%rsp)
jb     12a9 <main+0xd9>
add    $0x100000,%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
call   10c0 <realloc@plt>
test   %rax,%rax
je     14e4 <main+0x314>
mov    %rax,%r14
mov    %rax,%r15
add    0x8(%rsp),%r15
jmp    12ac <main+0xdc>
mov    0x2b4f(%rip),%rax
mov    (%rax),%rdi
mov    0x10(%rbp),%rdx
lea    0xba6(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%eax
jmp    14d5 <main+0x305>
mov    0x2b2e(%rip),%rax
mov    (%rax),%rcx
lea    0xbaf(%rip),%rdi
mov    $0x20,%esi
jmp    1295 <main+0xc5>
test   %rsi,%rsi
je     14cb <main+0x2fb>
mov    %r14,%rdi
call   1060 <dump@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2aed(%rip),%rax
mov    (%rax),%rcx
lea    0xbe5(%rip),%rdi
mov    $0x23,%esi
jmp    1295 <main+0xc5>

LLVM IR (-O0):
@.str = [59 x i8] c"Expecting number of atoms and log filename as parameters.\0A\00"
@stderr = global i32* null
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [38 x i8] c"Cannot open log file %s for writing.\0A\00"
@.str.3 = [33 x i8] c"Buffer memory allocation error!\0A\00"
@stdin = global i32 0
@.str.4 = [16 x i8] c" total energy\00"
@.str.5 = [14 x i8] c" stopping\00"
@.str.6 = [21 x i8] c" convergence NOT\00"
@.str.7 = [30 x i8] c" Writing output data file\00"
@.str.8 = [5 x i8] c"!ASE\00"
@stdout = global i32* null
@.str.9 = [36 x i8] c"Buffer memory re-allocation error!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 1048576, i64* %6
store i64 1048576, i64* %7
store i64 0, i64* %8
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32*, i32** @stderr
%18 = call i32 @fputs(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i32* %17)
store i32 1, i32* %3
br label %159
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strtol(i8* %22, i32* null, i32 10)
%24 = mul nsw i32 %23, 2
%25 = sext i32 %24 to i64
store i64 %25, i64* %10
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %13
%30 = load i32*, i32** %13
%31 = icmp ne i32* %30, null
br i1 %31, label %38, label %32
32: ; preds = %19
%33 = load i32*, i32** @stderr
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32 @fprintf(i32* %33, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %36)
store i32 1, i32* %3
br label %159
38: ; preds = %19
%39 = call i64 @malloc(i32 1048576)
%40 = inttoptr i64 %39 to i8*
store i8* %40, i8** %11
%41 = load i8*, i8** %11
%42 = icmp ne i8* %41, null
br i1 %42, label %46, label %43
43: ; preds = %38
%44 = load i32*, i32** @stderr
%45 = call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32* %44)
store i32 1, i32* %3
br label %159
46: ; preds = %38
%47 = load i8*, i8** %11
store i8* %47, i8** %12
br label %48
48: ; preds = %148, %114, %80, %46
%49 = load i8*, i8** %12
%50 = load i32, i32* @stdin
%51 = call i64 @fgets(i8* %49, i32 65536, i32 %50)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %149
53: ; preds = %48
%54 = load i8*, i8** %12
%55 = load i32*, i32** %13
%56 = call i32 @fputs(i8* %54, i32* %55)
%57 = load i32*, i32** %13
%58 = call i32 @fflush(i32* %57)
%59 = load i8*, i8** %12
%60 = call i64 @strstr(i8* %59, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%61 = icmp ne i64 %60, 0
br i1 %61, label %70, label %62
62: ; preds = %53
%63 = load i8*, i8** %12
%64 = call i64 @strstr(i8* %63, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%65 = icmp ne i64 %64, 0
br i1 %65, label %70, label %66
66: ; preds = %62
%67 = load i8*, i8** %12
%68 = call i64 @strstr(i8* %67, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %76
70: ; preds = %66, %62, %53
%71 = load i8*, i8** %12
%72 = load i32*, i32** @stderr
%73 = call i32 @fputs(i8* %71, i32* %72)
%74 = load i32*, i32** @stderr
%75 = call i32 @fflush(i32* %74)
br label %119
76: ; preds = %66
%77 = load i8*, i8** %12
%78 = call i64 @strstr(i8* %77, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %88
80: ; preds = %76
%81 = load i8*, i8** %11
%82 = load i64, i64* %8
%83 = load i8*, i8** %12
%84 = call i64 @strlen(i8* %83)
%85 = add i64 %82, %84
%86 = call i32 @dump(i8* %81, i64 %85)
%87 = load i8*, i8** %11
store i8* %87, i8** %12
store i64 0, i64* %8
br label %48
88: ; preds = %76
%89 = load i8*, i8** %12
%90 = call i64 @strstr(i8* %89, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %117
92: ; preds = %88
%93 = load i8*, i8** %11
%94 = load i64, i64* %8
%95 = load i8*, i8** %12
%96 = call i64 @strlen(i8* %95)
%97 = add i64 %94, %96
%98 = call i32 @dump(i8* %93, i64 %97)
%99 = load i8*, i8** %11
store i8* %99, i8** %12
store i64 0, i64* %8
store i64 0, i64* %9
br label %100
100: ; preds = %111, %92
%101 = load i64, i64* %9
%102 = load i64, i64* %10
%103 = icmp ult i64 %101, %102
br i1 %103, label %104, label %114
104: ; preds = %100
%105 = load i8*, i8** %11
%106 = load i32, i32* @stdin
%107 = call i64 @fgets(i8* %105, i32 65536, i32 %106)
%108 = load i8*, i8** %11
%109 = load i32*, i32** @stdout
%110 = call i32 @fputs(i8* %108, i32* %109)
br label %111
111: ; preds = %104
%112 = load i64, i64* %9
%113 = add i64 %112, 1
store i64 %113, i64* %9
br label %100
114: ; preds = %100
%115 = load i32*, i32** @stdout
%116 = call i32 @fflush(i32* %115)
br label %48
117: ; preds = %88
br label %118
118: ; preds = %117
br label %119
119: ; preds = %118, %70
%120 = load i8*, i8** %12
%121 = call i64 @strlen(i8* %120)
store i64 %121, i64* %9
%122 = load i64, i64* %9
%123 = load i8*, i8** %12
%124 = getelementptr inbounds i8, i8* %123, i64 %122
store i8* %124, i8** %12
%125 = load i64, i64* %9
%126 = load i64, i64* %8
%127 = add i64 %126, %125
store i64 %127, i64* %8
%128 = load i64, i64* %8
%129 = add i64 %128, 65536
%130 = load i64, i64* %7
%131 = icmp uge i64 %129, %130
br i1 %131, label %132, label %148
132: ; preds = %119
%133 = load i64, i64* %7
%134 = add i64 %133, 1048576
store i64 %134, i64* %7
%135 = load i8*, i8** %11
%136 = load i64, i64* %7
%137 = call i64 @realloc(i8* %135, i64 %136)
%138 = inttoptr i64 %137 to i8*
store i8* %138, i8** %11
%139 = load i8*, i8** %11
%140 = icmp ne i8* %139, null
br i1 %140, label %144, label %141
141: ; preds = %132
%142 = load i32*, i32** @stderr
%143 = call i32 @fputs(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0), i32* %142)
store i32 1, i32* %3
br label %159
144: ; preds = %132
%145 = load i8*, i8** %11
%146 = load i64, i64* %8
%147 = getelementptr inbounds i8, i8* %145, i64 %146
store i8* %147, i8** %12
br label %148
148: ; preds = %144, %119
br label %48
149: ; preds = %48
%150 = load i64, i64* %8
%151 = icmp ugt i64 %150, 0
br i1 %151, label %152, label %156
152: ; preds = %149
%153 = load i8*, i8** %11
%154 = load i64, i64* %8
%155 = call i32 @dump(i8* %153, i64 %154)
br label %156
156: ; preds = %152, %149
%157 = load i32*, i32** %13
%158 = call i32 @fclose(i32* %157)
store i32 0, i32* %3
br label %159
159: ; preds = %156, %141, %43, %32, %16
%160 = load i32, i32* %3
ret i32 %160
}

LLVM IR (-O2):
@.str = [59 x i8] c"Expecting number of atoms and log filename as parameters.\0A\00"
@stderr = global i32* null
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [38 x i8] c"Cannot open log file %s for writing.\0A\00"
@.str.3 = [33 x i8] c"Buffer memory allocation error!\0A\00"
@stdin = global i32 0
@.str.4 = [16 x i8] c" total energy\00"
@.str.5 = [14 x i8] c" stopping\00"
@.str.6 = [21 x i8] c" convergence NOT\00"
@.str.7 = [30 x i8] c" Writing output data file\00"
@.str.8 = [5 x i8] c"!ASE\00"
@stdout = global i32* null
@.str.9 = [36 x i8] c"Buffer memory re-allocation error!\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32*, i32** @stderr
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i64 58, i64 1, i32* %5)
br label %116
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strtol(i8* nocapture %9, i32* null, i32 10)
%11 = shl nsw i32 %10, 1
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %7
%17 = load i32*, i32** @stderr
%18 = load i8*, i8** %12
%19 = tail call i32 @fprintf(i32* %17, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %116
20: ; preds = %7
%21 = tail call i64 @malloc(i32 1048576)
%22 = inttoptr i64 %21 to i8*
%23 = icmp eq i64 %21, 0
br i1 %23, label %32, label %24
24: ; preds = %20
%25 = load i32, i32* @stdin
%26 = tail call i64 @fgets(i8* %22, i32 65536, i32 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %114, label %28
28: ; preds = %24
%29 = icmp eq i32 %10, 0
%30 = call i32 @llvm.umax.i32(i32 %11, i32 1)
%31 = sext i32 %30 to i64
br label %105
32: ; preds = %20
%33 = load i32*, i32** @stderr
%34 = tail call i64 @fwrite(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i64 32, i64 1, i32* %33)
br label %116
35: ; preds = %105, %60
%36 = phi i8* [ %106, %105 ], [ %107, %60 ]
%37 = phi i64 [ %109, %105 ], [ 0, %60 ]
%38 = tail call i32 @fputs(i8* %36, i32* %14)
%39 = tail call i32 @fflush(i32* %14)
%40 = tail call i64 @strstr(i8* %36, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %35
%43 = tail call i64 @strstr(i8* %36, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = tail call i64 @strstr(i8* %36, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %53, label %48
48: ; preds = %45, %42, %35
%49 = load i32*, i32** @stderr
%50 = tail call i32 @fputs(i8* %36, i32* %49)
%51 = load i32*, i32** @stderr
%52 = tail call i32 @fflush(i32* %51)
br label %82
53: ; preds = %45
%54 = tail call i64 @strstr(i8* %36, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %64, label %56
56: ; preds = %53
%57 = tail call i64 @strlen(i8* dereferenceable(1) %36)
%58 = add i64 %57, %37
%59 = tail call i32 @dump(i8* %107, i64 %58)
br label %60
60: ; preds = %56, %79
%61 = load i32, i32* @stdin
%62 = tail call i64 @fgets(i8* %107, i32 65536, i32 %61)
%63 = icmp eq i64 %62, 0
br i1 %63, label %114, label %35
64: ; preds = %53
%65 = tail call i64 @strstr(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %82, label %67
67: ; preds = %64
%68 = tail call i64 @strlen(i8* dereferenceable(1) %36)
%69 = add i64 %68, %37
%70 = tail call i32 @dump(i8* %107, i64 %69)
br i1 %29, label %79, label %71
71: ; preds = %67, %71
%72 = phi i64 [ %77, %71 ], [ 0, %67 ]
%73 = load i32, i32* @stdin
%74 = tail call i64 @fgets(i8* %107, i32 65536, i32 %73)
%75 = load i32*, i32** @stdout
%76 = tail call i32 @fputs(i8* %107, i32* %75)
%77 = add nuw i64 %72, 1
%78 = icmp eq i64 %77, %31
br i1 %78, label %79, label %71
79: ; preds = %71, %67
%80 = load i32*, i32** @stdout
%81 = tail call i32 @fflush(i32* %80)
br label %60
82: ; preds = %64, %48
%83 = tail call i64 @strlen(i8* dereferenceable(1) %36)
%84 = getelementptr inbounds i8, i8* %36, i64 %83
%85 = add i64 %83, %37
%86 = add i64 %85, 65536
%87 = icmp ult i64 %86, %108
br i1 %87, label %98, label %88
88: ; preds = %82
%89 = add i64 %108, 1048576
%90 = tail call i64 @realloc(i8* %107, i64 %89)
%91 = inttoptr i64 %90 to i8*
%92 = icmp eq i64 %90, 0
br i1 %92, label %93, label %96
93: ; preds = %88
%94 = load i32*, i32** @stderr
%95 = tail call i64 @fwrite(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0), i64 35, i64 1, i32* %94)
br label %116
96: ; preds = %88
%97 = getelementptr inbounds i8, i8* %91, i64 %85
br label %98
98: ; preds = %96, %82
%99 = phi i64 [ %89, %96 ], [ %108, %82 ]
%100 = phi i8* [ %91, %96 ], [ %107, %82 ]
%101 = phi i8* [ %97, %96 ], [ %84, %82 ]
%102 = load i32, i32* @stdin
%103 = tail call i64 @fgets(i8* %101, i32 65536, i32 %102)
%104 = icmp eq i64 %103, 0
br i1 %104, label %110, label %105
105: ; preds = %28, %98
%106 = phi i8* [ %22, %28 ], [ %101, %98 ]
%107 = phi i8* [ %22, %28 ], [ %100, %98 ]
%108 = phi i64 [ 1048576, %28 ], [ %99, %98 ]
%109 = phi i64 [ 0, %28 ], [ %85, %98 ]
br label %35
110: ; preds = %98
%111 = icmp eq i64 %85, 0
br i1 %111, label %114, label %112
112: ; preds = %110
%113 = tail call i32 @dump(i8* %100, i64 %85)
br label %114
114: ; preds = %60, %24, %112, %110
%115 = tail call i32 @fclose(i32* %14)
br label %116
116: ; preds = %114, %93, %32, %16, %4
%117 = phi i32 [ 1, %4 ], [ 1, %93 ], [ 0, %114 ], [ 1, %32 ], [ 1, %16 ]
ret i32 %117
}