#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 */
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
int intf_name(char const *, char *);
int intf_numa_node(char *);
int numa_node_to_cpusmask(int, int /*<<< orphan*/ *, int *);
int intf_best_cpus(const char *addr, uint64_t *cpusmask, int *nr) {
  char if_name[32];
  int numa_node, retval;
  retval = intf_name(addr, if_name);
  if (retval < 0)
    return -1;
  numa_node = intf_numa_node(if_name);
  if (numa_node < 0)
    return -1;
  retval = numa_node_to_cpusmask(numa_node, cpusmask, nr);
  return retval;
}


x86 assembly (clang, -O0):
<intf_best_cpus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <intf_name@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jge    116a <intf_best_cpus+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a5 <intf_best_cpus+0x75>
lea    -0x40(%rbp),%rdi
call   1040 <intf_numa_node@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    118c <intf_best_cpus+0x5c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a5 <intf_best_cpus+0x75>
mov    -0x44(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <numa_node_to_cpusmask@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intf_best_cpus>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rsp,%rsi
call   1030 <intf_name@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
js     116a <intf_best_cpus+0x3a>
mov    %rsp,%rdi
call   1040 <intf_numa_node@plt>
test   %eax,%eax
js     116a <intf_best_cpus+0x3a>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <numa_node_to_cpusmask@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @intf_best_cpus(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [32 x i8]
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%11 = load i8*, i8** %5
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%13 = call i32 @intf_name(i8* %11, i8* %12)
store i32 %13, i32* %10
%14 = load i32, i32* %10
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 -1, i32* %4
br label %29
17: ; preds = %3
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%19 = call i32 @intf_numa_node(i8* %18)
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 -1, i32* %4
br label %29
23: ; preds = %17
%24 = load i32, i32* %9
%25 = load i32*, i32** %6
%26 = load i32*, i32** %7
%27 = call i32 @numa_node_to_cpusmask(i32 %24, i32* %25, i32* %26)
store i32 %27, i32* %10
%28 = load i32, i32* %10
store i32 %28, i32* %4
br label %29
29: ; preds = %23, %22, %16
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
define i32 @intf_best_cpus(i8* %0, i32* %1, i32* %2) {
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%6 = call i32 @intf_name(i8* %0, i8* %5)
%7 = icmp slt i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = call i32 @intf_numa_node(i8* %5)
%10 = icmp slt i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i32 @numa_node_to_cpusmask(i32 %9, i32* %1, i32* %2)
br label %13
13: ; preds = %8, %3, %11
%14 = phi i32 [ %12, %11 ], [ -1, %3 ], [ -1, %8 ]
ret i32 %14
}