// File: /workspace/github_c_makefile_star2_O0/hansvanstaveren[P]BigDeal/output.c
// Function: cnv_int_byh
static void
cnv_int_byh(dl_int *dip, dl_byh *dbhp)
/*
 * Converts the internal handrepresentation from
 * *dip to a "bri" like coding in *dbhp.
 * This representation is as follows:
 * The 52 cards are numbered 1: AS, 2 KS, .... , 52 2C
 * and all thirteen slots for all four hands are filled in with one of
 * the 52 cards.
 *
 * Given the way this program works the order of cards per hand will
 * be strictly increasing.
 */
{
    int nextcard[NCARDSPERDECK+1];
    int i;
    int card,prevcard;
    int skip, skipcnt;
    int compass;

    /*
     * Setup a chain of 52 cards with a linked list type structure
     */
    for (i=0; i<NCARDSPERDECK; i++)
	nextcard[i] = i+1;
    nextcard[NCARDSPERDECK] = 0;

    /*
     * Run through the hand converting skip numbers to cards
     */
    for (compass=COMPASS_NORTH; compass<=COMPASS_WEST; compass++) {
	/*
	 * Get to the beginning of all leftover cards
	 */
	prevcard = 0;
	card = nextcard[prevcard];
	/*
	 * Go select the thirteen cards for this hand
	 */
	for (i=0; i<NCARDSPERHAND; i++) {
	    /*
	     * For the first card use number of skips directly
	     * for all other cards the extra skip compared to
	     * the previous card
	     */
	    if (i==0)
		skip=dip->di_hand[compass][0];
	    else
		skip=dip->di_hand[compass][i] - dip->di_hand[compass][i-1];
	    for (skipcnt=0; skipcnt<skip; skipcnt++) {
		prevcard = card;
		card = nextcard[card];
	    }
	    dbhp->dh_hand[compass][i] = card;
	    /*
	     * Take card just selected out of the linked list
	     */
	    card = nextcard[card];
	    nextcard[prevcard] = card;
	}
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0xf4(%rbp)
cmpl $0x34, -0xf4(%rbp)
jge 0x72ce
movl -0xf4(%rbp), %ecx
addl $0x1, %ecx
movslq -0xf4(%rbp), %rax
movl %ecx, -0xf0(%rbp,%rax,4)
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x729d
movl $0x0, -0x20(%rbp)
movl $0x0, -0x108(%rbp)
cmpl $0x3, -0x108(%rbp)
jg 0x744d
movl $0x0, -0xfc(%rbp)
movslq -0xfc(%rbp), %rax
movl -0xf0(%rbp,%rax,4), %eax
movl %eax, -0xf8(%rbp)
movl $0x0, -0xf4(%rbp)
cmpl $0xd, -0xf4(%rbp)
jge 0x7437
cmpl $0x0, -0xf4(%rbp)
jne 0x7347
movq -0x8(%rbp), %rax
movslq -0x108(%rbp), %rcx
imulq $0xd, %rcx, %rcx
addq %rcx, %rax
movzbl (%rax), %eax
movl %eax, -0x100(%rbp)
jmp 0x738e
movq -0x8(%rbp), %rax
movslq -0x108(%rbp), %rcx
imulq $0xd, %rcx, %rcx
addq %rcx, %rax
movslq -0xf4(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movslq -0x108(%rbp), %rdx
imulq $0xd, %rdx, %rdx
addq %rdx, %rcx
movl -0xf4(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
subl %ecx, %eax
movl %eax, -0x100(%rbp)
movl $0x0, -0x104(%rbp)
movl -0x104(%rbp), %eax
cmpl -0x100(%rbp), %eax
jge 0x73d7
movl -0xf8(%rbp), %eax
movl %eax, -0xfc(%rbp)
movslq -0xf8(%rbp), %rax
movl -0xf0(%rbp,%rax,4), %eax
movl %eax, -0xf8(%rbp)
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0x7398
movl -0xf8(%rbp), %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movslq -0x108(%rbp), %rcx
imulq $0xd, %rcx, %rcx
addq %rcx, %rax
movslq -0xf4(%rbp), %rcx
movb %dl, (%rax,%rcx)
movslq -0xf8(%rbp), %rax
movl -0xf0(%rbp,%rax,4), %eax
movl %eax, -0xf8(%rbp)
movl -0xf8(%rbp), %ecx
movslq -0xfc(%rbp), %rax
movl %ecx, -0xf0(%rbp,%rax,4)
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x7314
jmp 0x7439
movl -0x108(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x108(%rbp)
jmp 0x72df
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)