#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 */
struct Molecule_t {
  int dummy;
};
struct GTOBasis_t {
  int dummy;
};
struct GTOBasisSet_t {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ cleanGTOBasis(struct GTOBasis_t *, int);
int /*<<< orphan*/ cleanMolecule(struct Molecule_t *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
struct GTOBasis_t *genBasis(struct Molecule_t *, int *, int,
                            struct GTOBasisSet_t *);
int /*<<< orphan*/ printGTOBasis(int /*<<< orphan*/, int, struct GTOBasis_t *);
int /*<<< orphan*/ print_BasisSet(int, struct GTOBasisSet_t *);
int /*<<< orphan*/ printf(char *, char *);
struct Molecule_t *readMolecule_XYZ(int /*<<< orphan*/ *);
struct GTOBasisSet_t *read_GAMESS_BasisSet(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  struct Molecule_t *mol;
  struct GTOBasis_t *bas;
  int nBasis;
  struct GTOBasisSet_t *dbSet;
  int dbSetItem;
  FILE *dbSetFd;
  FILE *xyzFd;
  if (argc != 3) {
    printf("usage: %s <Basis Set File>  <XYZ File>\n"
           "<Basis Set File> - Basis set in GAMESS format\n"
           "<XYZ File>       - Cartesian coordinate of atoms\n",
           argv[0]);
    exit(-1);
  }
  dbSetFd = fopen(argv[1], "r");
  if (dbSetFd == NULL) {
    printf("Cannot open file %s\n", argv[1]);
    exit(-1);
  }
  xyzFd = fopen(argv[2], "r");
  if (xyzFd == NULL) {
    printf("Cannot open file %s\n", argv[2]);
    exit(-1);
  }
  mol = readMolecule_XYZ(xyzFd);
  dbSet = read_GAMESS_BasisSet(dbSetFd, argv[2], &dbSetItem);
  print_BasisSet(dbSetItem, dbSet);
  bas = genBasis(mol, &nBasis, dbSetItem, dbSet);
  printGTOBasis(stdout, nBasis, bas);
  cleanGTOBasis(bas, nBasis);
  cleanMolecule(mol);
  fclose(dbSetFd);
  fclose(xyzFd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x4(%rbp)
je     11e6 <main+0x36>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe29(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe92(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1227 <main+0x77>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe71(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe51(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1268 <main+0xb8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x48(%rbp),%rdi
call   1070 <readMolecule_XYZ@plt>
mov    %rax,-0x18(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x34(%rbp),%rdx
call   1030 <read_GAMESS_BasisSet@plt>
mov    %rax,-0x30(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   10d0 <print_BasisSet@plt>
mov    -0x18(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%rcx
lea    -0x24(%rbp),%rsi
call   1060 <genBasis@plt>
mov    %rax,-0x20(%rbp)
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1090 <printGTOBasis@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1080 <cleanGTOBasis@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <cleanMolecule@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1281 <main+0xd1>
mov    0x8(%rbx),%rdi
lea    0xeb8(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     128d <main+0xdd>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe9c(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1293 <main+0xe3>
mov    %rax,%r12
mov    %rax,%rdi
call   1070 <readMolecule_XYZ@plt>
mov    %rax,%r15
mov    0x10(%rbx),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
call   1030 <read_GAMESS_BasisSet@plt>
mov    %rax,%rbx
mov    (%rsp),%edi
mov    %rax,%rsi
call   10d0 <print_BasisSet@plt>
mov    (%rsp),%edx
lea    0x4(%rsp),%rsi
mov    %r15,%rdi
mov    %rbx,%rcx
call   1060 <genBasis@plt>
mov    %rax,%rbx
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
mov    0x4(%rsp),%esi
mov    %rbx,%rdx
call   1090 <printGTOBasis@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1080 <cleanGTOBasis@plt>
mov    %r15,%rdi
call   10a0 <cleanMolecule@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    (%rbx),%rsi
lea    0xd75(%rip),%rdi
jmp    129e <main+0xee>
mov    0x8(%rbx),%rsi
jmp    1297 <main+0xe7>
mov    0x10(%rbx),%rsi
lea    0xdeb(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.Molecule_t = type { i32 }
%struct.GTOBasis_t = type { i32 }
%struct.GTOBasisSet_t = type { i32 }
@.str = [135 x i8] c"usage: %s <Basis Set File> <XYZ File>\0A<Basis Set File> - Basis set in GAMESS format\0A<XYZ File> - Cartesian coordinate of atoms\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"Cannot open file %s\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca %struct.Molecule_t*
%6 = alloca %struct.GTOBasis_t*
%7 = alloca i32
%8 = alloca %struct.GTOBasisSet_t*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i8**, i8*** %4
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @printf(i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %4
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %10
%25 = load i32*, i32** %10
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %33
27: ; preds = %20
%28 = load i8**, i8*** %4
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = call i32 @exit(i32 -1)
unreachable
33: ; preds = %20
%34 = load i8**, i8*** %4
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %37, i32** %11
%38 = load i32*, i32** %11
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %46
40: ; preds = %33
%41 = load i8**, i8*** %4
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %43)
%45 = call i32 @exit(i32 -1)
unreachable
46: ; preds = %33
%47 = load i32*, i32** %11
%48 = call %struct.Molecule_t* @readMolecule_XYZ(i32* %47)
store %struct.Molecule_t* %48, %struct.Molecule_t** %5
%49 = load i32*, i32** %10
%50 = load i8**, i8*** %4
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = call %struct.GTOBasisSet_t* @read_GAMESS_BasisSet(i32* %49, i8* %52, i32* %9)
store %struct.GTOBasisSet_t* %53, %struct.GTOBasisSet_t** %8
%54 = load i32, i32* %9
%55 = load %struct.GTOBasisSet_t*, %struct.GTOBasisSet_t** %8
%56 = call i32 @print_BasisSet(i32 %54, %struct.GTOBasisSet_t* %55)
%57 = load %struct.Molecule_t*, %struct.Molecule_t** %5
%58 = load i32, i32* %9
%59 = load %struct.GTOBasisSet_t*, %struct.GTOBasisSet_t** %8
%60 = call %struct.GTOBasis_t* @genBasis(%struct.Molecule_t* %57, i32* %7, i32 %58, %struct.GTOBasisSet_t* %59)
store %struct.GTOBasis_t* %60, %struct.GTOBasis_t** %6
%61 = load i32, i32* @stdout
%62 = load i32, i32* %7
%63 = load %struct.GTOBasis_t*, %struct.GTOBasis_t** %6
%64 = call i32 @printGTOBasis(i32 %61, i32 %62, %struct.GTOBasis_t* %63)
%65 = load %struct.GTOBasis_t*, %struct.GTOBasis_t** %6
%66 = load i32, i32* %7
%67 = call i32 @cleanGTOBasis(%struct.GTOBasis_t* %65, i32 %66)
%68 = load %struct.Molecule_t*, %struct.Molecule_t** %5
%69 = call i32 @cleanMolecule(%struct.Molecule_t* %68)
%70 = load i32*, i32** %10
%71 = call i32 @fclose(i32* %70)
%72 = load i32*, i32** %11
%73 = call i32 @fclose(i32* %72)
ret i32 0
}

LLVM IR (-O2):
%struct.Molecule_t = type { i32 }
%struct.GTOBasisSet_t = type { i32 }
%struct.GTOBasis_t = type { i32 }
@.str = [135 x i8] c"usage: %s <Basis Set File> <XYZ File>\0A<Basis Set File> - Basis set in GAMESS format\0A<XYZ File> - Cartesian coordinate of atoms\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"Cannot open file %s\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = icmp eq i32 %0, 3
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i8*, i8** %13
%19 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = tail call i32 @exit(i32 -1)
unreachable
21: ; preds = %12
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = load i8*, i8** %22
%28 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = tail call i32 @exit(i32 -1)
unreachable
30: ; preds = %21
%31 = tail call %struct.Molecule_t* @readMolecule_XYZ(i32* %24)
%32 = load i8*, i8** %22
%33 = call %struct.GTOBasisSet_t* @read_GAMESS_BasisSet(i32* %15, i8* %32, i32* %4)
%34 = load i32, i32* %4
%35 = call i32 @print_BasisSet(i32 %34, %struct.GTOBasisSet_t* %33)
%36 = load i32, i32* %4
%37 = call %struct.GTOBasis_t* @genBasis(%struct.Molecule_t* %31, i32* %3, i32 %36, %struct.GTOBasisSet_t* %33)
%38 = load i32, i32* @stdout
%39 = load i32, i32* %3
%40 = call i32 @printGTOBasis(i32 %38, i32 %39, %struct.GTOBasis_t* %37)
%41 = load i32, i32* %3
%42 = call i32 @cleanGTOBasis(%struct.GTOBasis_t* %37, i32 %41)
%43 = call i32 @cleanMolecule(%struct.Molecule_t* %31)
%44 = call i32 @fclose(i32* %15)
%45 = call i32 @fclose(i32* %24)
ret i32 0
}