// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x420, %rsp            # imm = 0x420
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x418(%rbp)
xorl %ecx, %ecx
movl $0x1, %r8d
movl %ecx, %edi
movl %ecx, %esi
movl %ecx, %edx
callq 0x1150
movq %rax, 0x2cff(%rip)      # 0x40d0
movq 0x2cf8(%rip), %rdi      # 0x40d0
callq 0x10f0
movq %rax, 0x2cf4(%rip)      # 0x40d8
movq 0x2ced(%rip), %rdi      # 0x40d8
callq 0x1130
movq 0x2ce1(%rip), %rdi      # 0x40d8
leaq 0xc5e(%rip), %rcx       # 0x205c
leaq -0x135(%rip), %rdx      # 0x12d0
xorl %eax, %eax
movl %eax, %r8d
movq %rcx, %rsi
callq 0x1030
movq 0x2cbf(%rip), %rdi      # 0x40d8
leaq 0xc41(%rip), %rsi       # 0x2061
leaq -0x1c7(%rip), %rdx      # 0x1260
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rcx
callq 0x1030
movq 0x2c9d(%rip), %rdi      # 0x40d8
callq 0x10b0
movq %rax, 0x2c99(%rip)      # 0x40e0
movq 0x2c8a(%rip), %rdi      # 0x40d8
movq -0x418(%rbp), %rdx
leaq 0xc0e(%rip), %rsi       # 0x206a
movl $0x1, %ecx
callq 0x10d0
movq 0x2c6b(%rip), %rdi      # 0x40d8
leaq 0xbfc(%rip), %rsi       # 0x2070
leaq 0xc16(%rip), %rdx       # 0x2091
movl $0x1, %ecx
callq 0x10d0
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x14c3
movq 0x2c3d(%rip), %rdi      # 0x40d8
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0xbc2(%rip), %rsi       # 0x2070
movl $0x6, %ecx
callq 0x10d0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x148c
leaq -0x400(%rbp), %rdi
movl -0x8(%rbp), %edx
leaq 0xbb5(%rip), %rsi       # 0x2089
movb $0x0, %al
callq 0x1110
movq 0x2bf6(%rip), %rdi      # 0x40d8
leaq -0x400(%rbp), %rdx
leaq 0xb85(%rip), %rsi       # 0x2075
movl $0x1, %ecx
callq 0x10d0
movl $0x0, -0x410(%rbp)
movq 0x2ad5(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
callq 0x1090
cmpl $0x0, -0x410(%rbp)
jne 0x1541
movq 0x2ab5(%rip), %rax      # 0x3fd8
movq (%rax), %rsi
leaq 0xb4d(%rip), %rdi       # 0x207a
callq 0x1070
movq 0x2a9f(%rip), %rax      # 0x3fd8
movq (%rax), %rdi
callq 0x10a0
leaq -0x400(%rbp), %rdi
movq 0x2a91(%rip), %rax      # 0x3fe0
movq (%rax), %rdx
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1080
cmpq $0x0, %rax
jne 0x1579
cmpl $0x0, -0x410(%rbp)
jne 0x1572
xorl %edi, %edi
callq 0x1120
movb $0x0, -0x400(%rbp)
movq 0x2b58(%rip), %rdi      # 0x40d8
movq 0x2b59(%rip), %rsi      # 0x40e0
leaq -0x400(%rbp), %rdx
callq 0x10e0
movq %rax, -0x408(%rbp)
cmpq $0x0, -0x408(%rbp)
jne 0x15b3
movl $0x1, -0x410(%rbp)
jmp 0x1504
movl $0x0, -0x410(%rbp)
movq 0x2b14(%rip), %rdi      # 0x40d8
movq -0x408(%rbp), %rsi
xorl %edx, %edx
callq 0x1050
movl %eax, -0x40c(%rbp)
cmpl $0x0, -0x40c(%rbp)
jne 0x1648
movq 0x2af0(%rip), %rax      # 0x40d8
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x160b
movq 0x2ade(%rip), %rax      # 0x40d8
movq (%rax), %rsi
leaq 0xa8a(%rip), %rdi       # 0x208e
movb $0x0, %al
callq 0x1060
cmpl $0x0, 0x2ab6(%rip)      # 0x40c8
je 0x1646
movq 0x2abd(%rip), %rdi      # 0x40d8
movq 0x2abe(%rip), %rsi      # 0x40e0
callq 0x1140
movq 0x2aaa(%rip), %rdi      # 0x40d8
callq 0x10c0
movq 0x2a96(%rip), %rdi      # 0x40d0
callq 0x1040
xorl %edi, %edi
callq 0x1120
jmp 0x16b1
cmpl $0x1, -0x40c(%rbp)
jne 0x1661
leaq 0xa25(%rip), %rdi       # 0x207d
movb $0x0, %al
callq 0x1060
jmp 0x1675
movl -0x40c(%rbp), %esi
leaq 0xa15(%rip), %rdi       # 0x2083
movb $0x0, %al
callq 0x1060
movq 0x2a5c(%rip), %rax      # 0x40d8
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x16a1
movq 0x2a4a(%rip), %rax      # 0x40d8
movq (%rax), %rsi
leaq 0x9f4(%rip), %rdi       # 0x208c
movb $0x0, %al
callq 0x1060
jmp 0x16af
leaq 0x9e8(%rip), %rdi       # 0x2090
movb $0x0, %al
callq 0x1060
jmp 0x16b1
jmp 0x1504