#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 inet_diag_bc_op {
  int yes;
  int no;
  int /*<<< orphan*/ code;
};

/* Variables and functions */
int /*<<< orphan*/ INET_DIAG_BC_D_LE;
void *calloc(unsigned char, int);
unsigned char create_filter(void **filter_mem) {
  struct inet_diag_bc_op *bc_op = NULL;
  unsigned char filter_len = sizeof(struct inet_diag_bc_op) * 2;
  if ((*filter_mem = calloc(filter_len, 1)) == NULL)
    return 0;
  bc_op = (struct inet_diag_bc_op *)*filter_mem;
  bc_op->code = INET_DIAG_BC_D_LE;
  bc_op->yes = sizeof(struct inet_diag_bc_op) * 2;
  bc_op->no = 12;
  bc_op = bc_op + 1;
  bc_op->no = 1000;
  return filter_len;
}


x86 assembly (clang, -O0):
<create_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movb   $0x18,-0x19(%rbp)
mov    $0x1,%esi
movzbl -0x19(%rbp),%edi
call   1030 <calloc@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    1150 <create_filter+0x40>
movb   $0x0,-0x1(%rbp)
jmp    119d <create_filter+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e7e(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x18(%rbp),%rax
movl   $0x18,(%rax)
mov    -0x18(%rbp),%rax
movl   $0xc,0x4(%rax)
mov    -0x18(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x3e8,0x4(%rax)
mov    -0x19(%rbp),%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_filter>:
push   %rbx
mov    %rdi,%rbx
mov    $0x18,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     114f <create_filter+0x3f>
mov    0x2eae(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x8(%rax)
movabs $0xc00000018,%rcx
mov    %rcx,(%rax)
movl   $0x3e8,0x10(%rax)
mov    $0x18,%al
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.inet_diag_bc_op = type { i32, i32, i32 }
@INET_DIAG_BC_D_LE = global i32 0
define zeroext i8 @create_filter(i8** %0) {
%2 = alloca i8
%3 = alloca i8**
%4 = alloca %struct.inet_diag_bc_op*
%5 = alloca i8
store i8** %0, i8*** %3
store %struct.inet_diag_bc_op* null, %struct.inet_diag_bc_op** %4
store i8 24, i8* %5
%6 = load i8, i8* %5
%7 = call i8* @calloc(i8 zeroext %6, i32 1)
%8 = load i8**, i8*** %3
store i8* %7, i8** %8
%9 = icmp eq i8* %7, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i8 0, i8* %2
br label %27
11: ; preds = %1
%12 = load i8**, i8*** %3
%13 = load i8*, i8** %12
%14 = bitcast i8* %13 to %struct.inet_diag_bc_op*
store %struct.inet_diag_bc_op* %14, %struct.inet_diag_bc_op** %4
%15 = load i32, i32* @INET_DIAG_BC_D_LE
%16 = load %struct.inet_diag_bc_op*, %struct.inet_diag_bc_op** %4
%17 = getelementptr inbounds %struct.inet_diag_bc_op, %struct.inet_diag_bc_op* %16, i32 0, i32 2
store i32 %15, i32* %17
%18 = load %struct.inet_diag_bc_op*, %struct.inet_diag_bc_op** %4
%19 = getelementptr inbounds %struct.inet_diag_bc_op, %struct.inet_diag_bc_op* %18, i32 0, i32 0
store i32 24, i32* %19
%20 = load %struct.inet_diag_bc_op*, %struct.inet_diag_bc_op** %4
%21 = getelementptr inbounds %struct.inet_diag_bc_op, %struct.inet_diag_bc_op* %20, i32 0, i32 1
store i32 12, i32* %21
%22 = load %struct.inet_diag_bc_op*, %struct.inet_diag_bc_op** %4
%23 = getelementptr inbounds %struct.inet_diag_bc_op, %struct.inet_diag_bc_op* %22, i64 1
store %struct.inet_diag_bc_op* %23, %struct.inet_diag_bc_op** %4
%24 = load %struct.inet_diag_bc_op*, %struct.inet_diag_bc_op** %4
%25 = getelementptr inbounds %struct.inet_diag_bc_op, %struct.inet_diag_bc_op* %24, i32 0, i32 1
store i32 1000, i32* %25
%26 = load i8, i8* %5
store i8 %26, i8* %2
br label %27
27: ; preds = %11, %10
%28 = load i8, i8* %2
ret i8 %28
}

LLVM IR (-O2):
%struct.inet_diag_bc_op = type { i32, i32, i32 }
@INET_DIAG_BC_D_LE = global i32 0
define zeroext i8 @create_filter(i8** nocapture writeonly %0) {
%2 = tail call i8* @calloc(i8 zeroext 24, i32 1)
store i8* %2, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = load i32, i32* @INET_DIAG_BC_D_LE
%6 = getelementptr inbounds i8, i8* %2, i64 8
%7 = bitcast i8* %6 to i32*
store i32 %5, i32* %7
%8 = bitcast i8* %2 to i32*
store i32 24, i32* %8
%9 = getelementptr inbounds i8, i8* %2, i64 4
%10 = bitcast i8* %9 to i32*
store i32 12, i32* %10
%11 = getelementptr inbounds i8, i8* %2, i64 16
%12 = bitcast i8* %11 to i32*
store i32 1000, i32* %12
br label %13
13: ; preds = %1, %4
%14 = phi i8 [ 24, %4 ], [ 0, %1 ]
ret i8 %14
}