// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/tests/mux/main.c
// Function: pingpong
static int
pingpong(struct wire_requestqueue * Q, const char * key, const char * to,
    const char * from, int start)
{
	struct kvldskey * k;
	struct kvldskey * v0, * v1;
	int i;

	/* Create key and values. */
	if ((k = kvldskey_create((const uint8_t *)key, strlen(key))) == NULL)
		return (-1);
	if ((v0 = kvldskey_create((const uint8_t *)from, strlen(from))) == NULL)
		return (-1);
	if ((v1 = kvldskey_create((const uint8_t *)to, strlen(to))) == NULL)
		return (-1);

	/* Write initial value if we're starting the pingpong. */
	if (start) {
		if (set(Q, k, v1))
			return (-1);
	}

	/* Pingpong 100 times. */
	for (i = start; i < 100; ) {
		if (cas(Q, k, v0, v1))
			return (-1);
		if (op_p)
			i++;
	}

	/* Delete final value if necessary. */
	if (start) {
		do {
			if (cad(Q, k, v0))
				return (-1);
			if (op_p)
				break;
		} while (1);
	}

	/* Delete the values and key. */
	kvldskey_free(v1);
	kvldskey_free(v0);
	kvldskey_free(k);

	/* Success! */
	return (0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r15
leaq 0x7aef(%rip), %rdi      # 0xa068
pushq $0x8
popq %rsi
callq 0x436c
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0x2797
movq %rax, %r14
movq %r12, %rdi
callq 0x20f0
movq %r12, %rdi
movq %rax, %rsi
callq 0x436c
testq %rax, %rax
je 0x2797
movq %rax, %r12
movq %r13, %rdi
callq 0x20f0
movq %r13, %rdi
movq %rax, %rsi
callq 0x436c
testq %rax, %rax
je 0x2797
movq %rax, %r13
movl %ebx, %ebp
testl %ebx, %ebx
je 0x26bf
andl $0x0, 0xe02d(%rip)      # 0x1060c
movq $0x1, 0xe026(%rip) # 0x10610
leaq 0x557(%rip), %rcx       # 0x2b48
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
xorl %r8d, %r8d
callq 0x456e
testl %eax, %eax
je 0x2623
callq 0x2090
cmpl $0x0, (%rax)
je 0x2774
movq %rax, %r14
leaq 0x7a58(%rip), %rdi      # 0xa076
jmp 0x2767
leaq 0xdfe2(%rip), %rdi      # 0x1060c
callq 0x2f03
orl 0xdfe3(%rip), %eax      # 0x10618
movl %ebx, %ebp
je 0x26bf
callq 0x2090
cmpl $0x0, (%rax)
pushq $-0x1
popq %rbp
je 0x27a8
movq %rax, %r14
leaq 0x7a38(%rip), %rdi      # 0xa090
xorl %eax, %eax
callq 0x4059
andl $0x0, (%r14)
jmp 0x2797
andl $0x0, 0xdf9d(%rip)      # 0x1060c
movq $0x1, 0xdf96(%rip) # 0x10610
leaq 0x4f0(%rip), %r8        # 0x2b71
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
xorl %r9d, %r9d
callq 0x46f3
testl %eax, %eax
jne 0x273d
leaq 0xdf68(%rip), %rdi      # 0x1060c
callq 0x2f03
orl 0xdf69(%rip), %eax      # 0x10618
jne 0x2753
cmpl $0x1, 0xdf4c(%rip)      # 0x10608
sbbl $-0x1, %ebp
cmpl $0x63, %ebp
jle 0x2668
testl %ebx, %ebx
je 0x2721
leaq 0x4a2(%rip), %rbx       # 0x2b71
leaq 0xdf36(%rip), %rbp      # 0x1060c
andl $0x0, 0xdf2f(%rip)      # 0x1060c
movq $0x1, 0xdf28(%rip) # 0x10610
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x4b78
testl %eax, %eax
jne 0x27b8
movq %rbp, %rdi
callq 0x2f03
orl 0xdf06(%rip), %eax      # 0x10618
jne 0x27ce
cmpl $0x0, 0xdee9(%rip)      # 0x10608
je 0x26d6
movq %r13, %rdi
callq 0x2040
movq %r12, %rdi
callq 0x2040
movq %r14, %rdi
callq 0x2040
xorl %ebp, %ebp
jmp 0x2797
callq 0x2090
cmpl $0x0, (%rax)
je 0x277d
movq %rax, %r14
leaq 0x7952(%rip), %rdi      # 0xa0a3
jmp 0x2767
callq 0x2090
cmpl $0x0, (%rax)
je 0x2786
movq %rax, %r14
leaq 0x7956(%rip), %rdi      # 0xa0bd
xorl %eax, %eax
callq 0x4059
andl $0x0, (%r14)
jmp 0x2794
leaq 0x78fb(%rip), %rdi      # 0xa076
jmp 0x278d
leaq 0x791f(%rip), %rdi      # 0xa0a3
jmp 0x278d
leaq 0x7930(%rip), %rdi      # 0xa0bd
xorl %eax, %eax
callq 0x41e8
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x78e1(%rip), %rdi      # 0xa090
xorl %eax, %eax
callq 0x41e8
jmp 0x2797
callq 0x2090
cmpl $0x0, (%rax)
je 0x27e4
movq %rax, %r14
leaq 0x7904(%rip), %rdi      # 0xa0d0
jmp 0x2767
callq 0x2090
cmpl $0x0, (%rax)
je 0x27ed
movq %rax, %r14
leaq 0x7908(%rip), %rdi      # 0xa0ea
jmp 0x2767
leaq 0x78e5(%rip), %rdi      # 0xa0d0
jmp 0x278d
leaq 0x78f6(%rip), %rdi      # 0xa0ea
jmp 0x278d