#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 */
unsigned int count_cpus();
scalar_t__ cpufreq_cpu_exists(unsigned int);
int /*<<< orphan*/ debug_output_one(unsigned int);
void debug_output(unsigned int cpu, unsigned int all) {
  if (all) {
    unsigned int nr_cpus = count_cpus();
    for (cpu = 0; cpu < nr_cpus; cpu++) {
      if (cpufreq_cpu_exists(cpu))
        continue;
      debug_output_one(cpu);
    }
  } else
    debug_output_one(cpu);
}


x86 assembly (clang, -O0):
<debug_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1197 <debug_output+0x67>
mov    $0x0,%al
call   1040 <count_cpus@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1192 <debug_output+0x62>
mov    -0x4(%rbp),%edi
call   1030 <cpufreq_cpu_exists@plt>
cmp    $0x0,%rax
je     117c <debug_output+0x4c>
jmp    1184 <debug_output+0x54>
mov    -0x4(%rbp),%edi
call   1050 <debug_output_one@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1159 <debug_output+0x29>
jmp    119f <debug_output+0x6f>
mov    -0x4(%rbp),%edi
call   1050 <debug_output_one@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_output>:
test   %esi,%esi
je     1173 <debug_output+0x43>
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <count_cpus@plt>
test   %eax,%eax
je     116c <debug_output+0x3c>
mov    %eax,%ebp
jmp    1157 <debug_output+0x27>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %ebx,%ebp
je     116c <debug_output+0x3c>
mov    %ebx,%edi
call   1030 <cpufreq_cpu_exists@plt>
test   %rax,%rax
jne    1150 <debug_output+0x20>
mov    %ebx,%edi
call   1050 <debug_output_one@plt>
jmp    1150 <debug_output+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
jmp    1050 <debug_output_one@plt>

LLVM IR (-O0):
define void @debug_output(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %2
%9 = call i32 (...) @count_cpus()
store i32 %9, i32* %5
store i32 0, i32* %3
br label %10
10: ; preds = %22, %8
%11 = load i32, i32* %3
%12 = load i32, i32* %5
%13 = icmp ult i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load i32, i32* %3
%16 = call i64 @cpufreq_cpu_exists(i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
br label %22
19: ; preds = %14
%20 = load i32, i32* %3
%21 = call i32 @debug_output_one(i32 %20)
br label %22
22: ; preds = %19, %18
%23 = load i32, i32* %3
%24 = add i32 %23, 1
store i32 %24, i32* %3
br label %10
25: ; preds = %10
br label %29
26: ; preds = %2
%27 = load i32, i32* %3
%28 = call i32 @debug_output_one(i32 %27)
br label %29
29: ; preds = %26, %25
ret void
}

LLVM IR (-O2):
define void @debug_output(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %16, label %4
4: ; preds = %2
%5 = tail call i32 (...) @count_cpus()
%6 = icmp eq i32 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %4, %13
%8 = phi i32 [ %14, %13 ], [ 0, %4 ]
%9 = tail call i64 @cpufreq_cpu_exists(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @debug_output_one(i32 %8)
br label %13
13: ; preds = %7, %11
%14 = add nuw i32 %8, 1
%15 = icmp eq i32 %14, %5
br i1 %15, label %18, label %7
16: ; preds = %2
%17 = tail call i32 @debug_output_one(i32 %0)
br label %18
18: ; preds = %13, %4, %16
ret void
}