#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 sock_fprog {
  int len;
  struct sock_filter *filter;
};
struct sock_filter {
  int member_0;
  int member_1;
  int member_2;
  int member_3;
};
typedef int /*<<< orphan*/ filter;
typedef int /*<<< orphan*/ BPF_code;

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_ATTACH_FILTER;
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, struct sock_fprog *,
               int);
int attach_stun_response_filter(int sock_fd) {
  struct sock_fprog filter;
  struct sock_filter BPF_code[] = {
      {0x30, 0, 0, 0x00000010}, {0x35, 10, 0, 0x000000e0},
      {0x28, 0, 0, 0x00000006}, {0x45, 8, 0, 0x00001fff},
      {0xb1, 0, 0, 0x00000000}, {0x50, 0, 0, 0x00000008},
      {0x15, 0, 5, 0x00000001}, {0x48, 0, 0, 0x0000000a},
      {0x45, 3, 0, 0x00000003}, {0x40, 0, 0, 0x0000000c},
      {0x15, 0, 1, 0x2112a442}, {0x6, 0, 0, 0x000005ea},
      {0x6, 0, 0, 0x00000000},
  };
  filter.len = sizeof(BPF_code) / sizeof(BPF_code[0]);
  filter.filter = BPF_code;
  return setsockopt(sock_fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter,
                    sizeof(filter));
}


x86 assembly (clang, -O0):
<attach_stun_response_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0xf0(%rbp),%rdi
lea    0xec4(%rip),%rsi
mov    $0xd0,%edx
call   1040 <memcpy@plt>
movl   $0xd,-0x18(%rbp)
lea    -0xf0(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e86(%rip),%rax
mov    (%rax),%esi
mov    0x2e75(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<attach_stun_response_filter>:
push   %r14
push   %rbx
sub    $0xe8,%rsp
mov    %edi,%ebx
lea    0xecd(%rip),%rsi
lea    0x10(%rsp),%r14
mov    $0xd0,%edx
mov    %r14,%rdi
call   1040 <memcpy@plt>
movl   $0xd,(%rsp)
mov    %r14,0x8(%rsp)
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
mov    0x2e7f(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
add    $0xe8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sock_filter = type { i32, i32, i32, i32 }
%struct.sock_fprog = type { i32, %struct.sock_filter* }
@__const.attach_stun_response_filter.BPF_code = [13 x %struct.sock_filter] [%struct.sock_filter { i32 48, i32 0, i32 0, i32 16 }, %struct.sock_filter { i32 53, i32 10, i32 0, i32 224 }, %struct.sock_filter { i32 40, i32 0, i32 0, i32 6 }, %struct.sock_filter { i32 69, i32 8, i32 0, i32 8191 }, %struct.sock_filter { i32 177, i32 0, i32 0, i32 0 }, %struct.sock_filter { i32 80, i32 0, i32 0, i32 8 }, %struct.sock_filter { i32 21, i32 0, i32 5, i32 1 }, %struct.sock_filter { i32 72, i32 0, i32 0, i32 10 }, %struct.sock_filter { i32 69, i32 3, i32 0, i32 3 }, %struct.sock_filter { i32 64, i32 0, i32 0, i32 12 }, %struct.sock_filter { i32 21, i32 0, i32 1, i32 554869826 }, %struct.sock_filter { i32 6, i32 0, i32 0, i32 1514 }, %struct.sock_filter { i32 6, i32 0, i32 0, i32 0 }]
@SOL_SOCKET = global i32 0
@SO_ATTACH_FILTER = global i32 0
define i32 @attach_stun_response_filter(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.sock_fprog
%4 = alloca [13 x %struct.sock_filter]
store i32 %0, i32* %2
%5 = bitcast [13 x %struct.sock_filter]* %4 to i8*
%6 = getelementptr inbounds %struct.sock_fprog, %struct.sock_fprog* %3, i32 0, i32 0
store i32 13, i32* %6
%7 = getelementptr inbounds [13 x %struct.sock_filter], [13 x %struct.sock_filter]* %4, i64 0, i64 0
%8 = getelementptr inbounds %struct.sock_fprog, %struct.sock_fprog* %3, i32 0, i32 1
store %struct.sock_filter* %7, %struct.sock_filter** %8
%9 = load i32, i32* %2
%10 = load i32, i32* @SOL_SOCKET
%11 = load i32, i32* @SO_ATTACH_FILTER
%12 = call i32 @setsockopt(i32 %9, i32 %10, i32 %11, %struct.sock_fprog* %3, i32 16)
ret i32 %12
}

LLVM IR (-O2):
%struct.sock_filter = type { i32, i32, i32, i32 }
%struct.sock_fprog = type { i32, %struct.sock_filter* }
@__const.attach_stun_response_filter.BPF_code = [13 x %struct.sock_filter] [%struct.sock_filter { i32 48, i32 0, i32 0, i32 16 }, %struct.sock_filter { i32 53, i32 10, i32 0, i32 224 }, %struct.sock_filter { i32 40, i32 0, i32 0, i32 6 }, %struct.sock_filter { i32 69, i32 8, i32 0, i32 8191 }, %struct.sock_filter { i32 177, i32 0, i32 0, i32 0 }, %struct.sock_filter { i32 80, i32 0, i32 0, i32 8 }, %struct.sock_filter { i32 21, i32 0, i32 5, i32 1 }, %struct.sock_filter { i32 72, i32 0, i32 0, i32 10 }, %struct.sock_filter { i32 69, i32 3, i32 0, i32 3 }, %struct.sock_filter { i32 64, i32 0, i32 0, i32 12 }, %struct.sock_filter { i32 21, i32 0, i32 1, i32 554869826 }, %struct.sock_filter { i32 6, i32 0, i32 0, i32 1514 }, %struct.sock_filter { i32 6, i32 0, i32 0, i32 0 }]
@SOL_SOCKET = global i32 0
@SO_ATTACH_FILTER = global i32 0
define i32 @attach_stun_response_filter(i32 %0) {
%2 = alloca %struct.sock_fprog
%3 = alloca [13 x %struct.sock_filter]
%4 = bitcast %struct.sock_fprog* %2 to i8*
%5 = bitcast [13 x %struct.sock_filter]* %3 to i8*
%6 = getelementptr inbounds %struct.sock_fprog, %struct.sock_fprog* %2, i64 0, i32 0
store i32 13, i32* %6
%7 = getelementptr inbounds [13 x %struct.sock_filter], [13 x %struct.sock_filter]* %3, i64 0, i64 0
%8 = getelementptr inbounds %struct.sock_fprog, %struct.sock_fprog* %2, i64 0, i32 1
store %struct.sock_filter* %7, %struct.sock_filter** %8
%9 = load i32, i32* @SOL_SOCKET
%10 = load i32, i32* @SO_ATTACH_FILTER
%11 = call i32 @setsockopt(i32 %0, i32 %9, i32 %10, %struct.sock_fprog* %2, i32 16)
ret i32 %11
}