// File: /workspace/github_c_makefile_star2_O3/haxlang[P]hax/./haxsh.c
// Function: main
int
main(int argc, char **argv)
{
    int i;
    char line[1000], *cmd;
    int result, gotPartial;
    char *argv0 = argv[0];
#ifndef RHAXSH
    int ch;
    char *fileName = NULL;
#endif

    memoryp = Hax_CreateMemoryManagement(0, 0, 0, 0, 1);
    interp = Hax_CreateInterp(memoryp);
    Hax_InitMemory(interp);
#ifndef RHAXSH
    unixClientData = (ClientData) Hax_InitUnixCore(interp);
    Hax_EnvTraceProc(interp, unixClientData, writeEnv, unsetEnv, destroyEnv);
#endif
    Hax_CreateCommand(interp, (char *) "echo", cmdEcho, (ClientData) "echo",
	    (Hax_CmdDeleteProc *) NULL);
    Hax_CreateCommand(interp, (char *) "checkmem", cmdCheckmem, (ClientData) 0,
	    (Hax_CmdDeleteProc *) NULL);
    buffer = Hax_CreateCmdBuf(interp);

#ifndef RHAXSH
    while ((ch = getopt(argc, argv, "f:")) != -1) {
	switch (ch) {
	case 'f':
	    if (fileName != NULL) {
		usage();
	    }
	    fileName = optarg;
	    argv0 = fileName;
	    break;
	default:
	    usage();
	    /* NOTREACHED */
	}
    }

    argc -= optind;
    argv += optind;
#endif

    Hax_SetVar(interp, (char *) "argv0", argv0, HAX_GLOBAL_ONLY);
    Hax_SetVar(interp, (char *) "argv", "", HAX_GLOBAL_ONLY);
    for (i = 0; i < argc; i++) {
	Hax_SetVar(interp, (char *) "argv", argv[i], HAX_APPEND_VALUE | HAX_LIST_ELEMENT);
    }
    sprintf(line, "%d", argc);
    Hax_SetVar(interp, (char *) "argc", line, HAX_GLOBAL_ONLY);

#ifndef RHAXSH
    result = Hax_Eval(interp, NULL, initCmd, 0, (char **) NULL);
    if (result != HAX_OK) {
	printf("%s\n", interp->result);
	exit(1);
    }

    if (fileName != NULL) {
	Hax_EvalFile(interp, unixClientData, fileName);
	if (result != HAX_OK) {
	    printf("%s\n", interp->result);
	    exit(1);
	}
	exit(0);
    }
#endif

    gotPartial = 0;
    while (1) {
	clearerr(stdin);
	if (!gotPartial) {
	    fputs("% ", stdout);
	    fflush(stdout);
	}
	if (fgets(line, 1000, stdin) == NULL) {
	    if (!gotPartial) {
		exit(0);
	    }
	    line[0] = 0;
	}
	cmd = Hax_AssembleCmd(interp, buffer, line);
	if (cmd == NULL) {
	    gotPartial = 1;
	    continue;
	}

	gotPartial = 0;
	result = Hax_RecordAndEval(interp, cmd, 0);
	if (result == HAX_OK) {
	    if (*interp->result != 0) {
		printf("%s\n", interp->result);
	    }
	    if (quitFlag) {
		Hax_DeleteCmdBuf(interp, buffer);
		Hax_DeleteInterp(interp);
		Hax_DumpActiveMemory(memoryp);
		exit(0);
	    }
	} else {
	    if (result == HAX_ERROR) {
		printf("Error");
	    } else {
		printf("Error %d", result);
	    }
	    if (*interp->result != 0) {
		printf(": %s\n", interp->result);
	    } else {
		printf("\n");
	    }
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3e8, %rsp            # imm = 0x3E8
movq %rsi, %rbx
movl %edi, %ebp
movq (%rsi), %r14
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x1170
movq %rax, 0x2d4b(%rip)      # 0x40e0
movq %rax, %rdi
callq 0x1110
movq %rax, 0x2d44(%rip)      # 0x40e8
movq %rax, %rdi
callq 0x1150
movq 0x2d35(%rip), %rdi      # 0x40e8
leaq -0x100(%rip), %rdx      # 0x12ba
leaq 0xc9b(%rip), %rcx       # 0x205c
movq %rcx, %rsi
xorl %r8d, %r8d
callq 0x1030
movq 0x2d15(%rip), %rdi      # 0x40e8
leaq 0xc87(%rip), %rsi       # 0x2061
leaq -0x165(%rip), %rdx      # 0x127c
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x1030
movq 0x2cf6(%rip), %rdi      # 0x40e8
callq 0x10d0
movq %rax, 0x2cf2(%rip)      # 0x40f0
movq 0x2ce3(%rip), %rdi      # 0x40e8
leaq 0xc5e(%rip), %rsi       # 0x206a
movq %r14, %rdx
movl $0x1, %ecx
callq 0x10f0
movq 0x2cc8(%rip), %rdi      # 0x40e8
leaq 0xc49(%rip), %rsi       # 0x2070
leaq 0xc63(%rip), %rdx       # 0x2091
movl $0x1, %ecx
callq 0x10f0
testl %ebp, %ebp
jle 0x1469
movl %ebp, %r15d
xorl %r12d, %r12d
leaq 0xc27(%rip), %r14       # 0x2070
movq 0x2c98(%rip), %rdi      # 0x40e8
movq (%rbx,%r12,8), %rdx
movq %r14, %rsi
movl $0x6, %ecx
callq 0x10f0
incq %r12
cmpq %r12, %r15
jne 0x1449
leaq 0xc19(%rip), %rsi       # 0x2089
movq %rsp, %rbx
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1130
movq 0x2c62(%rip), %rdi      # 0x40e8
leaq 0xbe8(%rip), %rsi       # 0x2075
movq %rbx, %rdx
movl $0x1, %ecx
callq 0x10f0
movq 0x2b3f(%rip), %rbp      # 0x3fe0
movq 0x2b30(%rip), %r15      # 0x3fd8
leaq 0xbcb(%rip), %r14       # 0x207a
leaq 0xbd6(%rip), %r12       # 0x208c
leaq 0xbc6(%rip), %r13       # 0x2083
movq (%rbp), %rdi
callq 0x10b0
movq (%r15), %rsi
movq %r14, %rdi
callq 0x1090
movq (%r15), %rdi
callq 0x10c0
movq (%rbp), %rdx
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x10a0
testq %rax, %rax
jne 0x1517
jmp 0x15e3
movq (%rbp), %rdi
callq 0x10b0
movq (%rbp), %rdx
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x10a0
testq %rax, %rax
jne 0x1517
movb $0x0, (%rsp)
movq 0x2bca(%rip), %rdi      # 0x40e8
movq 0x2bcb(%rip), %rsi      # 0x40f0
movq %rbx, %rdx
callq 0x1100
testq %rax, %rax
je 0x14f4
movq 0x2baf(%rip), %rdi      # 0x40e8
movq %rax, %rsi
xorl %edx, %edx
callq 0x1070
cmpl $0x1, %eax
je 0x156f
testl %eax, %eax
jne 0x157f
movq 0x2b95(%rip), %rax      # 0x40e8
movq (%rax), %rdi
cmpb $0x0, (%rdi)
je 0x1560
callq 0x1050
cmpl $0x0, 0x2b71(%rip)      # 0x40d8
je 0x14bd
jmp 0x15b8
leaq 0xb07(%rip), %rdi       # 0x207d
xorl %eax, %eax
callq 0x1080
jmp 0x158b
movq %r13, %rdi
movl %eax, %esi
xorl %eax, %eax
callq 0x1080
movq 0x2b56(%rip), %rax      # 0x40e8
movq (%rax), %rsi
cmpb $0x0, (%rsi)
je 0x15a9
movq %r12, %rdi
xorl %eax, %eax
callq 0x1080
jmp 0x14bd
movl $0xa, %edi
callq 0x1040
jmp 0x14bd
movq 0x2b29(%rip), %rdi      # 0x40e8
movq 0x2b2a(%rip), %rsi      # 0x40f0
callq 0x1160
movq 0x2b16(%rip), %rdi      # 0x40e8
callq 0x10e0
movq 0x2b02(%rip), %rdi      # 0x40e0
callq 0x1060
xorl %edi, %edi
callq 0x1140