// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxCmdMZ.c
// Function: Hax_ScanCmd
int
Hax_ScanCmd(
    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 arg1Length;			/* Number of bytes in argument to be
					 * scanned.  This gives an upper limit
					 * on string field sizes. */
#   define MAX_FIELDS 20
    typedef struct {
	char fmt;			/* Format for field. */
	int size;			/* How many bytes to allow for
					 * field. */
	char *location;			/* Where field will be stored. */
    } Field;
    Field fields[MAX_FIELDS];		/* Info about all the fields in the
					 * format string. */
    Field *curField;
    int numFields = 0;			/* Number of fields actually
					 * specified. */
    int suppress;			/* Current field is assignment-
					 * suppressed. */
    int totalSize = 0;			/* Number of bytes needed to store
					 * all results combined. */
    char *results;			/* Where scanned output goes.  */
    int numScanned;			/* sscanf's result. */
    char *fmt;
    int i, widthSpecified;

    if (argc < 3) {
	Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		" string format ?varName varName ...?\"", (char *) NULL);
	return HAX_ERROR;
    }

    /*
     * This procedure operates in four stages:
     * 1. Scan the format string, collecting information about each field.
     * 2. Allocate an array to hold all of the scanned fields.
     * 3. Call sscanf to do all the dirty work, and have it store the
     *    parsed fields in the array.
     * 4. Pick off the fields from the array and assign them to variables.
     */

    arg1Length = (strlen(argv[1]) + 4) & ~03;
    for (fmt = argv[2]; *fmt != 0; fmt++) {
	if (*fmt != '%') {
	    continue;
	}
	fmt++;
	if (*fmt == '*') {
	    suppress = 1;
	    fmt++;
	} else {
	    suppress = 0;
	}
	widthSpecified = 0;
	while (isdigit(*fmt)) {
	    widthSpecified = 1;
	    fmt++;
	}
	if (suppress) {
	    continue;
	}
	if (numFields == MAX_FIELDS) {
	    interp->result = (char *) "too many fields to scan";
	    return HAX_ERROR;
	}
	curField = &fields[numFields];
	numFields++;
	switch (*fmt) {
	    case 'D':
	    case 'O':
	    case 'X':
	    case 'd':
	    case 'o':
	    case 'x':
		curField->fmt = 'd';
		curField->size = sizeof(int);
		break;

	    case 's':
		curField->fmt = 's';
		curField->size = arg1Length;
		break;

	    case 'c':
                if (widthSpecified) {
                    interp->result =
                         (char *) "field width may not be specified in %c "
			    "conversion";
                    return HAX_ERROR;
                }
		curField->fmt = 'c';
		curField->size = sizeof(int);
		break;

	    case 'E':
	    case 'F':
		curField->fmt = 'F';
		curField->size = sizeof(double);
		break;

	    case 'e':
	    case 'f':
		curField->fmt = 'f';
		curField->size = sizeof(float);
		break;

	    case '[':
		curField->fmt = 's';
		curField->size = arg1Length;
		do {
		    fmt++;
		} while (*fmt != ']');
		break;

	    default:
		sprintf(interp->result, "bad scan conversion character \"%c\"",
			*fmt);
		return HAX_ERROR;
	}
	totalSize += curField->size;
    }

    if (numFields != (argc-3)) {
	interp->result =
		(char *) "different numbers of variable names and field "
		    "specifiers";
	return HAX_ERROR;
    }

    /*
     * Step 2:
     */

    results = (char *) ckalloc(memoryp, (unsigned) totalSize);
    for (i = 0, totalSize = 0, curField = fields;
	    i < numFields; i++, curField++) {
	curField->location = results + totalSize;
	totalSize += curField->size;
    }

    /*
     * Fill in the remaining fields with NULL;  the only purpose of
     * this is to keep some memory analyzers, like Purify, from
     * complaining.
     */

    for ( ; i < MAX_FIELDS; i++, curField++) {
	curField->location = NULL;
    }

    /*
     * Step 3:
     */

    numScanned = sscanf(argv[1], argv[2],
	    fields[0].location, fields[1].location, fields[2].location,
	    fields[3].location, fields[4].location, fields[5].location,
	    fields[6].location, fields[7].location, fields[8].location,
	    fields[9].location, fields[10].location, fields[11].location,
	    fields[12].location, fields[13].location, fields[14].location,
	    fields[15].location, fields[16].location, fields[17].location,
	    fields[18].location, fields[19].location);

    /*
     * Step 4:
     */

    if (numScanned < numFields) {
	numFields = numScanned;
    }
    for (i = 0, curField = fields; i < numFields; i++, curField++) {
	switch (curField->fmt) {
	    char string[120];

	    case 'd':
		sprintf(string, "%d", *((int *) curField->location));
		if (Hax_SetVar(interp, argv[i+3], string, 0) == NULL) {
		    storeError:
		    Hax_AppendResult(interp,
			    "couldn't set variable \"", argv[i+3], "\"",
			    (char *) NULL);
		    ckfree(memoryp, (char *) results);
		    return HAX_ERROR;
		}
		break;

	    case 'c':
		sprintf(string, "%d", *((char *) curField->location) & 0xff);
		if (Hax_SetVar(interp, argv[i+3], string, 0) == NULL) {
		    goto storeError;
		}
		break;

	    case 's':
		if (Hax_SetVar(interp, argv[i+3], curField->location, 0)
			== NULL) {
		    goto storeError;
		}
		break;

	    case 'F':
		sprintf(string, "%g", *((double *) curField->location));
		if (Hax_SetVar(interp, argv[i+3], string, 0) == NULL) {
		    goto storeError;
		}
		break;

	    case 'f':
		sprintf(string, "%g", *((float *) curField->location));
		if (Hax_SetVar(interp, argv[i+3], string, 0) == NULL) {
		    goto storeError;
		}
		break;
	}
    }
    ckfree(memoryp, results);
    sprintf(interp->result, "%d", numScanned);
    return HAX_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x318, %rsp            # imm = 0x318
