// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq 0x280(%rax), %rax
movq %rax, -0x38(%rbp)
cmpl $0x3, -0x1c(%rbp)
jge 0x9138
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
leaq 0x1485b(%rip), %rsi     # 0x1d974
leaq 0x1486e(%rip), %rcx     # 0x1d98e
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x4500
movl $0x1, -0x4(%rbp)
jmp 0x9411
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movl $0xffffffff, -0x44(%rbp) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x14228(%rip), %rsi     # 0x1d382
callq 0x4300
cmpl $0x0, %eax
jne 0x916d
movl $0x3, -0x3c(%rbp)
jmp 0x9174
movl $0x2, -0x3c(%rbp)
movl -0x1c(%rbp), %eax
subl -0x3c(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x58(%rbp)
cmpl $0x1, -0x54(%rbp)
jne 0x91d0
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rax
movq (%rax), %rsi
leaq -0x54(%rbp), %rdx
leaq -0x60(%rbp), %rcx
callq 0x4520
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x91c9
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x9411
movl $0x1, -0x58(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x9376
movl -0x3c(%rbp), %eax
movl -0x54(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x920a
movq -0x18(%rbp), %rax
leaq 0x147c1(%rip), %rcx     # 0x1d9bc
movq %rcx, (%rax)
movl $0x1, -0x40(%rbp)
jmp 0x93ec
movq -0x60(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x9264
callq 0x4630
movq (%rax), %rax
movq -0x78(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x9252
movq -0x78(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5c, %eax
jne 0x9254
jmp 0x9264
jmp 0x9256
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x921a
movq -0x78(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x92d7
movq -0x60(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x64, %eax
jne 0x92aa
movq -0x60(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x14745(%rip), %rsi     # 0x1d9dc
callq 0x4300
cmpl $0x0, %eax
jne 0x92aa
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x50(%rbp), %rdi
movq -0x60(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x4460
cmpl $0x0, %eax
je 0x92d2
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x9378
jmp 0x9368
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x64(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0x4520
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x9302
jmp 0x93ec
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x9343
movq -0x50(%rbp), %rdi
movq -0x70(%rbp), %rax
movslq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x4460
cmpl $0x0, %eax
je 0x9336
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x9343
jmp 0x9338
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x9309
movq -0x38(%rbp), %rdi
movq -0x70(%rbp), %rsi
leaq 0x14692(%rip), %rdx     # 0x1d9e4
movl $0xa9, %ecx
callq 0x4260
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x9366
jmp 0x9376
jmp 0x9368
movl -0x3c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x3c(%rbp)
jmp 0x91d7
jmp 0x9378
cmpl $-0x1, -0x44(%rbp)
je 0x93e5
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
xorl %eax, %eax
movl %eax, %r8d
xorl %ecx, %ecx
movq %r8, %rsi
callq 0x45b0
movl %eax, -0x40(%rbp)
cmpl $0x1, -0x40(%rbp)
jne 0x93e3
leaq -0xe0(%rbp), %rdi
movq -0x60(%rbp), %rax
movl -0x44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movq -0x18(%rbp), %rax
movl 0x10(%rax), %ecx
leaq 0x14623(%rip), %rsi     # 0x1d9ef
movb $0x0, %al
callq 0x45d0
movq -0x18(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x43f0
jmp 0x93ec
movl $0x0, -0x40(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x940b
movq -0x38(%rbp), %rdi
movq -0x60(%rbp), %rsi
leaq 0x145e3(%rip), %rdx     # 0x1d9e4
movl $0xc3, %ecx
callq 0x4260
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax)