#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 rtgenmsg {
  int dummy;
};
struct nlmsghdr {
  int nlmsg_len;
  int nlmsg_type;
  int nlmsg_flags;
};
typedef int /*<<< orphan*/ req;

/* Variables and functions */
int NLM_F_DUMP;
int NLM_F_REQUEST;
int /*<<< orphan*/ send(int, void *, int, int /*<<< orphan*/);
void send_netlink_request(int sock, int type) {
  struct {
    struct nlmsghdr nlh;
    struct rtgenmsg msg;
  } req;
  req.nlh.nlmsg_len = sizeof(req);
  req.nlh.nlmsg_type = type;
  req.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST;
  send(sock, (void *)&req, sizeof(req), 0);
}


x86 assembly (clang, -O0):
<send_netlink_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x10,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    0x2eae(%rip),%rax
mov    (%rax),%eax
mov    0x2ead(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x10,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_netlink_request>:
sub    $0x18,%rsp
movl   $0x10,0x8(%rsp)
mov    %esi,0xc(%rsp)
mov    0x2eb9(%rip),%rax
mov    0x2eba(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    %ecx,0x10(%rsp)
lea    0x8(%rsp),%rsi
mov    $0x10,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.anon = type { %struct.nlmsghdr, %struct.rtgenmsg }
%struct.nlmsghdr = type { i32, i32, i32 }
%struct.rtgenmsg = type { i32 }
@NLM_F_DUMP = global i32 0
@NLM_F_REQUEST = global i32 0
define void @send_netlink_request(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.anon
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
%7 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %6, i32 0, i32 0
store i32 16, i32* %7
%8 = load i32, i32* %4
%9 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
%10 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %9, i32 0, i32 1
store i32 %8, i32* %10
%11 = load i32, i32* @NLM_F_DUMP
%12 = load i32, i32* @NLM_F_REQUEST
%13 = or i32 %11, %12
%14 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 0
%15 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %14, i32 0, i32 2
store i32 %13, i32* %15
%16 = load i32, i32* %3
%17 = bitcast %struct.anon* %5 to i8*
%18 = call i32 @send(i32 %16, i8* %17, i32 16, i32 0)
ret void
}

LLVM IR (-O2):
%struct.anon = type { %struct.nlmsghdr, %struct.rtgenmsg }
%struct.nlmsghdr = type { i32, i32, i32 }
%struct.rtgenmsg = type { i32 }
@NLM_F_DUMP = global i32 0
@NLM_F_REQUEST = global i32 0
define void @send_netlink_request(i32 %0, i32 %1) {
%3 = alloca %struct.anon
%4 = bitcast %struct.anon* %3 to i8*
%5 = getelementptr inbounds %struct.anon, %struct.anon* %3, i64 0, i32 0, i32 0
store i32 16, i32* %5
%6 = getelementptr inbounds %struct.anon, %struct.anon* %3, i64 0, i32 0, i32 1
store i32 %1, i32* %6
%7 = load i32, i32* @NLM_F_DUMP
%8 = load i32, i32* @NLM_F_REQUEST
%9 = or i32 %8, %7
%10 = getelementptr inbounds %struct.anon, %struct.anon* %3, i64 0, i32 0, i32 2
store i32 %9, i32* %10
%11 = call i32 @send(i32 %0, i8* %4, i32 16, i32 0)
ret void
}