movq %rdi, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
movl %edx, -0x44(%rbp)
movq %rcx, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq 0x280(%rax), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x1bc(%rbp)
movl $0x0, -0x1c4(%rbp)
cmpl $0x3, -0x44(%rbp)
jge 0xd8b5
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rax
movq (%rax), %rdx
leaq 0x100de(%rip), %rsi     # 0x1d974
leaq 0x10b1e(%rip), %rcx     # 0x1e3bb
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x4500
movl $0x1, -0x2c(%rbp)
jmp 0xe0c2
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x41b0
addq $0x4, %rax
andq $-0x4, %rax
movl %eax, -0x64(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x1e0(%rbp)
movq -0x1e0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xdb65
movq -0x1e0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x25, %eax
je 0xd903
jmp 0xdb4e
movq -0x1e0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1e0(%rbp)
movq -0x1e0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
jne 0xd942
movl $0x1, -0x1c0(%rbp)
movq -0x1e0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1e0(%rbp)
jmp 0xd94c
movl $0x0, -0x1c0(%rbp)
movl $0x0, -0x1e8(%rbp)
callq 0x4630
movq (%rax), %rax
movq -0x1e0(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0xd997
movl $0x1, -0x1e8(%rbp)
movq -0x1e0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1e0(%rbp)
jmp 0xd956
cmpl $0x0, -0x1c0(%rbp)
je 0xd9a5
jmp 0xdb4e
cmpl $0x14, -0x1bc(%rbp)
jne 0xd9c8
movq -0x40(%rbp), %rax
leaq 0x10a28(%rip), %rcx     # 0x1e3e1
movq %rcx, (%rax)
movl $0x1, -0x2c(%rbp)
jmp 0xe0c2
movslq -0x1bc(%rbp), %rax
shlq $0x4, %rax
leaq -0x1b0(%rbp,%rax), %rax
movq %rax, -0x1b8(%rbp)
movl -0x1bc(%rbp), %eax
incl %eax
movl %eax, -0x1bc(%rbp)
movq -0x1e0(%rbp), %rax
movsbl (%rax), %eax
addl $-0x44, %eax
movl %eax, %ecx
movq %rcx, -0x268(%rbp)
subl $0x34, %eax
ja 0xdb0d
movq -0x268(%rbp), %rax
leaq 0x1073f(%rip), %rcx     # 0x1e15c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x1b8(%rbp), %rax
movb $0x64, (%rax)
movq -0x1b8(%rbp), %rax
movl $0x4, 0x4(%rax)
jmp 0xdb38
movq -0x1b8(%rbp), %rax
movb $0x73, (%rax)
movl -0x64(%rbp), %ecx
movq -0x1b8(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0xdb38
cmpl $0x0, -0x1e8(%rbp)
je 0xda82
movq -0x40(%rbp), %rax
leaq 0x10986(%rip), %rcx     # 0x1e3f9
movq %rcx, (%rax)
movl $0x1, -0x2c(%rbp)
jmp 0xe0c2
movq -0x1b8(%rbp), %rax
movb $0x63, (%rax)
movq -0x1b8(%rbp), %rax
movl $0x4, 0x4(%rax)
jmp 0xdb38
movq -0x1b8(%rbp), %rax
movb $0x46, (%rax)
movq -0x1b8(%rbp), %rax
movl $0x8, 0x4(%rax)
jmp 0xdb38
movq -0x1b8(%rbp), %rax
movb $0x66, (%rax)
movq -0x1b8(%rbp), %rax
movl $0x4, 0x4(%rax)
jmp 0xdb38
movq -0x1b8(%rbp), %rax
movb $0x73, (%rax)
movl -0x64(%rbp), %ecx
movq -0x1b8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x1e0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1e0(%rbp)
movq -0x1e0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5d, %eax
jne 0xdaea
jmp 0xdb38
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x1e0(%rbp), %rax
movsbl (%rax), %edx
leaq 0x10906(%rip), %rsi     # 0x1e42b
movb $0x0, %al
callq 0x45d0
movl $0x1, -0x2c(%rbp)
jmp 0xe0c2
movq -0x1b8(%rbp), %rax
movl 0x4(%rax), %eax
addl -0x1c4(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x1e0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1e0(%rbp)
jmp 0xd8dc
movl -0x1bc(%rbp), %eax
movl -0x44(%rbp), %ecx
subl $0x3, %ecx
cmpl %ecx, %eax
je 0xdb8f
movq -0x40(%rbp), %rax
leaq 0x108ce(%rip), %rcx     # 0x1e44e
movq %rcx, (%rax)
movl $0x1, -0x2c(%rbp)
jmp 0xe0c2
movq -0x60(%rbp), %rdi
movl -0x1c4(%rbp), %eax
movl %eax, %esi
leaq 0x106e0(%rip), %rdx     # 0x1e282
movl $0x2a5, %ecx            # imm = 0x2A5
callq 0x44c0
movq %rax, -0x1d0(%rbp)
movl $0x0, -0x1e4(%rbp)
movl $0x0, -0x1c4(%rbp)
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movl -0x1e4(%rbp), %eax
cmpl -0x1bc(%rbp), %eax
jge 0xdc38
movq -0x1d0(%rbp), %rcx
movslq -0x1c4(%rbp), %rax
addq %rax, %rcx
movq -0x1b8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x1b8(%rbp), %rax
movl 0x4(%rax), %eax
addl -0x1c4(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movl -0x1e4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1e4(%rbp)
movq -0x1b8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x1b8(%rbp)
jmp 0xdbd5
jmp 0xdc3a
cmpl $0x14, -0x1e4(%rbp)
jge 0xdc75
movq -0x1b8(%rbp), %rax
movq $0x0, 0x8(%rax)
movl -0x1e4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1e4(%rbp)
movq -0x1b8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x1b8(%rbp)
jmp 0xdc3a
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x1a8(%rbp), %rdx
movq -0x198(%rbp), %rcx
movq -0x188(%rbp), %r8
movq -0x178(%rbp), %r9
movq -0x168(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movq -0x148(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x138(%rbp), %rax
movq %rax, -0x298(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x290(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0x288(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x280(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x278(%rbp)
movq -0xe8(%rbp), %r13
movq -0xd8(%rbp), %r12
movq -0xc8(%rbp), %r15
movq -0xb8(%rbp), %r14
movq -0xa8(%rbp), %rbx
movq -0x98(%rbp), %r11
movq -0x88(%rbp), %r10
movq -0x78(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x2b0(%rbp), %rax
movq %rax, (%rsp)
movq -0x2a8(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x2a0(%rbp), %rax
movq %rax, 0x10(%rsp)
movq -0x298(%rbp), %rax
movq %rax, 0x18(%rsp)
movq -0x290(%rbp), %rax
movq %rax, 0x20(%rsp)
movq -0x288(%rbp), %rax
movq %rax, 0x28(%rsp)
movq -0x280(%rbp), %rax
movq %rax, 0x30(%rsp)
movq -0x278(%rbp), %rax
movq %rax, 0x38(%rsp)
movq -0x270(%rbp), %rax
movq %r13, 0x40(%rsp)
movq %r12, 0x48(%rsp)
movq %r15, 0x50(%rsp)
movq %r14, 0x58(%rsp)
movq %rbx, 0x60(%rsp)
movq %r11, 0x68(%rsp)
movq %r10, 0x70(%rsp)
movq %rax, 0x78(%rsp)
movb $0x0, %al
callq 0x4430
movl %eax, -0x1d4(%rbp)
movl -0x1d4(%rbp), %eax
cmpl -0x1bc(%rbp), %eax
jge 0xde02
movl -0x1d4(%rbp), %eax
movl %eax, -0x1bc(%rbp)
movl $0x0, -0x1e4(%rbp)
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movl -0x1e4(%rbp), %eax
cmpl -0x1bc(%rbp), %eax
jge 0xe084
movq -0x1b8(%rbp), %rax
movsbl (%rax), %eax
addl $-0x46, %eax
movl %eax, %ecx
movq %rcx, -0x2b8(%rbp)
subl $0x2d, %eax
ja 0xe05c
movq -0x2b8(%rbp), %rax
leaq 0x1024b(%rip), %rcx     # 0x1e0a4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x260(%rbp), %rdi
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %edx
leaq 0xf457(%rip), %rsi      # 0x1d2d4
movb $0x0, %al
callq 0x45d0
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rax
movl -0x1e4(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x260(%rbp), %rdx
xorl %ecx, %ecx
callq 0x4450
cmpq $0x0, %rax
jne 0xdf0c
jmp 0xdeb2
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rax
movl -0x1e4(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x10406(%rip), %rsi     # 0x1e2d7
leaq 0xf398(%rip), %rcx      # 0x1d270
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x4500
movq -0x60(%rbp), %rdi
movq -0x1d0(%rbp), %rsi
leaq 0x1038c(%rip), %rdx     # 0x1e282
movl $0x2d5, %ecx            # imm = 0x2D5
callq 0x4260
movl $0x1, -0x2c(%rbp)
jmp 0xe0c2
jmp 0xe05c
leaq -0x260(%rbp), %rdi
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %edx
andl $0xff, %edx
leaq 0xf3a1(%rip), %rsi      # 0x1d2d4
movb $0x0, %al
callq 0x45d0
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rax
movl -0x1e4(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x260(%rbp), %rdx
xorl %ecx, %ecx
callq 0x4450
cmpq $0x0, %rax
jne 0xdf6b
jmp 0xdeb2
jmp 0xe05c
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rax
movl -0x1e4(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rdx
xorl %ecx, %ecx
callq 0x4450
cmpq $0x0, %rax
jne 0xdfa5
jmp 0xdeb2
jmp 0xe05c
leaq -0x260(%rbp), %rdi
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rax
movsd (%rax), %xmm0
leaq 0x104c0(%rip), %rsi     # 0x1e487
movb $0x1, %al
callq 0x45d0
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rax
movl -0x1e4(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x260(%rbp), %rdx
xorl %ecx, %ecx
callq 0x4450
cmpq $0x0, %rax
jne 0xdfff
jmp 0xdeb2
jmp 0xe05c
leaq -0x260(%rbp), %rdi
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x10465(%rip), %rsi     # 0x1e487
movb $0x1, %al
callq 0x45d0
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rax
movl -0x1e4(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x260(%rbp), %rdx
xorl %ecx, %ecx
callq 0x4450
cmpq $0x0, %rax
jne 0xe05a
jmp 0xdeb2
jmp 0xe05c
jmp 0xe05e
movl -0x1e4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1e4(%rbp)
movq -0x1b8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x1b8(%rbp)
jmp 0xde1a
movq -0x60(%rbp), %rdi
movq -0x1d0(%rbp), %rsi
leaq 0x101ec(%rip), %rdx     # 0x1e282
movl $0x2f7, %ecx            # imm = 0x2F7
callq 0x4260
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movl -0x1d4(%rbp), %edx
leaq 0xf220(%rip), %rsi      # 0x1d2d4
movb $0x0, %al
callq 0x45d0
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw (%rax,%rax)