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

/* Variables and functions */
int /*<<< orphan*/ analyze_zone(scalar_t__, scalar_t__, int, int);
int /*<<< orphan*/ print_headers(scalar_t__, int, int /*<<< orphan*/,
                                 int /*<<< orphan*/);
int /*<<< orphan*/ rapl_sysfs_zone_exists(scalar_t__, scalar_t__, int);
void analyze_zone_recurse(uint32_t zone, int verbose) {
  uint32_t sz;
  print_headers(zone, 1, 0, 0);
  analyze_zone(zone, 0, 0, verbose);
  for (sz = 0; !rapl_sysfs_zone_exists(zone, sz, 1); sz++) {
    analyze_zone(zone, sz, 1, verbose);
  }
}


x86 assembly (clang, -O0):
<analyze_zone_recurse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1040 <print_headers@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <analyze_zone@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x1,%edx
call   1030 <rapl_sysfs_zone_exists@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1192 <analyze_zone_recurse+0x62>
jmp    11b8 <analyze_zone_recurse+0x88>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
call   1050 <analyze_zone@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116b <analyze_zone_recurse+0x3b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<analyze_zone_recurse>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
mov    $0x1,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <print_headers@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %r14d,%ecx
call   1050 <analyze_zone@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <rapl_sysfs_zone_exists@plt>
test   %eax,%eax
jne    119b <analyze_zone_recurse+0x6b>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
mov    %r14d,%ecx
call   1050 <analyze_zone@plt>
add    $0x1,%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <rapl_sysfs_zone_exists@plt>
test   %eax,%eax
je     1170 <analyze_zone_recurse+0x40>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @analyze_zone_recurse(i64 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i64
store i64 %0, i64* %3
store i32 %1, i32* %4
%6 = load i64, i64* %3
%7 = call i32 @print_headers(i64 %6, i32 1, i32 0, i32 0)
%8 = load i64, i64* %3
%9 = load i32, i32* %4
%10 = call i32 @analyze_zone(i64 %8, i64 0, i32 0, i32 %9)
store i64 0, i64* %5
br label %11
11: ; preds = %22, %2
%12 = load i64, i64* %3
%13 = load i64, i64* %5
%14 = call i32 @rapl_sysfs_zone_exists(i64 %12, i64 %13, i32 1)
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
br i1 %16, label %17, label %25
17: ; preds = %11
%18 = load i64, i64* %3
%19 = load i64, i64* %5
%20 = load i32, i32* %4
%21 = call i32 @analyze_zone(i64 %18, i64 %19, i32 1, i32 %20)
br label %22
22: ; preds = %17
%23 = load i64, i64* %5
%24 = add nsw i64 %23, 1
store i64 %24, i64* %5
br label %11
25: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @analyze_zone_recurse(i64 %0, i32 %1) {
%3 = tail call i32 @print_headers(i64 %0, i32 1, i32 0, i32 0)
%4 = tail call i32 @analyze_zone(i64 %0, i64 0, i32 0, i32 %1)
%5 = tail call i32 @rapl_sysfs_zone_exists(i64 %0, i64 0, i32 1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %2, %7
%8 = phi i64 [ %10, %7 ], [ 0, %2 ]
%9 = tail call i32 @analyze_zone(i64 %0, i64 %8, i32 1, i32 %1)
%10 = add nuw nsw i64 %8, 1
%11 = tail call i32 @rapl_sysfs_zone_exists(i64 %0, i64 %10, i32 1)
%12 = icmp eq i32 %11, 0
br i1 %12, label %7, label %13
13: ; preds = %7, %2
ret void
}