// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/kvclient.c
// Function: main
int
main(int argc, char ** argv)
{
  struct tcpmap * map = NULL;
  if (argc < 3) {
    printf("Usage: %s <host> <port>\n", argv[0]);
    printf("Use default setting: localhost 9999\n");
    map = tcpmap_create("localhost", 9999);
  } else {
    map = tcpmap_create(argv[1], atoi(argv[2]));
  }

  if (map == NULL) {
    printf("failed\n");
    exit(0);
  }

  struct kv * const kv = malloc(1024);
  struct kv * const out = malloc(1024);

  kv_refill_str(kv, "abc", "123");
  printf("set %c/t\n", tcpmap_set(map, kv) ? 't': 'f');

  kv_refill_str(kv, "hello", "45678");
  printf("set %c/t\n", tcpmap_set(map, kv) ? 't': 'f');

  kv_refill_str(kv, "notthere", "");
  printf("get %c/f\n", tcpmap_get(map, kv, out) ? 't':'f');
  printf("probe %c/f\n", tcpmap_probe(map, kv) ? 't':'f');

  kv_refill_str(kv, "hello", "");
  printf("get %c/t\n", tcpmap_get(map, kv, out) ? 't':'f');

  kv_refill_str(kv, "abc", "");
  printf("get %c/t\n", tcpmap_get(map, kv, out) ? 't':'f');

  kv_refill_str(kv, "abc", "");
  printf("del %c/t\n", tcpmap_del(map, kv) ? 't':'f');

  kv_refill_str(kv, "abc", "");
  printf("get %c/f\n", tcpmap_get(map, kv, out) ? 't':'f');
  free(kv);
  free(out);

  tcpmap_destroy(map);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x2, %edi
jg 0x6e3a
movq (%rsi), %rsi
leaq 0xd1eb(%rip), %rdi      # 0x14004
xorl %eax, %eax
callq 0x61b0
leaq 0xd251(%rip), %rdi      # 0x14078
callq 0x60c0
leaq 0xd1ea(%rip), %rdi      # 0x1401d
movl $0x270f, %esi           # imm = 0x270F
jmp 0x6e4c
movq 0x8(%rsi), %rbx
movq 0x10(%rsi), %rdi
callq 0x64e0
movq %rbx, %rdi
movl %eax, %esi
callq 0x10f89
movq %rax, %rbx
testq %rax, %rax
je 0x7081
movl $0x400, %edi            # imm = 0x400
callq 0x63a0
movq %rax, %r14
movl $0x400, %edi            # imm = 0x400
callq 0x63a0
movq %rax, %r15
leaq 0xd1a9(%rip), %rsi      # 0x14027
leaq 0xd1a6(%rip), %rdx      # 0x1402b
movq %r14, %rdi
callq 0xb628
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11170
testb %al, %al
movl $0x74, %eax
movl $0x66, %esi
cmovnel %eax, %esi
movl $0x74, %r12d
leaq 0xd17b(%rip), %r13      # 0x1402f
movq %r13, %rdi
xorl %eax, %eax
callq 0x61b0
leaq 0xd174(%rip), %rsi      # 0x14039
leaq 0xd173(%rip), %rdx      # 0x1403f
movq %r14, %rdi
callq 0xb628
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11170
testb %al, %al
movl $0x66, %esi
cmovnel %r12d, %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x61b0
leaq 0xd14a(%rip), %rsi      # 0x14045
leaq 0xd86f(%rip), %r13      # 0x14771
movq %r14, %rdi
movq %r13, %rdx
callq 0xb628
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r15, %r12
callq 0x10fb8
testq %rax, %rax
movl $0x66, %esi
movl $0x74, %eax
cmovnel %eax, %esi
movl $0x74, %r15d
leaq 0xd113(%rip), %rdi      # 0x1404e
xorl %eax, %eax
callq 0x61b0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11147
testb %al, %al
movl $0x66, %esi
cmovnel %r15d, %esi
leaq 0xd0f9(%rip), %rdi      # 0x14058
xorl %eax, %eax
callq 0x61b0
movq %r14, %rdi
leaq 0xd0c9(%rip), %rsi      # 0x14039
movq %r13, %rdx
movq %r13, %r15
callq 0xb628
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x10fb8
testq %rax, %rax
movl $0x66, %esi
movl $0x74, %eax
cmovnel %eax, %esi
leaq 0xd0c4(%rip), %rdi      # 0x14064
xorl %eax, %eax
callq 0x61b0
movq %r14, %rdi
leaq 0xd076(%rip), %r13      # 0x14027
movq %r13, %rsi
movq %r15, %rdx
callq 0xb628
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x10fb8
testq %rax, %rax
movl $0x66, %esi
movl $0x74, %eax
cmovnel %eax, %esi
leaq 0xd083(%rip), %rdi      # 0x14064
xorl %eax, %eax
callq 0x61b0
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xb628
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11199
testb %al, %al
movl $0x66, %esi
movl $0x74, %eax
cmovnel %eax, %esi
leaq 0xd057(%rip), %rdi      # 0x1406e
xorl %eax, %eax
callq 0x61b0
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xb628
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x10fb8
testq %rax, %rax
movl $0x66, %esi
movl $0x74, %eax
cmovnel %eax, %esi
leaq 0xcffd(%rip), %rdi      # 0x1404e
xorl %eax, %eax
callq 0x61b0
movq %r14, %rdi
callq 0x6060
movq %r12, %rdi
callq 0x6060
movq %rbx, %rdi
callq 0x1122c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd014(%rip), %rdi      # 0x1409c
callq 0x60c0
xorl %edi, %edi
callq 0x6530