#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_all_zones_recurse(char const *, size_t *, size_t,
                                             size_t, int);
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_zone_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);
    }
  }
}


x86 assembly (clang, -O0):
<analyze_zone_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    11ba <analyze_zone_recurse+0x8a>
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_zone_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>
jmp    11ba <analyze_zone_recurse+0x8a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<analyze_zone_recurse>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
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
jne    118e <analyze_zone_recurse+0x5e>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r14d,%ecx
call   1050 <analyze_zone@plt>
cmp    %r15,%rbp
jae    118e <analyze_zone_recurse+0x5e>
movq   $0x0,(%rbx,%rbp,8)
add    $0x1,%rbp
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r15,%rcx
mov    %r14d,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <analyze_all_zones_recurse@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @analyze_zone_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 %37, 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 %36
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
%35 = call i32 @analyze_all_zones_recurse(i8* %29, i64* %30, i64 %32, i64 %33, i32 %34)
br label %36
36: ; preds = %25, %16
br label %37
37: ; preds = %36, %5
ret void
}

LLVM IR (-O2):
define void @analyze_zone_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 %15
8: ; preds = %5
%9 = tail call i32 @analyze_zone(i8* %0, i64* %1, i64 %2, i32 %4)
%10 = icmp ult i64 %2, %3
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = getelementptr inbounds i64, i64* %1, i64 %2
store i64 0, i64* %12
%13 = add nuw i64 %2, 1
%14 = tail call i32 @analyze_all_zones_recurse(i8* %0, i64* %1, i64 %13, i64 %3, i32 %4)
br label %15
15: ; preds = %8, %11, %5
ret void
}