#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 */

/* Variables and functions */
int /*<<< orphan*/ NETLINK_ROUTE;
int /*<<< orphan*/ PF_NETLINK;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int rtnl_recv(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int rtnl_send_set_iff_down(int, int, char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int rtnl_set_iff_down(int ifindex, char *ifname) {
  int s;
  int rc;
  s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
  if (s < 0)
    return s;
  rc = rtnl_send_set_iff_down(s, ifindex, ifname);
  if (rc < 0)
    goto out;
  rc = rtnl_recv(s, NULL, NULL);
out:
  close(s);
  return rc;
}


x86 assembly (clang, -O0):
<rtnl_set_iff_down>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
call   1060 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1187 <rtnl_set_iff_down+0x47>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c8 <rtnl_set_iff_down+0x88>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <rtnl_send_set_iff_down@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11a8 <rtnl_set_iff_down+0x68>
jmp    11ba <rtnl_set_iff_down+0x7a>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1040 <rtnl_recv@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtnl_set_iff_down>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
mov    0x2e8f(%rip),%rax
mov    (%rax),%esi
mov    0x2e66(%rip),%rax
mov    (%rax),%edx
call   1060 <socket@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1195 <rtnl_set_iff_down+0x55>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14,%rdx
call   1050 <rtnl_send_set_iff_down@plt>
test   %eax,%eax
js     118a <rtnl_set_iff_down+0x4a>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <rtnl_recv@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <close@plt>
mov    %ebp,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@PF_NETLINK = global i32 0
@SOCK_DGRAM = global i32 0
@NETLINK_ROUTE = global i32 0
define i32 @rtnl_set_iff_down(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%8 = load i32, i32* @PF_NETLINK
%9 = load i32, i32* @SOCK_DGRAM
%10 = load i32, i32* @NETLINK_ROUTE
%11 = call i32 @socket(i32 %8, i32 %9, i32 %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = load i32, i32* %6
store i32 %15, i32* %3
br label %31
16: ; preds = %2
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = load i8*, i8** %5
%20 = call i32 @rtnl_send_set_iff_down(i32 %17, i32 %18, i8* %19)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %16
br label %27
24: ; preds = %16
%25 = load i32, i32* %6
%26 = call i32 @rtnl_recv(i32 %25, i32* null, i32* null)
store i32 %26, i32* %7
br label %27
27: ; preds = %24, %23
%28 = load i32, i32* %6
%29 = call i32 @close(i32 %28)
%30 = load i32, i32* %7
store i32 %30, i32* %3
br label %31
31: ; preds = %27, %14
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@PF_NETLINK = global i32 0
@SOCK_DGRAM = global i32 0
@NETLINK_ROUTE = global i32 0
define i32 @rtnl_set_iff_down(i32 %0, i8* %1) {
%3 = load i32, i32* @PF_NETLINK
%4 = load i32, i32* @SOCK_DGRAM
%5 = load i32, i32* @NETLINK_ROUTE
%6 = tail call i32 @socket(i32 %3, i32 %4, i32 %5)
%7 = icmp slt i32 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %2
%9 = tail call i32 @rtnl_send_set_iff_down(i32 %6, i32 %0, i8* %1)
%10 = icmp slt i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @rtnl_recv(i32 %6, i32* null, i32* null)
br label %13
13: ; preds = %8, %11
%14 = phi i32 [ %9, %8 ], [ %12, %11 ]
%15 = tail call i32 @close(i32 %6)
br label %16
16: ; preds = %2, %13
%17 = phi i32 [ %14, %13 ], [ %6, %2 ]
ret i32 %17
}