// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]kivaloo/tests/mux/main.c
// Function: createmany
static int
createmany(struct wire_requestqueue * Q, size_t N, char * prefix)
{
	size_t i;
	struct kvldskey * key;
	struct kvldskey * key2;
	struct kvldskey ** values;
	size_t plen = strlen(prefix);
	uint8_t * keybuf = malloc(plen + 8);
	char valbuf[20];

	/* Copy prefix in. */
	memcpy(keybuf, prefix, plen);

	/* Allocate values structures. */
	values = malloc(N * sizeof(struct kvldskey *));
	for (i = 0; i < N; i++) {
		sprintf(valbuf, "%zu", i);
		values[i] = kvldskey_create((uint8_t *)valbuf, strlen(valbuf));
	}

	/* Store N key-value pairs. */
	op_done = 0;
	op_count = N;
	for (i = 0; i < N; i++) {
		be64enc(&keybuf[plen], i);
		key = kvldskey_create(keybuf, plen + 8);
		if (proto_kvlds_request_set(Q, key, values[i],
		    callback_done, NULL))
			return (-1);
		kvldskey_free(key);
	}

	/* Wait for SETs to complete. */
	if (events_spin(&op_done) || op_failed) {
		warnp("SET request failed");
		return (-1);
	}

	/* Read the values back and check that they are correct. */
	op_done = 0;
	op_failed = 0;
	op_count = N;
	for (i = 0; i < N; i++) {
		be64enc(&keybuf[plen], i);
		key = kvldskey_create(keybuf, plen + 8);
		if (proto_kvlds_request_get(Q, key, callback_get,
		    (void *)(uintptr_t)values[i])) {
			warnp("Error sending GET request");
			return (-1);
		}
		kvldskey_free(key);
	}
	if (events_spin(&op_done) || op_failed) {
		warnp("GET request failed");
		return (-1);
	}
	if (op_badval) {
		warnp("Bad value returned by GET!");
		return (-1);
	}

	/* Free values. */
	for (i = 0; i < N; i++)
		kvldskey_free(values[i]);
	free(values);

	/* Delete all the values. */
	be64enc(&keybuf[plen], 0);
	key = kvldskey_create(keybuf, plen + 8);
	be64enc(&keybuf[plen], N);
	key2 = kvldskey_create(keybuf, plen + 8);
	op_done = 0;
	op_count = 1;
	if (proto_kvlds_request_range2(Q, key, key2, callback_range,
	    callback_done, Q))
		return (-1);
	kvldskey_free(key2);
	kvldskey_free(key);

	/* Wait for RANGEs and DELETEs to complete. */
	if (events_spin(&op_done) || op_failed) {
		warnp("RANGE or DELETE request failed");
		return (-1);
	}

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, 0x18(%rsp)
movq %rsi, %rdi
callq 0x20f0
movq %rax, %r14
leaq 0x8(%rax), %rdi
movq %rdi, 0x10(%rsp)
callq 0x21f0
movq %rax, %r12
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x21d0
movl $0x13880, %edi          # imm = 0x13880
callq 0x21f0
movq %rax, %r13
leaq 0x8755(%rip), %rbx      # 0xb0fd
leaq 0x20(%rsp), %rbp
xorl %r15d, %r15d
movq %rbp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x22a0
movq %rbp, %rdi
callq 0x20f0
movq %rbp, %rdi
movq %rax, %rsi
callq 0x4730
movq %rax, (%r13,%r15,8)
incq %r15
cmpq $0x2710, %r15           # imm = 0x2710
jne 0x29b0
movl $0x0, 0xec2e(%rip)      # 0x1161c
movq $0x2710, 0xec27(%rip) # imm = 0x2710
addq %r14, %r12
xorl %r14d, %r14d
leaq 0x2ae(%rip), %rbx       # 0x2cb4
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %r14d, %eax
rolw $0x8, %ax
movw %ax, 0x6(%r12)
movl $0x0, (%r12)
movw $0x0, 0x4(%r12)
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x4730
movq %rax, %r15
movq (%r13,%r14,8), %rdx
movq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x495d
testl %eax, %eax
jne 0x2c9a
movq %r15, %rdi
callq 0x2040
incq %r14
cmpq $0x2710, %r14           # imm = 0x2710
jne 0x2a0b
leaq 0xeba7(%rip), %rdi      # 0x1161c
callq 0x3085
orl 0xeba8(%rip), %eax      # 0x11628
je 0x2a9f
callq 0x2090
cmpl $0x0, (%rax)
je 0x2b6e
movq %rax, %rbx
leaq 0x85f6(%rip), %rdi      # 0xb090
jmp 0x2b5c
xorl %ebx, %ebx
movl %ebx, 0xeb75(%rip)      # 0x1161c
movl %ebx, 0xeb7b(%rip)      # 0x11628
movq $0x2710, 0xeb68(%rip) # imm = 0x2710
leaq 0x240(%rip), %r14       # 0x2cff
movl %ebx, %eax
rolw $0x8, %ax
movw %ax, 0x6(%r12)
movl $0x0, (%r12)
movw $0x0, 0x4(%r12)
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x4730
movq %rax, %r15
movq (%r13,%rbx,8), %rcx
movq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x5282
testl %eax, %eax
jne 0x2b48
movq %r15, %rdi
callq 0x2040
incq %rbx
cmpq $0x2710, %rbx           # imm = 0x2710
jne 0x2abf
leaq 0xeafb(%rip), %rdi      # 0x1161c
callq 0x3085
orl 0xeafc(%rip), %eax      # 0x11628
je 0x2b7a
callq 0x2090
cmpl $0x0, (%rax)
je 0x2c7e
movq %rax, %rbx
leaq 0x85d5(%rip), %rdi      # 0xb11b
jmp 0x2b5c
callq 0x2090
cmpl $0x0, (%rax)
je 0x2b9d
movq %rax, %rbx
leaq 0x85a5(%rip), %rdi      # 0xb101
xorl %eax, %eax
callq 0x44ec
movl $0x0, (%rbx)
jmp 0x2c95
leaq 0x851b(%rip), %rdi      # 0xb090
jmp 0x2c8e
cmpb $0x0, 0xeaab(%rip)      # 0x1162c
je 0x2ba9
callq 0x2090
cmpl $0x0, (%rax)
je 0x2c87
movq %rax, %rbx
leaq 0x8593(%rip), %rdi      # 0xb12e
jmp 0x2b5c
leaq 0x855d(%rip), %rdi      # 0xb101
jmp 0x2c8e
xorl %ebx, %ebx
movq (%r13,%rbx,8), %rdi
callq 0x2040
incq %rbx
cmpq $0x2710, %rbx           # imm = 0x2710
jne 0x2bab
movq %r13, %rdi
callq 0x2040
movq $0x0, (%r12)
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x4730
movq %rax, %rbx
movabsq $0x1027000000000000, %rax # imm = 0x1027000000000000
movq %rax, (%r12)
movq %r15, %rdi
movq %r14, %rsi
callq 0x4730
movq %rax, %r14
movl $0x0, 0xea0d(%rip)      # 0x1161c
movq $0x1, 0xea06(%rip) # 0x11620
leaq 0x15d(%rip), %rcx       # 0x2d7e
leaq 0x8c(%rip), %r8         # 0x2cb4
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
movq %rdi, %r9
callq 0x593a
testl %eax, %eax
jne 0x2c9a
movq %r14, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
leaq 0xe9c6(%rip), %rdi      # 0x1161c
callq 0x3085
xorl %ebp, %ebp
orl 0xe9c5(%rip), %eax      # 0x11628
je 0x2c9a
callq 0x2090
cmpl $0x0, (%rax)
je 0x2cab
movq %rax, %rbx
leaq 0x84d0(%rip), %rdi      # 0xb149
jmp 0x2b5c
leaq 0x8496(%rip), %rdi      # 0xb11b
jmp 0x2c8e
leaq 0x84a0(%rip), %rdi      # 0xb12e
xorl %eax, %eax
callq 0x460b
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8497(%rip), %rdi      # 0xb149
jmp 0x2c8e