#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 */

/* Variables and functions */
char *malloc(int);
char *mqc_GetMatrixFile(char *, char *);
int /*<<< orphan*/ mqc_Global_init();
int /*<<< orphan*/ mqc_error(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ setenv(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int main(int argc, char *argv[]) {
  char charBuf[2096];
  char *MatFileName;
  char *EnvName;
  char *NextEnvName;
  int i, j;
  if (argc - 1 < 2) {
    printf("Error in number of argments to this program.  Arguments should "
           "be:\n     - Full path to a Gaussian file\n         - This can "
           "either be a MatrixFile\n         - This can be a Gaussian input "
           "file\n     - The name of the binary for the program that \n       "
           "generates the MatrixFile, most likely \"g16\".  \n       The "
           "environment should be setup to run the program.\n");
    if (argc - 1 == 0) {
      mqc_error("No arguments to this program\n");
    } else {
      mqc_error("Only one argument to this program\n");
    }
  }
  mqc_Global_init();
  j = argc - 1;
  EnvName = malloc(1024);
  NextEnvName = malloc(1024);
  for (i = 1; i < j; i++) {
    MatFileName = mqc_GetMatrixFile(argv[i], argv[j]);
    if (i > 1) {
      sprintf(NextEnvName, "NxtMatFil%d", i - 1);
      if (setenv(NextEnvName, EnvName, 1) != 0) {
        sprintf(charBuf, "Not able to set env variable \"%s\" to \"%s\"\n",
                NextEnvName, EnvName);
        mqc_error(charBuf);
      }
    }
    sprintf(EnvName, "MatFil%d", i);
    if (setenv(EnvName, MatFileName, 1) != 0) {
      sprintf(charBuf, "Not able to set env variable \"%s\" to \"%s\"\n",
              EnvName, MatFileName);
    }
  }
  sprintf(NextEnvName, "NxtMatFil%d", j - 1);
  if (setenv(NextEnvName, "mqc_Done", 1) != 0) {
    sprintf(charBuf, "Not able to set env variable \"%s\" to \"mqc_Done\"\n",
            NextEnvName);
    mqc_error(charBuf);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cmp    $0x2,%eax
jge    11d5 <main+0x65>
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cmp    $0x0,%eax
jne    11c4 <main+0x54>
lea    0xfab(%rip),%rdi
call   1060 <mqc_error@plt>
jmp    11d0 <main+0x60>
lea    0xfb8(%rip),%rdi
call   1060 <mqc_error@plt>
jmp    11d5 <main+0x65>
mov    $0x0,%al
call   1050 <mqc_Global_init@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x860(%rbp)
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,-0x850(%rbp)
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,-0x858(%rbp)
movl   $0x1,-0x85c(%rbp)
mov    -0x85c(%rbp),%eax
cmp    -0x860(%rbp),%eax
jge    134a <main+0x1da>
mov    -0x10(%rbp),%rax
movslq -0x85c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
movslq -0x860(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1080 <mqc_GetMatrixFile@plt>
mov    %rax,-0x848(%rbp)
cmpl   $0x1,-0x85c(%rbp)
jle    12d1 <main+0x161>
mov    -0x858(%rbp),%rdi
mov    -0x85c(%rbp),%edx
sub    $0x1,%edx
lea    0xf32(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    -0x858(%rbp),%rdi
mov    -0x850(%rbp),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
cmp    $0x0,%rax
je     12cc <main+0x15c>
lea    -0x840(%rbp),%rdi
mov    -0x858(%rbp),%rdx
mov    -0x850(%rbp),%rcx
lea    0xef9(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x840(%rbp),%rdi
call   1060 <mqc_error@plt>
jmp    12d1 <main+0x161>
mov    -0x850(%rbp),%rdi
mov    -0x85c(%rbp),%edx
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    -0x850(%rbp),%rdi
mov    -0x848(%rbp),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
cmp    $0x0,%rax
je     1331 <main+0x1c1>
lea    -0x840(%rbp),%rdi
mov    -0x850(%rbp),%rdx
mov    -0x848(%rbp),%rcx
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    1336 <main+0x1c6>
mov    -0x85c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x85c(%rbp)
jmp    1214 <main+0xa4>
mov    -0x858(%rbp),%rdi
mov    -0x860(%rbp),%edx
sub    $0x1,%edx
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    -0x858(%rbp),%rdi
lea    0xe67(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
cmp    $0x0,%rax
je     13b2 <main+0x242>
lea    -0x840(%rbp),%rdi
mov    -0x858(%rbp),%rdx
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x840(%rbp),%rdi
call   1060 <mqc_error@plt>
mov    -0x4(%rbp),%eax
add    $0x860,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x858,%rsp
mov    %rsi,%r15
mov    %edi,%ebp
lea    -0x1(%rbp),%r14d
cmp    $0x2,%edi
jg     11b5 <main+0x45>
lea    0xf1c(%rip),%rdi
call   1030 <puts@plt>
test   %r14d,%r14d
lea    0xe5b(%rip),%rax
lea    0xe72(%rip),%rdi
cmove  %rax,%rdi
call   1060 <mqc_error@plt>
xor    %eax,%eax
call   1050 <mqc_Global_init@plt>
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,%r12
mov    %rbp,0x10(%rsp)
cmp    $0x3,%ebp
jl     1242 <main+0xd2>
mov    %r14d,%eax
mov    0x8(%r15),%rdi
mov    %rax,0x8(%rsp)
mov    (%r15,%rax,8),%rsi
call   1080 <mqc_GetMatrixFile@plt>
mov    %rax,%rbp
lea    0xe45(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
test   %rax,%rax
je     123c <main+0xcc>
lea    0xe23(%rip),%rsi
lea    0x20(%rsp),%rdi
mov    %rbx,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1090 <sprintf@plt>
cmp    $0x2,%r14d
jne    12a9 <main+0x139>
mov    0x10(%rsp),%rdx
add    $0xfffffffe,%edx
lea    0xdf0(%rip),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1090 <sprintf@plt>
lea    0xe16(%rip),%rsi
mov    %r12,%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
test   %rax,%rax
je     1295 <main+0x125>
lea    0xe06(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <mqc_error@plt>
xor    %eax,%eax
add    $0x858,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%rax
add    $0xfffffffffffffffe,%rax
mov    %rax,0x18(%rsp)
xor    %r13d,%r13d
jmp    12cf <main+0x15f>
nopl   0x0(%rax)
add    $0x1,%r13
cmp    %r13,0x18(%rsp)
je     1242 <main+0xd2>
mov    0x10(%r15,%r13,8),%rdi
mov    0x8(%rsp),%rax
mov    (%r15,%rax,8),%rsi
call   1080 <mqc_GetMatrixFile@plt>
mov    %rax,%rbp
lea    0x1(%r13),%edx
mov    %r12,%rdi
lea    0xd4e(%rip),%rsi
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
test   %rax,%rax
je     1333 <main+0x1c3>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
lea    0xd2f(%rip),%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %r14,%rdi
call   1060 <mqc_error@plt>
lea    0x2(%r13),%edx
mov    %rbx,%rdi
lea    0xd03(%rip),%rsi
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
test   %rax,%rax
je     12c0 <main+0x150>
lea    0x20(%rsp),%rdi
lea    0xce0(%rip),%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1090 <sprintf@plt>
jmp    12c0 <main+0x150>

LLVM IR (-O0):
@.str = [357 x i8] c"Error in number of argments to this program. Arguments should be:\0A - Full path to a Gaussian file\0A - This can either be a MatrixFile\0A - This can be a Gaussian input file\0A - The name of the binary for the program that \0A generates the MatrixFile, most likely \22g16\22. \0A The environment should be setup to run the program.\0A\00"
@.str.1 = [30 x i8] c"No arguments to this program\0A\00"
@.str.2 = [35 x i8] c"Only one argument to this program\0A\00"
@.str.3 = [12 x i8] c"NxtMatFil%d\00"
@.str.4 = [43 x i8] c"Not able to set env variable \22%s\22 to \22%s\22\0A\00"
@.str.5 = [9 x i8] c"MatFil%d\00"
@.str.6 = [9 x i8] c"mqc_Done\00"
@.str.7 = [49 x i8] c"Not able to set env variable \22%s\22 to \22mqc_Done\22\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2096 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = sub nsw i32 %12, 1
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %25
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([357 x i8], [357 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 1
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 @mqc_error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %24
22: ; preds = %15
%23 = call i32 @mqc_error(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
br label %25
25: ; preds = %24, %2
%26 = call i32 (...) @mqc_Global_init()
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
store i32 %28, i32* %11
%29 = call i8* @malloc(i32 1024)
store i8* %29, i8** %8
%30 = call i8* @malloc(i32 1024)
store i8* %30, i8** %9
store i32 1, i32* %10
br label %31
31: ; preds = %80, %25
%32 = load i32, i32* %10
%33 = load i32, i32* %11
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %83
35: ; preds = %31
%36 = load i8**, i8*** %5
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = load i8**, i8*** %5
%42 = load i32, i32* %11
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = call i8* @mqc_GetMatrixFile(i8* %40, i8* %45)
store i8* %46, i8** %7
%47 = load i32, i32* %10
%48 = icmp sgt i32 %47, 1
br i1 %48, label %49, label %66
49: ; preds = %35
%50 = load i8*, i8** %9
%51 = load i32, i32* %10
%52 = sub nsw i32 %51, 1
%53 = call i32 (i8*, i8*, ...) @sprintf(i8* %50, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %52)
%54 = load i8*, i8** %9
%55 = load i8*, i8** %8
%56 = call i64 @setenv(i8* %54, i8* %55, i32 1)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %65
58: ; preds = %49
%59 = getelementptr inbounds [2096 x i8], [2096 x i8]* %6, i64 0, i64 0
%60 = load i8*, i8** %9
%61 = load i8*, i8** %8
%62 = call i32 (i8*, i8*, ...) @sprintf(i8* %59, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %60, i8* %61)
%63 = getelementptr inbounds [2096 x i8], [2096 x i8]* %6, i64 0, i64 0
%64 = call i32 @mqc_error(i8* %63)
br label %65
65: ; preds = %58, %49
br label %66
66: ; preds = %65, %35
%67 = load i8*, i8** %8
%68 = load i32, i32* %10
%69 = call i32 (i8*, i8*, ...) @sprintf(i8* %67, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %68)
%70 = load i8*, i8** %8
%71 = load i8*, i8** %7
%72 = call i64 @setenv(i8* %70, i8* %71, i32 1)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %79
74: ; preds = %66
%75 = getelementptr inbounds [2096 x i8], [2096 x i8]* %6, i64 0, i64 0
%76 = load i8*, i8** %8
%77 = load i8*, i8** %7
%78 = call i32 (i8*, i8*, ...) @sprintf(i8* %75, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %76, i8* %77)
br label %79
79: ; preds = %74, %66
br label %80
80: ; preds = %79
%81 = load i32, i32* %10
%82 = add nsw i32 %81, 1
store i32 %82, i32* %10
br label %31
83: ; preds = %31
%84 = load i8*, i8** %9
%85 = load i32, i32* %11
%86 = sub nsw i32 %85, 1
%87 = call i32 (i8*, i8*, ...) @sprintf(i8* %84, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %86)
%88 = load i8*, i8** %9
%89 = call i64 @setenv(i8* %88, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 1)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %97
91: ; preds = %83
%92 = getelementptr inbounds [2096 x i8], [2096 x i8]* %6, i64 0, i64 0
%93 = load i8*, i8** %9
%94 = call i32 (i8*, i8*, ...) @sprintf(i8* %92, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i8* %93)
%95 = getelementptr inbounds [2096 x i8], [2096 x i8]* %6, i64 0, i64 0
%96 = call i32 @mqc_error(i8* %95)
br label %97
97: ; preds = %91, %83
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
@.str.1 = [30 x i8] c"No arguments to this program\0A\00"
@.str.2 = [35 x i8] c"Only one argument to this program\0A\00"
@.str.3 = [12 x i8] c"NxtMatFil%d\00"
@.str.4 = [43 x i8] c"Not able to set env variable \22%s\22 to \22%s\22\0A\00"
@.str.5 = [9 x i8] c"MatFil%d\00"
@.str.6 = [9 x i8] c"mqc_Done\00"
@.str.7 = [49 x i8] c"Not able to set env variable \22%s\22 to \22mqc_Done\22\0A\00"
@str = [356 x i8] c"Error in number of argments to this program. Arguments should be:\0A - Full path to a Gaussian file\0A - This can either be a MatrixFile\0A - This can be a Gaussian input file\0A - The name of the binary for the program that \0A generates the MatrixFile, most likely \22g16\22. \0A The environment should be setup to run the program.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2096 x i8]
%4 = getelementptr inbounds [2096 x i8], [2096 x i8]* %3, i64 0, i64 0
%5 = add i32 %0, -1
%6 = icmp slt i32 %0, 3
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([356 x i8], [356 x i8]* @str, i64 0, i64 0))
%9 = icmp eq i32 %5, 0
%10 = select i1 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0)
%11 = tail call i32 @mqc_error(i8* %10)
br label %12
12: ; preds = %7, %2
%13 = tail call i32 (...) @mqc_Global_init()
%14 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%15 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%16 = icmp sgt i32 %0, 2
br i1 %16, label %17, label %56
17: ; preds = %12
%18 = zext i32 %5 to i64
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = zext i32 %5 to i64
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = load i8*, i8** %19
%24 = call i8* @mqc_GetMatrixFile(i8* %22, i8* %23)
%25 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 1)
%26 = call i64 @setenv(i8* %14, i8* %24, i32 1)
%27 = icmp eq i64 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %17
%29 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %14, i8* %24)
br label %30
30: ; preds = %28, %17
%31 = icmp eq i32 %5, 2
br i1 %31, label %56, label %32
32: ; preds = %30, %53
%33 = phi i64 [ %54, %53 ], [ 2, %30 ]
%34 = getelementptr inbounds i8*, i8** %1, i64 %33
%35 = load i8*, i8** %34
%36 = load i8*, i8** %19
%37 = call i8* @mqc_GetMatrixFile(i8* %35, i8* %36)
%38 = trunc i64 %33 to i32
%39 = add i32 %38, -1
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = call i64 @setenv(i8* %15, i8* %14, i32 1)
%42 = icmp eq i64 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %32
%44 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %15, i8* %14)
%45 = call i32 @mqc_error(i8* %4)
br label %46
46: ; preds = %32, %43
%47 = trunc i64 %33 to i32
%48 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %47)
%49 = call i64 @setenv(i8* %14, i8* %37, i32 1)
%50 = icmp eq i64 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %46
%52 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %14, i8* %37)
br label %53
53: ; preds = %46, %51
%54 = add nuw nsw i64 %33, 1
%55 = icmp eq i64 %54, %20
br i1 %55, label %56, label %32
56: ; preds = %53, %30, %12
%57 = add nsw i32 %0, -2
%58 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %57)
%59 = call i64 @setenv(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 1)
%60 = icmp eq i64 %59, 0
br i1 %60, label %64, label %61
61: ; preds = %56
%62 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i8* %15)
%63 = call i32 @mqc_error(i8* %4)
br label %64
64: ; preds = %61, %56
ret i32 0
}