// File: /workspace/github_c_makefile_star2_O1/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 $0x98, %rsp
movq %rcx, %r12
movq %rsi, %r14
cmpl $0x2, %edx
jg 0x77bc
movq (%r12), %rdx
leaq 0xe0d7(%rip), %rsi      # 0x15874
leaq 0xe0ea(%rip), %rcx      # 0x1588e
movq %r14, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4500
movl $0x1, %r15d
jmp 0x7a79
movl %edx, %ebp
movq 0x280(%r14), %rbx
movq 0x8(%r12), %rax
movq %rax, 0x28(%rsp)
movq 0x10(%r12), %rdi
leaq 0xdbe6(%rip), %rsi      # 0x153c1
callq 0x4310
xorl %ecx, %ecx
cmpl $0x1, %eax
adcl $0x2, %ecx
subl %ecx, %ebp
movl %ebp, 0xc(%rsp)
leaq (%r12,%rcx,8), %rax
movq %rax, 0x10(%rsp)
cmpl $0x1, %ebp
jne 0x781c
movq (%rax), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
callq 0x4520
movl %eax, %r15d
testl %eax, %eax
jne 0x7a79
movq %rbx, 0x20(%rsp)
movl 0xc(%rsp), %eax
testl %eax, %eax
movl %ebp, 0x1c(%rsp)
jle 0x79e1
xorl %r15d, %r15d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
leaq 0xdf6f(%rip), %rcx      # 0x157b0
movl $0x0, 0x4(%rsp)
decl %eax
cmpq %rax, %r15
jne 0x786c
leaq 0xe065(%rip), %rax      # 0x158bc
movq %rax, (%r14)
movl $0x5, %eax
movl $0x1, 0x4(%rsp)
jmp 0x791d
movq %r14, %rbx
movq 0x10(%rsp), %rax
movq (%rax,%r15,8), %r13
movsbq (%r13), %rbp
testq %rbp, %rbp
sete %r14b
je 0x78cd
callq 0x4640
cmpb $0x5c, %bpl
je 0x78c8
movq (%rax), %rax
movzwl (%rax,%rbp,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
jne 0x78c8
leaq 0x1(%r13), %rcx
movsbq (%rcx), %rdx
testq %rdx, %rdx
sete %r14b
je 0x78cd
cmpb $0x5c, %dl
je 0x78c8
movzwl (%rax,%rdx,2), %edx
andl $0x2000, %edx           # imm = 0x2000
incq %rcx
testw %dx, %dx
je 0x78a4
testb %r14b, %r14b
je 0x7947
cmpb $0x64, (%r13)
jne 0x78ef
movq %r13, %rdi
leaq 0xdffe(%rip), %rsi      # 0x158dc
callq 0x4310
movl %r15d, %ecx
orl $0x1, %ecx
testl %eax, %eax
cmovel %ecx, %r12d
movq 0x28(%rsp), %rdi
movq %r13, %rsi
callq 0x4460
movl %r15d, %ecx
orl $0x1, %ecx
xorl %edx, %edx
testl %eax, %eax
setne %dl
cmovnel %ecx, %r12d
leal (%rdx,%rdx,4), %eax
addl $0x4, %eax
movq %rbx, %r14
leaq 0xde93(%rip), %rcx      # 0x157b0
cmpl $0x9, %eax
ja 0x7a8e
movl %eax, %eax
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
addq $0x2, %r15
movl 0xc(%rsp), %eax
cmpl %r15d, %eax
jg 0x7849
jmp 0x79e7
movq %rbx, %r14
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x8(%rsp), %rdx
leaq 0x30(%rsp), %rcx
callq 0x4520
movl %eax, 0x4(%rsp)
testl %eax, %eax
je 0x796e
movl $0x5, %eax
jmp 0x7916
movl $0x0, 0x4(%rsp)
cmpl $0x0, 0x8(%rsp)
jle 0x79a9
xorl %r13d, %r13d
movq 0x28(%rsp), %rbx
movq 0x30(%rsp), %rax
movq (%rax,%r13,8), %rsi
movq %rbx, %rdi
callq 0x4460
testl %eax, %eax
jne 0x79ae
incq %r13
movslq 0x8(%rsp), %rax
cmpq %rax, %r13
jl 0x7985
jmp 0x79b5
xorl %r13d, %r13d
jmp 0x79b5
movl %r15d, %r12d
orl $0x1, %r12d
movq 0x30(%rsp), %rsi
movq 0x20(%rsp), %rdi
leaq 0xdf1e(%rip), %rdx      # 0x158e4
movl $0xa9, %ecx
callq 0x4280
xorl %eax, %eax
cmpl 0x8(%rsp), %r13d
setl %al
addl %eax, %eax
jmp 0x7916
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmpl $-0x1, %r12d
movl 0x1c(%rsp), %ebp
je 0x7a4b
movq 0x10(%rsp), %rax
movslq %r12d, %rbx
movq (%rax,%rbx,8), %rdx
movq %r14, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x45b0
movl %eax, %r15d
cmpl $0x1, %eax
jne 0x7a59
movq 0x10(%rsp), %rax
movq -0x8(%rax,%rbx,8), %rdx
movl 0x10(%r14), %ecx
leaq 0xdec6(%rip), %rsi      # 0x158ef
leaq 0x30(%rsp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x45d0
movq %r14, %rdi
movq %r15, %rsi
callq 0x4400
movl $0x1, %r15d
jmp 0x7a59
xorl %r15d, %r15d
jmp 0x7a59
movl 0x1c(%rsp), %ebp
movl 0x4(%rsp), %r15d
cmpl $0x1, %ebp
jne 0x7a79
movq 0x10(%rsp), %rsi
leaq 0xde7a(%rip), %rdx      # 0x158e4
movq 0x20(%rsp), %rdi
movl $0xc3, %ecx
callq 0x4280
movl %r15d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7a79