#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int get_cpu_count_from_file(char *);
int /*<<< orphan*/ stderr;
int get_cpu_count() {
  int cpu_count = get_cpu_count_from_file("/sys/devices/system/cpu/present");
  if (cpu_count != get_cpu_count_from_file("/sys/devices/system/cpu/online")) {
    {
      fprintf(stderr, "present cpus != online cpus\n");
      exit(EXIT_FAILURE);
    };
  }
  return cpu_count;
}


x86 assembly (clang, -O0):
<get_cpu_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <get_cpu_count_from_file@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xecc(%rip),%rdi
call   1030 <get_cpu_count_from_file@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
cmp    %ecx,%eax
je     1189 <get_cpu_count+0x59>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xec9(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cpu_count>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1030 <get_cpu_count_from_file@plt>
mov    %eax,%ebx
lea    0xeda(%rip),%rdi
call   1030 <get_cpu_count_from_file@plt>
cmp    %eax,%ebx
jne    1153 <get_cpu_count+0x23>
mov    %ebx,%eax
pop    %rbx
ret
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xedc(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"/sys/devices/system/cpu/present\00"
@.str.1 = [31 x i8] c"/sys/devices/system/cpu/online\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"present cpus != online cpus\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @get_cpu_count() {
%1 = alloca i32
%2 = call i32 @get_cpu_count_from_file(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = call i32 @get_cpu_count_from_file(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp ne i32 %3, %4
br i1 %5, label %6, label %11
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
@.str = [32 x i8] c"/sys/devices/system/cpu/present\00"
@.str.1 = [31 x i8] c"/sys/devices/system/cpu/online\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"present cpus != online cpus\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @get_cpu_count() {
%1 = tail call i32 @get_cpu_count_from_file(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @get_cpu_count_from_file(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32 %1, %2
br i1 %3, label %9, label %4
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %0
ret i32 %1
}