#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*/ fprintf(int /*<<< orphan*/, char *);
int get_online_cpu_from_cpuinfo();
int get_online_cpu_from_sysfs();
int set_affinity(int);
int /*<<< orphan*/ stderr;
int set_affinity_single(void) {
  int cpu;
  cpu = get_online_cpu_from_sysfs();
  if (cpu >= 0)
    goto set_affinity;
  cpu = get_online_cpu_from_cpuinfo();
  if (cpu >= 0)
    goto set_affinity;
  fprintf(stderr, "WARNING: Failed to detect online cpu, using cpu=0\n");
  cpu = 0;
set_affinity:
  return set_affinity(cpu);
}


x86 assembly (clang, -O0):
<set_affinity_single>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <get_online_cpu_from_sysfs@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1161 <set_affinity_single+0x21>
jmp    1196 <set_affinity_single+0x56>
mov    $0x0,%al
call   1030 <get_online_cpu_from_cpuinfo@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     117a <set_affinity_single+0x3a>
jmp    1196 <set_affinity_single+0x56>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <set_affinity@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_affinity_single>:
push   %rax
xor    %eax,%eax
call   1060 <get_online_cpu_from_sysfs@plt>
test   %eax,%eax
jns    116e <set_affinity_single+0x2e>
xor    %eax,%eax
call   1030 <get_online_cpu_from_cpuinfo@plt>
test   %eax,%eax
jns    116e <set_affinity_single+0x2e>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
pop    %rax
jmp    1050 <set_affinity@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [51 x i8] c"WARNING: Failed to detect online cpu, using cpu=0\0A\00"
define i32 @set_affinity_single() {
%1 = alloca i32
%2 = call i32 (...) @get_online_cpu_from_sysfs()
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = icmp sge i32 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
br label %14
6: ; preds = %0
%7 = call i32 (...) @get_online_cpu_from_cpuinfo()
store i32 %7, i32* %1
%8 = load i32, i32* %1
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %6
br label %14
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %14
14: ; preds = %11, %10, %5
%15 = load i32, i32* %1
%16 = call i32 @set_affinity(i32 %15)
ret i32 %16
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [51 x i8] c"WARNING: Failed to detect online cpu, using cpu=0\0A\00"
define i32 @set_affinity_single() {
%1 = tail call i32 (...) @get_online_cpu_from_sysfs()
%2 = icmp sgt i32 %1, -1
br i1 %2, label %9, label %3
3: ; preds = %0
%4 = tail call i32 (...) @get_online_cpu_from_cpuinfo()
%5 = icmp sgt i32 %4, -1
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %3, %0, %6
%10 = phi i32 [ %1, %0 ], [ %4, %3 ], [ 0, %6 ]
%11 = tail call i32 @set_affinity(i32 %10)
ret i32 %11
}