#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 nlmsg {
  int dummy;
};
struct nl_handle {
  int dummy;
};
struct ifinfomsg {
  int dummy;
};

/* Variables and functions */
int ENOMEM;
int /*<<< orphan*/ NLM_F_DUMP;
int nl_exchange(struct nl_handle *, struct nlmsg *, struct nlmsg **);
int /*<<< orphan*/ nlmsg_free(struct nlmsg *);
struct nlmsg *rtnlmsg_new(int, int, int /*<<< orphan*/, int);
int rtnl_ifi_dump(struct nl_handle *hnd, int type, int family,
                  struct nlmsg **dest) {
  struct nlmsg *req;
  int err;
  req = rtnlmsg_new(type, family, NLM_F_DUMP, sizeof(struct ifinfomsg));
  if (!req)
    return ENOMEM;
  err = nl_exchange(hnd, req, dest);
  nlmsg_free(req);
  return err;
}


x86 assembly (clang, -O0):
<rtnl_ifi_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    0x2e95(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%ecx
call   1040 <rtnlmsg_new@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117f <rtnl_ifi_dump+0x4f>
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <rtnl_ifi_dump+0x72>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <nl_exchange@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <nlmsg_free@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtnl_ifi_dump>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdi,%r15
mov    0x2ea4(%rip),%rax
mov    (%rax),%eax
mov    %esi,%edi
mov    %edx,%esi
mov    %eax,%edx
mov    $0x4,%ecx
call   1040 <rtnlmsg_new@plt>
test   %rax,%rax
je     117a <rtnl_ifi_dump+0x4a>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1030 <nl_exchange@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <nlmsg_free@plt>
mov    %ebp,%eax
jmp    1183 <rtnl_ifi_dump+0x53>
mov    0x2e57(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.nl_handle = type { i32 }
%struct.nlmsg = type { i32 }
@NLM_F_DUMP = global i32 0
@ENOMEM = global i32 0
define i32 @rtnl_ifi_dump(%struct.nl_handle* %0, i32 %1, i32 %2, %struct.nlmsg** %3) {
%5 = alloca i32
%6 = alloca %struct.nl_handle*
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.nlmsg**
%10 = alloca %struct.nlmsg*
%11 = alloca i32
store %struct.nl_handle* %0, %struct.nl_handle** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store %struct.nlmsg** %3, %struct.nlmsg*** %9
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = load i32, i32* @NLM_F_DUMP
%15 = call %struct.nlmsg* @rtnlmsg_new(i32 %12, i32 %13, i32 %14, i32 4)
store %struct.nlmsg* %15, %struct.nlmsg** %10
%16 = load %struct.nlmsg*, %struct.nlmsg** %10
%17 = icmp ne %struct.nlmsg* %16, null
br i1 %17, label %20, label %18
18: ; preds = %4
%19 = load i32, i32* @ENOMEM
store i32 %19, i32* %5
br label %28
20: ; preds = %4
%21 = load %struct.nl_handle*, %struct.nl_handle** %6
%22 = load %struct.nlmsg*, %struct.nlmsg** %10
%23 = load %struct.nlmsg**, %struct.nlmsg*** %9
%24 = call i32 @nl_exchange(%struct.nl_handle* %21, %struct.nlmsg* %22, %struct.nlmsg** %23)
store i32 %24, i32* %11
%25 = load %struct.nlmsg*, %struct.nlmsg** %10
%26 = call i32 @nlmsg_free(%struct.nlmsg* %25)
%27 = load i32, i32* %11
store i32 %27, i32* %5
br label %28
28: ; preds = %20, %18
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
%struct.nl_handle = type { i32 }
%struct.nlmsg = type { i32 }
@NLM_F_DUMP = global i32 0
@ENOMEM = global i32 0
define i32 @rtnl_ifi_dump(%struct.nl_handle* %0, i32 %1, i32 %2, %struct.nlmsg** %3) {
%5 = load i32, i32* @NLM_F_DUMP
%6 = tail call %struct.nlmsg* @rtnlmsg_new(i32 %1, i32 %2, i32 %5, i32 4)
%7 = icmp eq %struct.nlmsg* %6, null
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = load i32, i32* @ENOMEM
br label %13
10: ; preds = %4
%11 = tail call i32 @nl_exchange(%struct.nl_handle* %0, %struct.nlmsg* %6, %struct.nlmsg** %3)
%12 = tail call i32 @nlmsg_free(%struct.nlmsg* %6)
br label %13
13: ; preds = %10, %8
%14 = phi i32 [ %11, %10 ], [ %9, %8 ]
ret i32 %14
}