// File: /workspace/github_c_makefile_star2_O2/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 0x676a
movq (%rsi), %rsi
leaq 0xa8bb(%rip), %rdi      # 0x11004
xorl %eax, %eax
callq 0x61b0
leaq 0xa921(%rip), %rdi      # 0x11078
callq 0x60c0
leaq 0xa8ba(%rip), %rdi      # 0x1101d
movl $0x270f, %esi           # imm = 0x270F
jmp 0x677c
movq 0x8(%rsi), %rbx
movq 0x10(%rsi), %rdi
callq 0x64e0
movq %rbx, %rdi
movl %eax, %esi
callq 0xe8b2
movq %rax, %rbx
testq %rax, %rax
je 0x69a2
movl $0x400, %edi            # imm = 0x400
callq 0x63a0
movq %rax, %r14
movl $0x400, %edi            # imm = 0x400
callq 0x63a0
movq %rax, %r15
leaq 0xa879(%rip), %rsi      # 0x11027
leaq 0xa876(%rip), %rdx      # 0x1102b
movq %r14, %rdi
callq 0xa7e4
movq %rbx, %rdi
movq %r14, %rsi
callq 0xea7f
testb %al, %al
pushq $0x74
popq %rax
pushq $0x66
popq %r12
movl %r12d, %esi
cmovnel %eax, %esi
leaq 0xa851(%rip), %r13      # 0x1102f
movq %r13, %rdi
xorl %eax, %eax
callq 0x61b0
leaq 0xa84a(%rip), %rsi      # 0x11039
leaq 0xa849(%rip), %rdx      # 0x1103f
movq %r14, %rdi
callq 0xa7e4
movq %rbx, %rdi
movq %r14, %rsi
callq 0xea7f
testb %al, %al
movl %r12d, %esi
pushq $0x74
popq %rax
cmovnel %eax, %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x61b0
leaq 0xa820(%rip), %rsi      # 0x11045
leaq 0xaf51(%rip), %rdx      # 0x1177d
movq %r14, %rdi
callq 0xa7e4
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r15, %r13
callq 0xe8df
testq %rax, %rax
movl %r12d, %esi
pushq $0x74
popq %r15
cmovnel %r15d, %esi
leaq 0xa7f4(%rip), %rdi      # 0x1104e
xorl %eax, %eax
callq 0x61b0
movq %rbx, %rdi
movq %r14, %rsi
callq 0xea58
testb %al, %al
movl %r12d, %esi
cmovnel %r15d, %esi
leaq 0xa7dc(%rip), %rdi      # 0x11058
xorl %eax, %eax
callq 0x61b0
movq %r14, %rdi
leaq 0xa7ac(%rip), %rsi      # 0x11039
leaq 0xaee9(%rip), %rdx      # 0x1177d
callq 0xa7e4
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r13, -0x30(%rbp)
callq 0xe8df
testq %rax, %rax
movl %r12d, %esi
cmovnel %r15d, %esi
leaq 0xa7a8(%rip), %rdi      # 0x11064
xorl %eax, %eax
callq 0x61b0
movq %r14, %rdi
leaq 0xa75a(%rip), %rsi      # 0x11027
leaq 0xaea9(%rip), %rdx      # 0x1177d
callq 0xa7e4
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xe8df
testq %rax, %rax
movl %r12d, %esi
cmovnel %r15d, %esi
leaq 0xa76c(%rip), %rdi      # 0x11064
xorl %eax, %eax
callq 0x61b0
movq %r14, %rdi
leaq 0xa71e(%rip), %rsi      # 0x11027
leaq 0xae6d(%rip), %rdx      # 0x1177d
movq %rdx, %r13
callq 0xa7e4
movq %rbx, %rdi
movq %r14, %rsi
callq 0xeaa6
testb %al, %al
movl %r12d, %esi
cmovnel %r15d, %esi
leaq 0xa73b(%rip), %rdi      # 0x1106e
xorl %eax, %eax
callq 0x61b0
movq %r14, %rdi
leaq 0xa6e3(%rip), %rsi      # 0x11027
movq %r13, %rdx
callq 0xa7e4
movq %rbx, %rdi
movq %r14, %rsi
movq -0x30(%rbp), %r15
movq %r15, %rdx
callq 0xe8df
testq %rax, %rax
pushq $0x74
popq %rax
cmovnel %eax, %r12d
leaq 0xa6df(%rip), %rdi      # 0x1104e
movl %r12d, %esi
xorl %eax, %eax
callq 0x61b0
movq %r14, %rdi
callq 0x6060
movq %r15, %rdi
callq 0x6060
movq %rbx, %rdi
callq 0xeb2f
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa6f3(%rip), %rdi      # 0x1109c
callq 0x60c0
xorl %edi, %edi
callq 0x6530
nopl (%rax)