#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 size_t uint32_t;

/* Variables and functions */
int /*<<< orphan*/ analyze_zone(char const *, size_t *, size_t, int);
int /*<<< orphan*/ powercap_sysfs_zone_exists(char const *, size_t *, size_t);
void analyze_all_zones_recurse(const char *control_type, uint32_t *zones,
                               uint32_t depth, uint32_t max_depth,
                               int verbose) {
  if (!powercap_sysfs_zone_exists(control_type, zones, depth)) {
    analyze_zone(control_type, zones, depth, verbose);
    if (depth < max_depth) {
      zones[depth] = 0;
      analyze_all_zones_recurse(control_type, zones, depth + 1, max_depth,
                                verbose);
    }
    zones[depth - 1]++;
    analyze_all_zones_recurse(control_type, zones, depth, max_depth, verbose);
  }
}


x86 assembly (clang, -O0):
<analyze_all_zones_recurse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <powercap_sysfs_zone_exists@plt>
cmp    $0x0,%eax
jne    11e6 <analyze_all_zones_recurse+0xb6>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1050 <analyze_zone@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11b5 <analyze_all_zones_recurse+0x85>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    $0x1,%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1030 <analyze_all_zones_recurse@plt>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,8),%rdx
add    $0x1,%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1030 <analyze_all_zones_recurse@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<analyze_all_zones_recurse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r12
call   1040 <powercap_sysfs_zone_exists@plt>
test   %eax,%eax
je     1162 <analyze_all_zones_recurse+0x32>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x1(%rbp),%r13
jmp    1188 <analyze_all_zones_recurse+0x58>
nopl   0x0(%rax,%rax,1)
addq   $0x1,-0x8(%rbx,%rbp,8)
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1040 <powercap_sysfs_zone_exists@plt>
test   %eax,%eax
jne    1153 <analyze_all_zones_recurse+0x23>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r14d,%ecx
call   1050 <analyze_zone@plt>
cmp    %r15,%rbp
jae    1170 <analyze_all_zones_recurse+0x40>
movq   $0x0,(%rbx,%rbp,8)
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r14d,%r8d
call   1030 <analyze_all_zones_recurse@plt>
jmp    1170 <analyze_all_zones_recurse+0x40>

LLVM IR (-O0):
define void @analyze_all_zones_recurse(i8* %0, i64* %1, i64 %2, i64 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
store i8* %0, i8** %6
store i64* %1, i64** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i32 %4, i32* %10
%11 = load i8*, i8** %6
%12 = load i64*, i64** %7
%13 = load i64, i64* %8
%14 = call i32 @powercap_sysfs_zone_exists(i8* %11, i64* %12, i64 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %47, label %16
16: ; preds = %5
%17 = load i8*, i8** %6
%18 = load i64*, i64** %7
%19 = load i64, i64* %8
%20 = load i32, i32* %10
%21 = call i32 @analyze_zone(i8* %17, i64* %18, i64 %19, i32 %20)
%22 = load i64, i64* %8
%23 = load i64, i64* %9
%24 = icmp ult i64 %22, %23
br i1 %24, label %25, label %35
25: ; preds = %16
%26 = load i64*, i64** %7
%27 = load i64, i64* %8
%28 = getelementptr inbounds i64, i64* %26, i64 %27
store i64 0, i64* %28
%29 = load i8*, i8** %6
%30 = load i64*, i64** %7
%31 = load i64, i64* %8
%32 = add i64 %31, 1
%33 = load i64, i64* %9
%34 = load i32, i32* %10
br label %35
35: ; preds = %25, %16
%36 = load i64*, i64** %7
%37 = load i64, i64* %8
%38 = sub i64 %37, 1
%39 = getelementptr inbounds i64, i64* %36, i64 %38
%40 = load i64, i64* %39
%41 = add i64 %40, 1
store i64 %41, i64* %39
%42 = load i8*, i8** %6
%43 = load i64*, i64** %7
%44 = load i64, i64* %8
%45 = load i64, i64* %9
%46 = load i32, i32* %10
br label %47
47: ; preds = %35, %5
ret void
}

LLVM IR (-O2):
define void @analyze_all_zones_recurse(i8* %0, i64* %1, i64 %2, i64 %3, i32 %4) {
%6 = tail call i32 @powercap_sysfs_zone_exists(i8* %0, i64* %1, i64 %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = icmp ult i64 %2, %3
%10 = getelementptr inbounds i64, i64* %1, i64 %2
%11 = add nuw i64 %2, 1
%12 = add i64 %2, -1
%13 = getelementptr inbounds i64, i64* %1, i64 %12
br label %14
14: ; preds = %8, %17
%15 = tail call i32 @analyze_zone(i8* %0, i64* %1, i64 %2, i32 %4)
br i1 %9, label %16, label %17
16: ; preds = %14
store i64 0, i64* %10
tail call void @analyze_all_zones_recurse(i8* %0, i64* %1, i64 %11, i64 %3, i32 %4)
br label %17
17: ; preds = %16, %14
%18 = load i64, i64* %13
%19 = add i64 %18, 1
store i64 %19, i64* %13
%20 = tail call i32 @powercap_sysfs_zone_exists(i8* %0, i64* %1, i64 %2)
%21 = icmp eq i32 %20, 0
br i1 %21, label %14, label %22
22: ; preds = %17, %5
ret void
}