#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*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ generate_isapnp_events(int);
int /*<<< orphan*/ generate_pci_events(int);
int /*<<< orphan*/ generate_usb_events(int);
int init_netlink_socket(int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[], char **environ) {
  int netlink_socket;
  netlink_socket = init_netlink_socket(1);
  if (netlink_socket == -1) {
    fprintf(stderr,
            "[%s]: "
            "Unable to open netlink socket."
            "\n",
            "netlink init");
    ;
    return 1;
  }
  generate_pci_events(netlink_socket);
  generate_usb_events(netlink_socket);
  generate_isapnp_events(netlink_socket);
  close(netlink_socket);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x1,%edi
call   1070 <init_netlink_socket@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    11b9 <main+0x59>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
lea    0xe5f(%rip),%rsi
lea    0xe7e(%rip),%rdx
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e0 <main+0x80>
mov    -0x1c(%rbp),%edi
call   1030 <generate_pci_events@plt>
mov    -0x1c(%rbp),%edi
call   1080 <generate_usb_events@plt>
mov    -0x1c(%rbp),%edi
call   1060 <generate_isapnp_events@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebx
mov    $0x1,%edi
call   1070 <init_netlink_socket@plt>
cmp    $0xffffffff,%eax
je     1199 <main+0x39>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <generate_pci_events@plt>
mov    %ebp,%edi
call   1080 <generate_usb_events@plt>
mov    %ebp,%edi
call   1060 <generate_isapnp_events@plt>
mov    %ebp,%edi
call   1040 <close@plt>
xor    %ebx,%ebx
jmp    11b5 <main+0x55>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
lea    0xe76(%rip),%rdx
call   1050 <fprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"[%s]: Unable to open netlink socket.\0A\00"
@.str.1 = [13 x i8] c"netlink init\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = call i32 @init_netlink_socket(i32 1)
store i32 %9, i32* %8
%10 = load i32, i32* %8
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %4
br label %24
15: ; preds = %3
%16 = load i32, i32* %8
%17 = call i32 @generate_pci_events(i32 %16)
%18 = load i32, i32* %8
%19 = call i32 @generate_usb_events(i32 %18)
%20 = load i32, i32* %8
%21 = call i32 @generate_isapnp_events(i32 %20)
%22 = load i32, i32* %8
%23 = call i32 @close(i32 %22)
store i32 0, i32* %4
br label %24
24: ; preds = %15, %12
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"[%s]: Unable to open netlink socket.\0A\00"
@.str.1 = [13 x i8] c"netlink init\00"
define i32 @main(i32 %0, i8** nocapture readnone %1, i8** nocapture readnone %2) {
%4 = tail call i32 @init_netlink_socket(i32 1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %14
9: ; preds = %3
%10 = tail call i32 @generate_pci_events(i32 %4)
%11 = tail call i32 @generate_usb_events(i32 %4)
%12 = tail call i32 @generate_isapnp_events(i32 %4)
%13 = tail call i32 @close(i32 %4)
br label %14
14: ; preds = %9, %6
%15 = phi i32 [ 1, %6 ], [ 0, %9 ]
ret i32 %15
}