// File: /workspace/github_c_makefile_star2_O1/NedFreed[P]msglint/msglint.c
// Function: valreset
static int valreset(int *pstack, vstack *vs, msgtoken **cur,
		    const char **tmpl, whtwarn_ctx *wht, best_ctx *best)
{
    int stack = *pstack;
    const char *next;

    /* remember best token */
    if (*cur == NULL ||
	(best->tok != NULL && (*cur)->toknum > best->tok->toknum)) {
	best->tok = *cur;
	best->tmpl = *tmpl;
    }

    /* try to back up */
    while (stack >= 0) {
	/* don't allow reset outside a matched enumerated type */
	if (*vs[stack].type == 'E' || *vs[stack].type == 'e') break;

	/* skip an optional, repeat or successful repeat-at-least-once */
	if (*vs[stack].type == 'O' || *vs[stack].type == '*' ||
	    (*vs[stack].type == '1' && vs[stack].count > 0)) {
	    *cur = vs[stack].cur;
	    *wht = vs[stack].wstate;
	    *tmpl = skipvalgroup(vs[stack].vstate);
	    *pstack = stack - 1;
	    return (1);
	}

	/* try a different alternate if available */
	if (*vs[stack].type == 'A') {
	    next = vs[stack].vstate = skipvalseg(vs[stack].vstate);
	    if (*next != '}' && *next != '\0') {
		*cur = vs[stack].cur;
		*wht = vs[stack].wstate;
		*tmpl = next;
		*pstack = stack;
		return (1);
	    }
	}
	--stack;
    }

    /* failed to reset */
    
    return (0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r15
movq %rdx, %r12
movq %rdi, %rbx
movl (%rdi), %r13d
movq (%rdx), %rax
testq %rax, %rax
je 0x99e2
movq (%r9), %rdi
testq %rdi, %rdi
je 0x99ec
movl 0x18(%rax), %edx
cmpl 0x18(%rdi), %edx
jle 0x99ec
movq %rax, (%r9)
movq (%rcx), %rax
movq %rax, 0x8(%r9)
xorl %ebp, %ebp
testl %r13d, %r13d
js 0x9afe
movq %rcx, (%rsp)
leaq (,%r13,2), %rax
addq %r13, %rax
shlq $0x5, %rax
leaq (%rax,%rsi), %r14
addq $0x28, %r14
movq -0x20(%r14), %rax
movb (%rax), %cl
movzbl %cl, %eax
cmpl $0x40, %eax
jle 0x9a2c
cmpl $0x44, %eax
jg 0x9a62
cmpl $0x41, %eax
je 0x9a3d
jmp 0x9a79
cmpl $0x31, %eax
jne 0x9a5b
cmpl $0x0, -0x8(%r14)
jg 0x9a8b
cmpb $0x41, %cl
jne 0x9a79
movq -0x18(%r14), %rdi
callq 0x9b44
movq %rax, -0x18(%r14)
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x9a79
cmpl $0x7d, %ecx
je 0x9a79
jmp 0x9b0f
cmpl $0x2a, %eax
jne 0x9a79
jmp 0x9a8b
cmpl $0x45, %eax
je 0x9afe
cmpl $0x4f, %eax
je 0x9a8b
cmpl $0x65, %eax
je 0x9afe
leaq -0x1(%r13), %rax
addq $-0x60, %r14
testq %r13, %r13
movq %rax, %r13
jg 0x9a12
jmp 0x9afe
movq -0x28(%r14), %rax
movq %rax, (%r12)
movq 0x30(%r14), %rax
movq %rax, 0x30(%r15)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups %xmm2, 0x20(%r15)
movups %xmm1, 0x10(%r15)
movups %xmm0, (%r15)
movq -0x18(%r14), %rax
xorl %ecx, %ecx
movq (%rsp), %rdi
movzbl (%rax), %edx
cmpl $0x7d, %edx
je 0x9acf
testl %edx, %edx
jne 0x9ad5
jmp 0x9ae5
testl %ecx, %ecx
jle 0x9ae5
decl %ecx
xorl %esi, %esi
cmpb $0x7b, %dl
sete %sil
addl %esi, %ecx
incq %rax
jmp 0x9ac1
xorl %ecx, %ecx
cmpb $0x7d, %dl
sete %cl
addq %rcx, %rax
movq %rax, (%rdi)
decl %r13d
movl %r13d, (%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x28(%r14), %rcx
movq %rcx, (%r12)
movq 0x30(%r14), %rcx
movq %rcx, 0x30(%r15)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups %xmm2, 0x20(%r15)
movups %xmm1, 0x10(%r15)
movups %xmm0, (%r15)
movq (%rsp), %rcx
movq %rax, (%rcx)
jmp 0x9af6