// File: /workspace/github_c_makefile_star2_O3/haxlang[P]hax/haxCmdAH.c
// Function: Hax_CaseCmd
int
Hax_CaseCmd(
    ClientData dummy,			/* Not used. */
    Hax_Interp *interp,			/* Current interpreter. */
    int argc,				/* Number of arguments. */
    char **argv				/* Argument strings. */)
{
    Interp *iPtr = (Interp *) interp;
    Hax_Memoryp *memoryp = iPtr->memoryp;
    int i, result;
    int body;
    char *string;
    int caseArgc, splitArgs;
    char **caseArgv;

    if (argc < 3) {
	Hax_AppendResult(interp, "wrong # args: should be \"",
		argv[0], " string ?in? patList body ... ?default body?\"",
		(char *) NULL);
	return HAX_ERROR;
    }
    string = argv[1];
    body = -1;
    if (strcmp(argv[2], "in") == 0) {
	i = 3;
    } else {
	i = 2;
    }
    caseArgc = argc - i;
    caseArgv = argv + i;

    /*
     * If all of the pattern/command pairs are lumped into a single
     * argument, split them out again.
     */

    splitArgs = 0;
    if (caseArgc == 1) {
	result = Hax_SplitList(interp, caseArgv[0], &caseArgc, &caseArgv);
	if (result != HAX_OK) {
	    return result;
	}
	splitArgs = 1;
    }

    for (i = 0; i < caseArgc; i += 2) {
	int patArgc, j;
	char **patArgv;
	char *p;

	if (i == (caseArgc-1)) {
	    interp->result = (char *) "extra case pattern with no body";
	    result = HAX_ERROR;
	    goto cleanup;
	}

	/*
	 * Check for special case of single pattern (no list) with
	 * no backslash sequences.
	 */

	for (p = caseArgv[i]; *p != 0; p++) {
	    if (isspace(*p) || (*p == '\\')) {
		break;
	    }
	}
	if (*p == 0) {
	    if ((*caseArgv[i] == 'd')
		    && (strcmp(caseArgv[i], "default") == 0)) {
		body = i+1;
	    }
	    if (Hax_StringMatch(string, caseArgv[i])) {
		body = i+1;
		goto match;
	    }
	    continue;
	}

	/*
	 * Break up pattern lists, then check each of the patterns
	 * in the list.
	 */

	result = Hax_SplitList(interp, caseArgv[i], &patArgc, &patArgv);
	if (result != HAX_OK) {
	    goto cleanup;
	}
	for (j = 0; j < patArgc; j++) {
	    if (Hax_StringMatch(string, patArgv[j])) {
		body = i+1;
		break;
	    }
	}
	ckfree(memoryp, (char *) patArgv);
	if (j < patArgc) {
	    break;
	}
    }

    match:
    if (body != -1) {
	result = Hax_Eval(interp, NULL, caseArgv[body], 0, (char **) NULL);
	if (result == HAX_ERROR) {
	    char msg[100];
	    sprintf(msg, "\n    (\"%.50s\" arm line %d)", caseArgv[body-1],
		    interp->errorLine);
	    Hax_AddErrorInfo(interp, msg);
	}
	goto cleanup;
    }

    /*
     * Nothing matched:  return nothing.
     */

    result = HAX_OK;

    cleanup:
    if (splitArgs) {
	ckfree(memoryp, (char *) caseArgv);
    }
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %r15
cmpl $0x2, %edx
jg 0x7690
movq (%rcx), %rdx
leaq 0xd1ef(%rip), %rsi      # 0x14860
leaq 0xd202(%rip), %rcx      # 0x1487a
movq %r15, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4510
movl $0x1, %r13d
jmp 0x78c1
movl %edx, %ebx
movq 0x10(%rcx), %rdx
movl $0x2, %eax
cmpb $0x69, (%rdx)
jne 0x76af
cmpb $0x6e, 0x1(%rdx)
jne 0x76af
xorl %eax, %eax
cmpb $0x1, 0x2(%rdx)
adcl $0x2, %eax
movq 0x280(%r15), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rcx), %r12
subl %eax, %ebx
movl %ebx, 0xc(%rsp)
movl %eax, %eax
leaq (%rcx,%rax,8), %rcx
movq %rcx, 0x10(%rsp)
movl %ebx, %eax
cmpl $0x1, %ebx
jne 0x76fb
movq (%rcx), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
callq 0x4530
movl %eax, %r13d
testl %eax, %eax
jne 0x78c1
movl 0xc(%rsp), %eax
testl %eax, %eax
jle 0x789e
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
xorl %r14d, %r14d
decl %eax
cmpq %rax, %r14
je 0x7826
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %r13
movb (%r13), %bpl
testb %bpl, %bpl
je 0x777f
callq 0x4650
movq (%rax), %rax
leaq 0x1(%r13), %rcx
movl %ebp, %edx
cmpb $0x5c, %dl
je 0x7797
movsbq %dl, %rdx
movzwl (%rax,%rdx,2), %edx
andl $0x2000, %edx           # imm = 0x2000
jne 0x7797
movb (%rcx), %dl
incq %rcx
testb %dl, %dl
jne 0x7739
cmpb $0x64, %bpl
jne 0x777f
movq %r13, %rdi
leaq 0xd161(%rip), %rsi      # 0x148c8
callq 0x4320
movl %r14d, %ecx
orl $0x1, %ecx
testl %eax, %eax
movl 0x4(%rsp), %eax
cmovel %ecx, %eax
movl %eax, 0x4(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4470
testl %eax, %eax
je 0x7813
jmp 0x7832
movq %r15, %rdi
movq %r13, %rsi
leaq 0x8(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq 0x4530
testl %eax, %eax
jne 0x78d6
cmpl $0x0, 0x8(%rsp)
jle 0x77e2
xorl %r13d, %r13d
movq 0x20(%rsp), %rax
movq (%rax,%r13,8), %rsi
movq %r12, %rdi
callq 0x4470
testl %eax, %eax
jne 0x77e7
incq %r13
movslq 0x8(%rsp), %rax
cmpq %rax, %r13
jl 0x77be
jmp 0x77f1
xorl %r13d, %r13d
jmp 0x77f1
movl %r14d, %eax
orl $0x1, %eax
movl %eax, 0x4(%rsp)
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdi
leaq 0xd0ce(%rip), %rdx      # 0x148d0
movl $0xa9, %ecx
callq 0x4280
cmpl 0x8(%rsp), %r13d
jl 0x783b
addq $0x2, %r14
movl 0xc(%rsp), %eax
cmpl %r14d, %eax
jg 0x770e
jmp 0x783b
leaq 0xd07b(%rip), %rax      # 0x148a8
movq %rax, (%r15)
jmp 0x7896
orl $0x1, %r14d
movl %r14d, 0x4(%rsp)
movl 0x4(%rsp), %ecx
cmpl $-0x1, %ecx
je 0x789e
movq 0x10(%rsp), %rax
movslq %ecx, %r14
movq (%rax,%r14,8), %rdx
movq %r15, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x45c0
movl %eax, %r13d
cmpl $0x1, %eax
jne 0x78a1
movq 0x10(%rsp), %rax
movq -0x8(%rax,%r14,8), %rdx
movl 0x10(%r15), %ecx
leaq 0xd05f(%rip), %rsi      # 0x148db
leaq 0x20(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x45e0
movq %r15, %rdi
movq %r12, %rsi
callq 0x4410
movl $0x1, %r13d
jmp 0x78a1
xorl %r13d, %r13d
cmpl $0x1, %ebx
jne 0x78c1
movq 0x10(%rsp), %rsi
leaq 0xd01e(%rip), %rdx      # 0x148d0
movq 0x18(%rsp), %rdi
movl $0xc3, %ecx
callq 0x4280
movl %r13d, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %r13d
jmp 0x78a1