// File: /workspace/github_c_makefile_star2_O2/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, 0x10(%rsp)
movq %rsi, %rdi
callq 0x20f0
movq %rax, %r15
leaq 0x8(%rax), %rdi
movq %rdi, 0x8(%rsp)
callq 0x21e0
movq %rax, %r12
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, 0x18(%rsp)
movq %r15, %rdx
callq 0x21c0
movl $0x13880, %edi          # imm = 0x13880
callq 0x21e0
movq %rax, %r13
leaq 0x78ab(%rip), %rbp      # 0xa0fd
leaq 0x20(%rsp), %rbx
xorl %r15d, %r15d
cmpq $0x2710, %r15           # imm = 0x2710
je 0x2890
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2290
movq %rbx, %rdi
callq 0x20f0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x436c
movq %rax, (%r13,%r15,8)
incq %r15
jmp 0x285a
andl $0x0, 0xdd75(%rip)      # 0x1060c
movq $0x2710, 0xdd6e(%rip) # imm = 0x2710
addq 0x18(%rsp), %r12
xorl %r15d, %r15d
leaq 0x297(%rip), %rbp       # 0x2b48
cmpq $0x2710, %r15           # imm = 0x2710
je 0x2910
movl %r15d, %eax
rolw $0x8, %ax
movw %ax, 0x6(%r12)
andl $0x0, (%r12)
andw $0x0, 0x4(%r12)
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x436c
movq %rax, %rbx
movq (%r13,%r15,8), %rdx
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0x456e
testl %eax, %eax
jne 0x2b2d
movq %rbx, %rdi
callq 0x2040
incq %r15
jmp 0x28b1
leaq 0xdcf5(%rip), %rdi      # 0x1060c
callq 0x2f03
orl 0xdcf6(%rip), %eax      # 0x10618
je 0x2941
callq 0x2090
cmpl $0x0, (%rax)
je 0x2a00
movq %rax, %rbx
leaq 0x7754(%rip), %rdi      # 0xa090
jmp 0x2a2d
andl $0x0, 0xdcc4(%rip)      # 0x1060c
andl $0x0, 0xdcc9(%rip)      # 0x10618
movq $0x2710, 0xdcb6(%rip) # imm = 0x2710
xorl %r15d, %r15d
leaq 0x22d(%rip), %rbp       # 0x2b91
cmpq $0x2710, %r15           # imm = 0x2710
je 0x29bc
movl %r15d, %eax
rolw $0x8, %ax
movw %ax, 0x6(%r12)
andl $0x0, (%r12)
andw $0x0, 0x4(%r12)
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x436c
movq %rax, %rbx
movq (%r13,%r15,8), %rcx
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %rbp, %rdx
callq 0x4c76
testl %eax, %eax
jne 0x29ea
movq %rbx, %rdi
callq 0x2040
incq %r15
jmp 0x2964
leaq 0xdc49(%rip), %rdi      # 0x1060c
callq 0x2f03
orl 0xdc4a(%rip), %eax      # 0x10618
je 0x2a0c
callq 0x2090
cmpl $0x0, (%rax)
je 0x2b16
movq %rax, %rbx
leaq 0x7733(%rip), %rdi      # 0xa11b
jmp 0x2a2d
callq 0x2090
cmpl $0x0, (%rax)
je 0x2a3c
movq %rax, %rbx
leaq 0x7703(%rip), %rdi      # 0xa101
jmp 0x2a2d
leaq 0x7689(%rip), %rdi      # 0xa090
jmp 0x2b26
cmpb $0x0, 0xdc09(%rip)      # 0x1061c
je 0x2a48
callq 0x2090
cmpl $0x0, (%rax)
je 0x2b1f
movq %rax, %rbx
leaq 0x7701(%rip), %rdi      # 0xa12e
xorl %eax, %eax
callq 0x4059
andl $0x0, (%rbx)
jmp 0x2b2d
leaq 0x76be(%rip), %rdi      # 0xa101
jmp 0x2b26
xorl %ebx, %ebx
cmpq $0x2710, %rbx           # imm = 0x2710
je 0x2a62
movq (%r13,%rbx,8), %rdi
callq 0x2040
incq %rbx
jmp 0x2a4a
movq %r13, %rdi
callq 0x2040
andq $0x0, (%r12)
movq %r14, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x436c
movq %rax, %r13
movabsq $0x1027000000000000, %rax # imm = 0x1027000000000000
movq %rax, (%r12)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x436c
movq %rax, %rbx
andl $0x0, 0xdb67(%rip)      # 0x1060c
movq $0x1, 0xdb60(%rip) # 0x10610
leaq 0x157(%rip), %rcx       # 0x2c0e
leaq 0x8a(%rip), %r8         # 0x2b48
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movq %rax, %rdx
movq %rdi, %r9
callq 0x5284
testl %eax, %eax
jne 0x2b2d
movq %rbx, %rdi
callq 0x2040
movq %r13, %rdi
callq 0x2040
leaq 0xdb20(%rip), %rdi      # 0x1060c
callq 0x2f03
movl %eax, %ecx
xorl %eax, %eax
orl 0xdb1d(%rip), %ecx      # 0x10618
je 0x2b30
callq 0x2090
cmpl $0x0, (%rax)
je 0x2b3f
movq %rax, %rbx
leaq 0x7638(%rip), %rdi      # 0xa149
jmp 0x2a2d
leaq 0x75fe(%rip), %rdi      # 0xa11b
jmp 0x2b26
leaq 0x7608(%rip), %rdi      # 0xa12e
xorl %eax, %eax
callq 0x41e8
pushq $-0x1
popq %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7603(%rip), %rdi      # 0xa149
jmp 0x2b26