// File: /workspace/github_c_makefile_star2_O0/canboat[P]canboat/ip/iptee.c
// Function: storeNewClient
int storeNewClient(int i, int sockfd)
{
  char portstr[10];

  client[i].socklen = sizeof(client[i].sockaddr);
  if (getpeername(sockfd, &client[i].sockaddr.any, &client[i].socklen))
  {
    logError("Unknown incoming client\n");
    close(sockfd);
    return 0;
  }

  if (client[i].host)
  {
    free(client[i].host);
    client[i].host = 0;
  }
  if (client[i].port)
  {
    free(client[i].port);
    client[i].port = 0;
  }

  client[i].host = calloc(INET6_ADDRSTRLEN + 2, 1);
  if (client[i].sockaddr.any.sa_family == AF_INET)
  {
    inet_ntop(client[i].sockaddr.any.sa_family, &client[i].sockaddr.in.sin_addr, client[i].host, INET6_ADDRSTRLEN + 1);
    snprintf(portstr, sizeof(portstr), "%u", ntohs(client[i].sockaddr.in.sin_port));
    client[i].port = strdup(portstr);
  }
  else if (client[i].sockaddr.any.sa_family == AF_INET6)
  {
    inet_ntop(client[i].sockaddr.any.sa_family, &client[i].sockaddr.in6.sin6_addr, client[i].host, INET6_ADDRSTRLEN + 1);
    snprintf(portstr, sizeof(portstr), "%u", ntohs(client[i].sockaddr.in6.sin6_port));
    client[i].port = strdup(portstr);
  }
  else
  {
    logAbort("Unknown family %d\n", client[i].sockaddr.any.sa_family);
  }

  client[i].fd        = sockfd;
  client[i].ct        = ClientTCP;
  client[i].reconnect = false;

  logDebug("New TCP client socket %d addr %s port %s\n", sockfd, client[i].host, portstr);

  if (i >= clients)
  {
    clients = i + 1;
  }
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movslq -0x8(%rbp), %rcx
leaq 0x6b67(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movl $0x1c, 0x3c(%rax)
movl -0xc(%rbp), %edi
movslq -0x8(%rbp), %rax
leaq 0x6b4b(%rip), %rsi      # 0x9210
shlq $0x6, %rax
addq %rax, %rsi
addq $0x20, %rsi
movslq -0x8(%rbp), %rax
leaq 0x6b35(%rip), %rdx      # 0x9210
shlq $0x6, %rax
addq %rax, %rdx
addq $0x3c, %rdx
callq 0x20b0
cmpl $0x0, %eax
je 0x2712
leaq 0x395f(%rip), %rdi      # 0x6056
movb $0x0, %al
callq 0x3620
movl -0xc(%rbp), %edi
callq 0x2180
movl $0x0, -0x4(%rbp)
jmp 0x2a2e
movslq -0x8(%rbp), %rcx
leaq 0x6af3(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
cmpq $0x0, 0x10(%rax)
je 0x2760
movslq -0x8(%rbp), %rcx
leaq 0x6ada(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x2040
movslq -0x8(%rbp), %rcx
leaq 0x6abf(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movq $0x0, 0x10(%rax)
movslq -0x8(%rbp), %rcx
leaq 0x6aa5(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
cmpq $0x0, 0x18(%rax)
je 0x27ae
movslq -0x8(%rbp), %rcx
leaq 0x6a8c(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
callq 0x2040
movslq -0x8(%rbp), %rcx
leaq 0x6a71(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movq $0x0, 0x18(%rax)
movl $0x30, %edi
movl $0x1, %esi
callq 0x21a0
movq %rax, %rcx
movslq -0x8(%rbp), %rdx
leaq 0x6a45(%rip), %rax      # 0x9210
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movslq -0x8(%rbp), %rcx
leaq 0x6a2f(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movzwl 0x20(%rax), %eax
cmpl $0x2, %eax
jne 0x28a9
movslq -0x8(%rbp), %rcx
leaq 0x6a10(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movzwl 0x20(%rax), %edi
movslq -0x8(%rbp), %rax
leaq 0x69fa(%rip), %rsi      # 0x9210
shlq $0x6, %rax
addq %rax, %rsi
addq $0x20, %rsi
addq $0x4, %rsi
movslq -0x8(%rbp), %rcx
leaq 0x69e0(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movl $0x2f, %ecx
callq 0x2030
leaq -0x16(%rbp), %rax
movq %rax, -0x20(%rbp)
movslq -0x8(%rbp), %rcx
leaq 0x69b8(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movzwl 0x22(%rax), %edi
callq 0x2250
movq -0x20(%rbp), %rdi
movzwl %ax, %ecx
movl $0xa, %esi
leaq 0x37f4(%rip), %rdx      # 0x606f
movb $0x0, %al
callq 0x2100
leaq -0x16(%rbp), %rdi
callq 0x22e0
movq %rax, %rcx
movslq -0x8(%rbp), %rdx
leaq 0x6977(%rip), %rax      # 0x9210
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
jmp 0x299f
movslq -0x8(%rbp), %rcx
leaq 0x695c(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movzwl 0x20(%rax), %eax
cmpl $0xa, %eax
jne 0x2979
movslq -0x8(%rbp), %rcx
leaq 0x693d(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movzwl 0x20(%rax), %edi
movslq -0x8(%rbp), %rax
leaq 0x6927(%rip), %rsi      # 0x9210
shlq $0x6, %rax
addq %rax, %rsi
addq $0x20, %rsi
addq $0x8, %rsi
movslq -0x8(%rbp), %rcx
leaq 0x690d(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movl $0x2f, %ecx
callq 0x2030
leaq -0x16(%rbp), %rax
movq %rax, -0x28(%rbp)
movslq -0x8(%rbp), %rcx
leaq 0x68e5(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movzwl 0x22(%rax), %edi
callq 0x2250
movq -0x28(%rbp), %rdi
movzwl %ax, %ecx
movl $0xa, %esi
leaq 0x3721(%rip), %rdx      # 0x606f
movb $0x0, %al
callq 0x2100
leaq -0x16(%rbp), %rdi
callq 0x22e0
movq %rax, %rcx
movslq -0x8(%rbp), %rdx
leaq 0x68a4(%rip), %rax      # 0x9210
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
jmp 0x299d
movslq -0x8(%rbp), %rcx
leaq 0x688c(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movzwl 0x20(%rax), %esi
leaq 0x36dc(%rip), %rdi      # 0x6072
movb $0x0, %al
callq 0x36d0
jmp 0x299f
movl -0xc(%rbp), %ecx
movslq -0x8(%rbp), %rdx
leaq 0x6863(%rip), %rax      # 0x9210
shlq $0x6, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movslq -0x8(%rbp), %rcx
leaq 0x684f(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movl $0x1, 0x4(%rax)
movslq -0x8(%rbp), %rcx
leaq 0x6836(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movb $0x0, 0x8(%rax)
movl -0xc(%rbp), %esi
movslq -0x8(%rbp), %rcx
leaq 0x681d(%rip), %rax      # 0x9210
shlq $0x6, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
leaq -0x16(%rbp), %rcx
leaq 0x367c(%rip), %rdi      # 0x6085
movb $0x0, %al
callq 0x3570
movl -0x8(%rbp), %eax
cmpl 0xa7f7(%rip), %eax      # 0xd210
jl 0x2a27
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, 0xa7e9(%rip)      # 0xd210
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)