// File: /workspace/github_c_makefile_star2_O1/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, %r14
leaq 0x8(%rax), %rdi
movq %rdi, 0x8(%rsp)
callq 0x21f0
movq %rax, %r12
movq %rax, (%rsp)
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x21d0
movl $0x13880, %edi          # imm = 0x13880
callq 0x21f0
movq %rax, %r13
leaq 0x875e(%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 0x4704
movq %rax, (%r13,%r15,8)
incq %r15
cmpq $0x2710, %r15           # imm = 0x2710
jne 0x29a7
movl $0x0, 0xec37(%rip)      # 0x1161c
movq $0x2710, 0xec30(%rip) # imm = 0x2710
movq %r14, 0x18(%rsp)
addq %r14, %r12
xorl %r14d, %r14d
leaq 0x2b0(%rip), %rbx       # 0x2cb2
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %r14d, %eax
rolw $0x8, %ax
movw %ax, 0x6(%r12)
movl $0x0, (%r12)
movw $0x0, 0x4(%r12)
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x4704
movq %rax, %r15
movq (%r13,%r14,8), %rdx
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x4935
testl %eax, %eax
jne 0x2c98
movq %r15, %rdi
callq 0x2040
incq %r14
cmpq $0x2710, %r14           # imm = 0x2710
jne 0x2a07
leaq 0xebac(%rip), %rdi      # 0x1161c
callq 0x3095
orl 0xebad(%rip), %eax      # 0x11628
je 0x2a9a
callq 0x2090
cmpl $0x0, (%rax)
je 0x2b6a
movq %rax, %rbx
leaq 0x85fb(%rip), %rdi      # 0xb090
jmp 0x2b58
xorl %ebx, %ebx
movl %ebx, 0xeb7a(%rip)      # 0x1161c
movl %ebx, 0xeb80(%rip)      # 0x11628
movq $0x2710, 0xeb6d(%rip) # imm = 0x2710
movq 0x18(%rsp), %r14
movl %ebx, %eax
rolw $0x8, %ax
movw %ax, 0x6(%r12)
movl $0x0, (%r12)
movw $0x0, 0x4(%r12)
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x4704
movq %rax, %r15
movq (%r13,%rbx,8), %rcx
movq 0x10(%rsp), %rdi
movq %rax, %rsi
leaq 0x204(%rip), %rdx       # 0x2cfd
callq 0x525a
testl %eax, %eax
jne 0x2b44
movq %r15, %rdi
callq 0x2040
incq %rbx
cmpq $0x2710, %rbx           # imm = 0x2710
jne 0x2ab8
leaq 0xeaff(%rip), %rdi      # 0x1161c
callq 0x3095
orl 0xeb00(%rip), %eax      # 0x11628
je 0x2b76
callq 0x2090
cmpl $0x0, (%rax)
je 0x2c7c
movq %rax, %rbx
leaq 0x85d9(%rip), %rdi      # 0xb11b
jmp 0x2b58
callq 0x2090
cmpl $0x0, (%rax)
je 0x2b99
movq %rax, %rbx
leaq 0x85a9(%rip), %rdi      # 0xb101
xorl %eax, %eax
callq 0x44c0
movl $0x0, (%rbx)
jmp 0x2c93
leaq 0x851f(%rip), %rdi      # 0xb090
jmp 0x2c8c
cmpb $0x0, 0xeaaf(%rip)      # 0x1162c
je 0x2ba5
callq 0x2090
cmpl $0x0, (%rax)
je 0x2c85
movq %rax, %rbx
leaq 0x8597(%rip), %rdi      # 0xb12e
jmp 0x2b58
leaq 0x8561(%rip), %rdi      # 0xb101
jmp 0x2c8c
xorl %ebx, %ebx
movq (%r13,%rbx,8), %rdi
callq 0x2040
incq %rbx
cmpq $0x2710, %rbx           # imm = 0x2710
jne 0x2ba7
movq %r13, %rdi
callq 0x2040
movq (%rsp), %r12
movq $0x0, (%r12,%r14)
movq %r12, %rdi
movq %r14, %r15
movq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x4704
movq %rax, %rbx
movabsq $0x1027000000000000, %rax # imm = 0x1027000000000000
movq %rax, (%r12,%r15)
movq %r12, %rdi
movq %r14, %rsi
callq 0x4704
movq %rax, %r14
movl $0x0, 0xea0f(%rip)      # 0x1161c
movq $0x1, 0xea08(%rip) # 0x11620
leaq 0x15d(%rip), %rcx       # 0x2d7c
leaq 0x8c(%rip), %r8         # 0x2cb2
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
movq %rdi, %r9
callq 0x5935
testl %eax, %eax
jne 0x2c98
movq %r14, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
leaq 0xe9c8(%rip), %rdi      # 0x1161c
callq 0x3095
xorl %ebp, %ebp
orl 0xe9c7(%rip), %eax      # 0x11628
je 0x2c98
callq 0x2090
cmpl $0x0, (%rax)
je 0x2ca9
movq %rax, %rbx
leaq 0x84d2(%rip), %rdi      # 0xb149
jmp 0x2b58
leaq 0x8498(%rip), %rdi      # 0xb11b
jmp 0x2c8c
leaq 0x84a2(%rip), %rdi      # 0xb12e
xorl %eax, %eax
callq 0x45df
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 0x8499(%rip), %rdi      # 0xb149
jmp 0x2c8c