// File: /workspace/github_c_makefile_star2_O2/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), %r15
xorl %r12d, %r12d
pushq $0x1
popq %r14
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r14d, %r8d
callq 0x1170
movq %rax, 0x2d5f(%rip)      # 0x40e0
movq %rax, %rdi
callq 0x1110
movq %rax, 0x2d58(%rip)      # 0x40e8
movq %rax, %rdi
callq 0x1150
movq 0x2d49(%rip), %rdi      # 0x40e8
leaq -0xee(%rip), %rdx       # 0x12b8
leaq 0xcaf(%rip), %rcx       # 0x205c
movq %rcx, %rsi
xorl %r8d, %r8d
callq 0x1030
movq 0x2d29(%rip), %rdi      # 0x40e8
leaq 0xc9b(%rip), %rsi       # 0x2061
leaq -0x151(%rip), %rdx      # 0x127c
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x1030
movq 0x2d0a(%rip), %rdi      # 0x40e8
callq 0x10d0
movq %rax, 0x2d06(%rip)      # 0x40f0
movq 0x2cf7(%rip), %rdi      # 0x40e8
leaq 0xc72(%rip), %rsi       # 0x206a
movq %r15, %rdx
movl %r14d, %ecx
callq 0x10f0
movq 0x2cde(%rip), %rdi      # 0x40e8
leaq 0xc5f(%rip), %r15       # 0x2070
leaq 0xc79(%rip), %rdx       # 0x2091
movq %r15, %rsi
movl %r14d, %ecx
callq 0x10f0
testl %ebp, %ebp
movl $0x0, %r13d
cmovgl %ebp, %r13d
pushq $0x6
popq %r14
cmpq %r12, %r13
je 0x1453
movq 0x2ca9(%rip), %rdi      # 0x40e8
movq (%rbx,%r12,8), %rdx
movq %r15, %rsi
movl %r14d, %ecx
callq 0x10f0
incq %r12
jmp 0x1433
leaq 0xc2f(%rip), %rsi       # 0x2089
movq %rsp, %rbx
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1130
movq 0x2c78(%rip), %rdi      # 0x40e8
leaq 0xbfe(%rip), %rsi       # 0x2075
pushq $0x1
popq %rcx
movq %rbx, %rdx
callq 0x10f0
movb $0x1, %r13b
movq 0x2b54(%rip), %rbp      # 0x3fe0
movq 0x2b45(%rip), %r15      # 0x3fd8
leaq 0xbe0(%rip), %r14       # 0x207a
leaq 0xbeb(%rip), %r12       # 0x208c
movq (%rbp), %rdi
callq 0x10b0
testb $0x1, %r13b
je 0x14c3
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 0x14e7
testb $0x1, %r13b
jne 0x15b9
movb $0x0, (%rsp)
movq 0x2bfa(%rip), %rdi      # 0x40e8
movq 0x2bfb(%rip), %rsi      # 0x40f0
movq %rbx, %rdx
callq 0x1100
testq %rax, %rax
setne %r13b
je 0x14a1
movq 0x2bdb(%rip), %rdi      # 0x40e8
movq %rax, %rsi
xorl %edx, %edx
callq 0x1070
cmpl $0x1, %eax
je 0x1543
testl %eax, %eax
jne 0x1553
movq 0x2bc1(%rip), %rax      # 0x40e8
movq (%rax), %rdi
cmpb $0x0, (%rdi)
je 0x1534
callq 0x1050
cmpl $0x0, 0x2b9d(%rip)      # 0x40d8
je 0x14a1
jmp 0x158e
leaq 0xb33(%rip), %rdi       # 0x207d
xorl %eax, %eax
callq 0x1080
jmp 0x1563
leaq 0xb29(%rip), %rdi       # 0x2083
movl %eax, %esi
xorl %eax, %eax
callq 0x1080
movq 0x2b7e(%rip), %rax      # 0x40e8
movq (%rax), %rsi
cmpb $0x0, (%rsi)
je 0x1581
movq %r12, %rdi
xorl %eax, %eax
callq 0x1080
jmp 0x14a1
pushq $0xa
popq %rdi
callq 0x1040
jmp 0x14a1
movq 0x2b53(%rip), %rdi      # 0x40e8
movq 0x2b54(%rip), %rsi      # 0x40f0
callq 0x1160
movq 0x2b40(%rip), %rdi      # 0x40e8
callq 0x10e0
movq 0x2b2c(%rip), %rdi      # 0x40e0
callq 0x1060
xorl %edi, %edi
callq 0x1140