// File: /workspace/github_c_makefile_star2_O0/kieselsteini[P]PiXL-old/pixl.c
// Function: f_recv
static int f_recv(lua_State *L) {
  struct sockaddr_in sin;
  int datalen = 1024 * 4;
  socklen_t sinlen;
  luaL_Buffer buffer;
  char *data;
  struct timeval tv;
  fd_set set;
  // check socket for data
  net_create_socket(L);
  FD_ZERO(&set); FD_SET(socket_fd, &set);
  tv.tv_sec = 0; tv.tv_usec = 0;
  if (select(socket_fd + 1, &set, NULL, NULL, &tv) <= 0) return 0;
  if (!FD_ISSET(socket_fd, &set)) return 0;
  // reset addr
  SDL_zero(sin);
  sin.sin_family = AF_INET;
  sin.sin_port = 0;
  sin.sin_addr.s_addr = INADDR_ANY;
  sinlen = sizeof(sin);
  // receive
  data = luaL_buffinitsize(L, &buffer, datalen);
  datalen = recvfrom(socket_fd, data, datalen, 0, (struct sockaddr*)&sin, &sinlen);
  if (datalen < 0) return 0;
  luaL_pushresultsize(&buffer, datalen);
  lua_pushinteger(L, ntohl(sin.sin_addr.s_addr));
  lua_pushinteger(L, ntohs(sin.sin_port));
  return 3;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2110, %rsp           # imm = 0x2110
movq %rdi, -0x10(%rbp)
movl $0x1000, -0x24(%rbp)    # imm = 0x1000
movq -0x10(%rbp), %rdi
callq 0x52220
leaq -0x20e0(%rbp), %rax
movq %rax, -0x20f0(%rbp)
movl $0x0, -0x20e4(%rbp)
movl -0x20e4(%rbp), %eax
cmpq $0x10, %rax
jae 0x51b09
movq -0x20f0(%rbp), %rax
movl -0x20e4(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x20e4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20e4(%rbp)
jmp 0x51ad7
jmp 0x51b0b
movl 0x11304b(%rip), %eax    # 0x164b5c
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movl 0x11302e(%rip), %eax    # 0x164b5c
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x20e0(%rbp,%rax,8), %rcx
movq %rcx, -0x20e0(%rbp,%rax,8)
movq $0x0, -0x2060(%rbp)
movq $0x0, -0x2058(%rbp)
movl 0x112ff8(%rip), %edi    # 0x164b5c
addl $0x1, %edi
leaq -0x20e0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x2060(%rbp), %r8
movq %rcx, %rdx
callq 0x64b0
cmpl $0x0, %eax
jg 0x51b92
movl $0x0, -0x4(%rbp)
jmp 0x51cbe
movl 0x112fc4(%rip), %eax    # 0x164b5c
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x20e0(%rbp,%rax,8), %rax
movq %rax, -0x20f8(%rbp)
movl 0x112fa5(%rip), %eax    # 0x164b5c
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x20f8(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0x51be8
movl $0x0, -0x4(%rbp)
jmp 0x51cbe
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x6240
movw $0x2, -0x20(%rbp)
movw $0x0, -0x1e(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x10, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x24(%rbp), %rdx
leaq -0x2048(%rbp), %rsi
callq 0xf7c0
movq %rax, -0x2050(%rbp)
movl 0x112f29(%rip), %edi    # 0x164b5c
movq -0x2050(%rbp), %rsi
movslq -0x24(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x20(%rbp), %r8
leaq -0x28(%rbp), %r9
callq 0x63b0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0x51c5f
movl $0x0, -0x4(%rbp)
jmp 0x51cbe
movslq -0x24(%rbp), %rsi
leaq -0x2048(%rbp), %rdi
callq 0xf690
movq -0x10(%rbp), %rax
movq %rax, -0x2108(%rbp)
movl -0x1c(%rbp), %edi
callq 0x6600
movq -0x2108(%rbp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0x8e00
movq -0x10(%rbp), %rax
movq %rax, -0x2100(%rbp)
movzwl -0x1e(%rbp), %edi
callq 0x6810
movq -0x2100(%rbp), %rdi
movzwl %ax, %eax
movl %eax, %esi
callq 0x8e00
movl $0x3, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2110, %rsp           # imm = 0x2110
popq %rbp
retq
nopw (%rax,%rax)