// File: /workspace/github_c_makefile_star2_O1/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 0x4704
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x2936
movq %rax, %r14
movq %r12, %rdi
callq 0x20f0
movq %r12, %rdi
movq %rax, %rsi
callq 0x4704
testq %rax, %rax
je 0x2936
movq %rax, %r12
movl %r13d, 0x4(%rsp)
movq %rbx, %rdi
callq 0x20f0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4704
testq %rax, %rax
je 0x2936
movq %rax, %r13
cmpl $0x0, 0x4(%rsp)
je 0x27a3
movl $0x0, 0xeef8(%rip)      # 0x1161c
movq $0x1, 0xeef1(%rip) # 0x11620
leaq 0x57c(%rip), %rcx       # 0x2cb2
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
xorl %r8d, %r8d
callq 0x4935
testl %eax, %eax
je 0x2765
callq 0x2090
cmpl $0x0, (%rax)
je 0x288a
movq %rax, %rbx
leaq 0x8913(%rip), %rdi      # 0xb076
jmp 0x2791
leaq 0xeeb0(%rip), %rdi      # 0x1161c
callq 0x3095
orl 0xeeb1(%rip), %eax      # 0x11628
je 0x27a3
callq 0x2090
cmpl $0x0, (%rax)
je 0x28f8
movq %rax, %rbx
leaq 0x88ff(%rip), %rdi      # 0xb090
xorl %eax, %eax
callq 0x44c0
movl $0x0, (%rbx)
jmp 0x2936
cmpl $0x63, 0x4(%rsp)
jg 0x2810
leaq 0xee6b(%rip), %rbx      # 0x1161c
movl 0x4(%rsp), %ebp
movl $0x0, 0xee5d(%rip)      # 0x1161c
movq $0x1, 0xee56(%rip) # 0x11620
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
leaq 0x500(%rip), %r8        # 0x2cdd
xorl %r9d, %r9d
callq 0x4b09
testl %eax, %eax
jne 0x2893
movq %rbx, %rdi
callq 0x3095
orl 0xee2d(%rip), %eax      # 0x11628
jne 0x28a9
cmpl $0x1, 0xee10(%rip)      # 0x11618
sbbl $-0x1, %ebp
cmpl $0x64, %ebp
jl 0x27b5
cmpl $0x0, 0x4(%rsp)
je 0x286b
leaq 0x4bf(%rip), %rbx       # 0x2cdd
leaq 0xedf7(%rip), %rbp      # 0x1161c
movl $0x0, 0xeded(%rip)      # 0x1161c
movq $0x1, 0xede6(%rip) # 0x11620
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x50f7
testl %eax, %eax
jne 0x28bf
movq %rbp, %rdi
callq 0x3095
orl 0xedc8(%rip), %eax      # 0x11628
jne 0x28d5
cmpl $0x0, 0xedaf(%rip)      # 0x11618
je 0x2825
movq %r13, %rdi
callq 0x2040
movq %r12, %rdi
callq 0x2040
movq %r14, %rdi
callq 0x2040
xorl %ebp, %ebp
jmp 0x2936
leaq 0x87e5(%rip), %rdi      # 0xb076
jmp 0x28ff
callq 0x2090
cmpl $0x0, (%rax)
je 0x2908
movq %rax, %rbx
leaq 0x87fc(%rip), %rdi      # 0xb0a3
jmp 0x28e9
callq 0x2090
cmpl $0x0, (%rax)
je 0x2911
movq %rax, %rbx
leaq 0x8800(%rip), %rdi      # 0xb0bd
jmp 0x28e9
callq 0x2090
cmpl $0x0, (%rax)
je 0x291a
movq %rax, %rbx
leaq 0x87fd(%rip), %rdi      # 0xb0d0
jmp 0x28e9
callq 0x2090
cmpl $0x0, (%rax)
je 0x2923
movq %rax, %rbx
leaq 0x8801(%rip), %rdi      # 0xb0ea
xorl %eax, %eax
callq 0x44c0
movl $0x0, (%rbx)
jmp 0x2931
leaq 0x8791(%rip), %rdi      # 0xb090
xorl %eax, %eax
callq 0x45df
jmp 0x2936
leaq 0x8794(%rip), %rdi      # 0xb0a3
jmp 0x292a
leaq 0x87a5(%rip), %rdi      # 0xb0bd
jmp 0x292a
leaq 0x87af(%rip), %rdi      # 0xb0d0
jmp 0x292a
leaq 0x87c0(%rip), %rdi      # 0xb0ea
xorl %eax, %eax
callq 0x45df
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq