#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 */
struct pqos_cpuinfo {
  int dummy;
};

/* Variables and functions */
unsigned int __get_num_sockets(struct pqos_cpuinfo const *);
int pqos_cpu_get_num_sockets(const struct pqos_cpuinfo *cpu, unsigned *count) {
  ;
  ;
  if (cpu == NULL || count == NULL)
    return 2;
  *count = __get_num_sockets(cpu);
  if (*count == 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<pqos_cpu_get_num_sockets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1136 <pqos_cpu_get_num_sockets+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1142 <pqos_cpu_get_num_sockets+0x32>
movl   $0x2,-0x4(%rbp)
jmp    1173 <pqos_cpu_get_num_sockets+0x63>
mov    -0x10(%rbp),%rdi
call   1030 <__get_num_sockets@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    116c <pqos_cpu_get_num_sockets+0x5c>
movl   $0x1,-0x4(%rbp)
jmp    1173 <pqos_cpu_get_num_sockets+0x63>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pqos_cpu_get_num_sockets>:
push   %rbx
mov    $0x2,%eax
test   %rdi,%rdi
je     1133 <pqos_cpu_get_num_sockets+0x23>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1133 <pqos_cpu_get_num_sockets+0x23>
call   1030 <__get_num_sockets@plt>
mov    %eax,%ecx
mov    %eax,(%rbx)
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
%struct.pqos_cpuinfo = type { i32 }
define i32 @pqos_cpu_get_num_sockets(%struct.pqos_cpuinfo* %0, i32* %1) {
%3 = alloca i32
%4 = alloca %struct.pqos_cpuinfo*
%5 = alloca i32*
store %struct.pqos_cpuinfo* %0, %struct.pqos_cpuinfo** %4
store i32* %1, i32** %5
%6 = load %struct.pqos_cpuinfo*, %struct.pqos_cpuinfo** %4
%7 = icmp eq %struct.pqos_cpuinfo* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32*, i32** %5
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %8, %2
store i32 2, i32* %3
br label %21
12: ; preds = %8
%13 = load %struct.pqos_cpuinfo*, %struct.pqos_cpuinfo** %4
%14 = call i32 @__get_num_sockets(%struct.pqos_cpuinfo* %13)
%15 = load i32*, i32** %5
store i32 %14, i32* %15
%16 = load i32*, i32** %5
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %12
store i32 1, i32* %3
br label %21
20: ; preds = %12
store i32 0, i32* %3
br label %21
21: ; preds = %20, %19, %11
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
%struct.pqos_cpuinfo = type { i32 }
define i32 @pqos_cpu_get_num_sockets(%struct.pqos_cpuinfo* %0, i32* writeonly %1) {
%3 = icmp eq %struct.pqos_cpuinfo* %0, null
%4 = icmp eq i32* %1, null
%5 = or i1 %3, %4
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = tail call i32 @__get_num_sockets(%struct.pqos_cpuinfo* %0)
store i32 %7, i32* %1
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
br label %10
10: ; preds = %6, %2
%11 = phi i32 [ 2, %2 ], [ %9, %6 ]
ret i32 %11
}