// File: /workspace/github_c_makefile_star2_O3/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, %r13d
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x89b7(%rip), %rdi      # 0xb068
movl $0x8, %esi
callq 0x4730
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x293e
movq %rax, %r14
movq %r12, %rdi
callq 0x20f0
movq %r12, %rdi
movq %rax, %rsi
callq 0x4730
testq %rax, %rax
je 0x293e
movq %rax, %r12
movl %r13d, 0x4(%rsp)
movq %rbx, %rdi
callq 0x20f0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4730
testq %rax, %rax
je 0x293e
movq %rax, %r13
movl 0x4(%rsp), %ebx
testl %ebx, %ebx
je 0x27bf
movl $0x0, 0xeef7(%rip)      # 0x1161c
movq $0x1, 0xeef0(%rip) # 0x11620
leaq 0x57d(%rip), %rcx       # 0x2cb4
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
xorl %r8d, %r8d
callq 0x495d
testl %eax, %eax
je 0x2767
callq 0x2090
cmpl $0x0, (%rax)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
je 0x27aa
movq %rax, %rbx
leaq 0x8911(%rip), %rdi      # 0xb076
jmp 0x2798
leaq 0xeeae(%rip), %rdi      # 0x1161c
callq 0x3085
orl 0xeeaf(%rip), %eax      # 0x11628
je 0x27b6
callq 0x2090
cmpl $0x0, (%rax)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
je 0x2912
movq %rax, %rbx
leaq 0x88f8(%rip), %rdi      # 0xb090
xorl %eax, %eax
callq 0x44ec
movl $0x0, (%rbx)
jmp 0x293e
leaq 0x88c5(%rip), %rdi      # 0xb076
jmp 0x2919
movl 0x4(%rsp), %ebx
cmpl $0x63, %ebx
jg 0x2828
leaq 0xee56(%rip), %rbp      # 0x1161c
movl $0x0, 0xee4c(%rip)      # 0x1161c
movq $0x1, 0xee45(%rip) # 0x11620
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
leaq 0x4f1(%rip), %r8        # 0x2cdf
xorl %r9d, %r9d
callq 0x4b31
testl %eax, %eax
jne 0x289b
movq %rbp, %rdi
callq 0x3085
orl 0xee1c(%rip), %eax      # 0x11628
jne 0x28b1
cmpl $0x1, 0xedff(%rip)      # 0x11618
sbbl $-0x1, %ebx
cmpl $0x64, %ebx
jl 0x27c6
cmpl $0x0, 0x4(%rsp)
je 0x287c
leaq 0x4b0(%rip), %rbx       # 0x2cdf
leaq 0xede6(%rip), %rbp      # 0x1161c
movl $0x0, 0xeddc(%rip)      # 0x1161c
movq $0x1, 0xedd5(%rip) # 0x11620
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x511f
testl %eax, %eax
jne 0x28d9
movq %rbp, %rdi
callq 0x3085
orl 0xedb7(%rip), %eax      # 0x11628
jne 0x28ef
cmpl $0x0, 0xed9e(%rip)      # 0x11618
je 0x2836
movq %r13, %rdi
callq 0x2040
movq %r12, %rdi
callq 0x2040
movq %r14, %rdi
callq 0x2040
xorl %ebp, %ebp
jmp 0x293e
callq 0x2090
cmpl $0x0, (%rax)
je 0x28c7
movq %rax, %rbx
leaq 0x87f4(%rip), %rdi      # 0xb0a3
jmp 0x2903
callq 0x2090
cmpl $0x0, (%rax)
je 0x28d0
movq %rax, %rbx
leaq 0x87f8(%rip), %rdi      # 0xb0bd
jmp 0x2903
leaq 0x87d5(%rip), %rdi      # 0xb0a3
jmp 0x2932
leaq 0x87e6(%rip), %rdi      # 0xb0bd
jmp 0x2932
callq 0x2090
cmpl $0x0, (%rax)
je 0x2922
movq %rax, %rbx
leaq 0x87e3(%rip), %rdi      # 0xb0d0
jmp 0x2903
callq 0x2090
cmpl $0x0, (%rax)
je 0x292b
movq %rax, %rbx
leaq 0x87e7(%rip), %rdi      # 0xb0ea
xorl %eax, %eax
callq 0x44ec
movl $0x0, (%rbx)
jmp 0x2939
leaq 0x8777(%rip), %rdi      # 0xb090
xorl %eax, %eax
callq 0x460b
jmp 0x293e
leaq 0x87a7(%rip), %rdi      # 0xb0d0
jmp 0x2932
leaq 0x87b8(%rip), %rdi      # 0xb0ea
xorl %eax, %eax
callq 0x460b
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq