#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct sockaddr_storage {
  int dummy;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ from_addr_ss;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int get_uint16(unsigned char *);
int /*<<< orphan*/ memset(struct sockaddr_storage *, int /*<<< orphan*/, int);
int recvfrom(int, unsigned char *, int, int /*<<< orphan*/, struct sockaddr *,
             int *);
int /*<<< orphan*/ register_response(int, int);
int /*<<< orphan*/ stderr;
void process_single_response(int sockfd) {
  struct sockaddr_storage from_addr_ss;
  struct sockaddr *from_addr;
  static unsigned char in_buf[8192];
  int numbytes, resp_id;
  socklen_t addr_len;
  int flags;
  memset(&from_addr_ss, 0, sizeof(from_addr_ss));
  from_addr = (struct sockaddr *)&from_addr_ss;
  addr_len = sizeof(from_addr_ss);
  if ((numbytes = recvfrom(sockfd, in_buf, 8192, 0, from_addr, &addr_len)) ==
      -1) {
    fprintf(stderr, "Error receiving datagram\n");
    return;
  }
  resp_id = get_uint16(in_buf);
  flags = get_uint16(in_buf + 2);
  register_response(resp_id, flags & 0xF);
}


x86 assembly (clang, -O0):
<process_single_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x4,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%r8
lea    0x2ed8(%rip),%rsi
mov    $0x2000,%edx
xor    %ecx,%ecx
lea    -0x1c(%rbp),%r9
call   1060 <recvfrom@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    11be <process_single_response+0x6e>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11ee <process_single_response+0x9e>
lea    0x2e9b(%rip),%rdi
call   1070 <get_uint16@plt>
mov    %eax,-0x18(%rbp)
lea    0x2e8c(%rip),%rdi
add    $0x2,%rdi
call   1070 <get_uint16@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
and    $0xf,%esi
call   1040 <register_response@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_single_response>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
movl   $0x4,0xc(%rsp)
lea    0x2ee4(%rip),%rsi
lea    0xc(%rsp),%r9
mov    %ebx,%edi
mov    $0x2000,%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   1060 <recvfrom@plt>
cmp    $0xffffffff,%eax
je     11bf <process_single_response+0x6f>
lea    0x2ec2(%rip),%rdi
call   1070 <get_uint16@plt>
mov    %eax,%ebx
lea    0x2eb6(%rip),%rdi
call   1070 <get_uint16@plt>
and    $0xf,%eax
mov    %ebx,%edi
mov    %eax,%esi
call   1040 <register_response@plt>
jmp    11d4 <process_single_response+0x84>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@process_single_response.in_buf = internal global [8192 x i8] zeroinitializer
@stderr = global i32 0
@.str = [26 x i8] c"Error receiving datagram\0A\00"
define void @process_single_response(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.sockaddr_storage
%4 = alloca %struct.sockaddr*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %2
%9 = call i32 @memset(%struct.sockaddr_storage* %3, i32 0, i32 4)
%10 = bitcast %struct.sockaddr_storage* %3 to %struct.sockaddr*
store %struct.sockaddr* %10, %struct.sockaddr** %4
store i32 4, i32* %7
%11 = load i32, i32* %2
%12 = load %struct.sockaddr*, %struct.sockaddr** %4
%13 = call i32 @recvfrom(i32 %11, i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @process_single_response.in_buf, i64 0, i64 0), i32 8192, i32 0, %struct.sockaddr* %12, i32* %7)
store i32 %13, i32* %5
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %1
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %25
18: ; preds = %1
%19 = call i32 @get_uint16(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @process_single_response.in_buf, i64 0, i64 0))
store i32 %19, i32* %6
%20 = call i32 @get_uint16(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @process_single_response.in_buf, i64 0, i64 2))
store i32 %20, i32* %8
%21 = load i32, i32* %6
%22 = load i32, i32* %8
%23 = and i32 %22, 15
%24 = call i32 @register_response(i32 %21, i32 %23)
br label %25
25: ; preds = %18, %15
ret void
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@process_single_response.in_buf = internal global [8192 x i8] zeroinitializer
@stderr = global i32 0
@.str = [26 x i8] c"Error receiving datagram\0A\00"
define void @process_single_response(i32 %0) {
%2 = alloca %struct.sockaddr_storage
%3 = alloca i32
%4 = bitcast %struct.sockaddr_storage* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = call i32 @memset(%struct.sockaddr_storage* %2, i32 0, i32 4)
%7 = bitcast %struct.sockaddr_storage* %2 to %struct.sockaddr*
store i32 4, i32* %3
%8 = call i32 @recvfrom(i32 %0, i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @process_single_response.in_buf, i64 0, i64 0), i32 8192, i32 0, %struct.sockaddr* %7, i32* %3)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %18
13: ; preds = %1
%14 = call i32 @get_uint16(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @process_single_response.in_buf, i64 0, i64 0))
%15 = call i32 @get_uint16(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @process_single_response.in_buf, i64 0, i64 2))
%16 = and i32 %15, 15
%17 = call i32 @register_response(i32 %14, i32 %16)
br label %18
18: ; preds = %13, %10
ret void
}