#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 int /*<<< orphan*/ uint64_t;
typedef scalar_t__ uint32_t;
typedef scalar_t__ ssize_t;
typedef int /*<<< orphan*/ name;

/* Variables and functions */
int /*<<< orphan*/ analyze_constraint(char const *, scalar_t__ const *,
                                      scalar_t__, scalar_t__, int);
int /*<<< orphan*/ powercap_sysfs_constraint_exists(char const *,
                                                    scalar_t__ const *,
                                                    scalar_t__, scalar_t__);
int powercap_sysfs_zone_get_enabled(char const *, scalar_t__ const *,
                                    scalar_t__, scalar_t__ *);
int powercap_sysfs_zone_get_energy_uj(char const *, scalar_t__ const *,
                                      scalar_t__, int /*<<< orphan*/ *);
int powercap_sysfs_zone_get_max_energy_range_uj(char const *,
                                                scalar_t__ const *, scalar_t__,
                                                int /*<<< orphan*/ *);
int powercap_sysfs_zone_get_max_power_range_uw(char const *, scalar_t__ const *,
                                               scalar_t__,
                                               int /*<<< orphan*/ *);
scalar_t__ powercap_sysfs_zone_get_name(char const *, scalar_t__ const *,
                                        scalar_t__, char *, int);
int powercap_sysfs_zone_get_power_uw(char const *, scalar_t__ const *,
                                     scalar_t__, int /*<<< orphan*/ *);
int /*<<< orphan*/ print_parent_headers(scalar_t__ const *, scalar_t__,
                                        scalar_t__);
int /*<<< orphan*/ str_or_verbose(int, scalar_t__, char *, char *, int);
int /*<<< orphan*/ u64_or_verbose(int, scalar_t__, char *, int /*<<< orphan*/,
                                  int);
void analyze_zone(const char *control_type, const uint32_t *zones,
                  uint32_t depth, int verbose) {
  char name[1024];
  uint64_t val64;
  uint32_t val32;
  ssize_t sret;
  int ret;
  print_parent_headers(zones, depth, depth);
  sret = powercap_sysfs_zone_get_name(control_type, zones, depth, name,
                                      sizeof(name));
  ret = sret > 0 ? 0 : (int)sret;
  str_or_verbose(verbose, depth, "name", name, ret);
  ret = powercap_sysfs_zone_get_enabled(control_type, zones, depth, &val32);
  u64_or_verbose(verbose, depth, "enabled", (uint64_t)val32, ret);
  ret = powercap_sysfs_zone_get_max_energy_range_uj(control_type, zones, depth,
                                                    &val64);
  u64_or_verbose(verbose, depth, "max_energy_range_uj", val64, ret);
  ret = powercap_sysfs_zone_get_energy_uj(control_type, zones, depth, &val64);
  u64_or_verbose(verbose, depth, "energy_uj", val64, ret);
  ret = powercap_sysfs_zone_get_max_power_range_uw(control_type, zones, depth,
                                                   &val64);
  u64_or_verbose(verbose, depth, "max_power_range_uw", val64, ret);
  ret = powercap_sysfs_zone_get_power_uw(control_type, zones, depth, &val64);
  u64_or_verbose(verbose, depth, "power_uw", val64, ret);
  for (val32 = 0;
       !powercap_sysfs_constraint_exists(control_type, zones, depth, val32);
       val32++) {
    analyze_constraint(control_type, zones, depth, val32, verbose);
  }
}


x86 assembly (clang, -O0):
<analyze_zone>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <print_parent_headers@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x420(%rbp),%rcx
mov    $0x400,%r8d
call   1080 <powercap_sysfs_zone_get_name@plt>
mov    %rax,-0x438(%rbp)
cmpq   $0x0,-0x438(%rbp)
jle    121b <analyze_zone+0x6b>
xor    %eax,%eax
mov    %eax,-0x440(%rbp)
jmp    1228 <analyze_zone+0x78>
mov    -0x438(%rbp),%rax
mov    %eax,-0x440(%rbp)
mov    -0x440(%rbp),%eax
mov    %eax,-0x43c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    -0x420(%rbp),%rcx
mov    -0x43c(%rbp),%r8d
lea    0xdb0(%rip),%rdx
call   10a0 <str_or_verbose@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x430(%rbp),%rcx
call   1090 <powercap_sysfs_zone_get_enabled@plt>
mov    %eax,-0x43c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x430(%rbp),%rax
mov    %eax,%ecx
mov    -0x43c(%rbp),%r8d
lea    0xd74(%rip),%rdx
call   1040 <u64_or_verbose@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x424(%rbp),%rcx
call   10d0 <powercap_sysfs_zone_get_max_energy_range_uj@plt>
mov    %eax,-0x43c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x424(%rbp),%ecx
mov    -0x43c(%rbp),%r8d
lea    0xd3e(%rip),%rdx
call   1040 <u64_or_verbose@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x424(%rbp),%rcx
call   1070 <powercap_sysfs_zone_get_energy_uj@plt>
mov    %eax,-0x43c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x424(%rbp),%ecx
mov    -0x43c(%rbp),%r8d
lea    0xd14(%rip),%rdx
call   1040 <u64_or_verbose@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x424(%rbp),%rcx
call   10b0 <powercap_sysfs_zone_get_max_power_range_uw@plt>
mov    %eax,-0x43c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x424(%rbp),%ecx
mov    -0x43c(%rbp),%r8d
lea    0xce0(%rip),%rdx
call   1040 <u64_or_verbose@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x424(%rbp),%rcx
call   1060 <powercap_sysfs_zone_get_power_uw@plt>
mov    %eax,-0x43c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x424(%rbp),%ecx
mov    -0x43c(%rbp),%r8d
lea    0xcb5(%rip),%rdx
call   1040 <u64_or_verbose@plt>
movq   $0x0,-0x430(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x430(%rbp),%rcx
call   1030 <powercap_sysfs_constraint_exists@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    13c6 <analyze_zone+0x216>
jmp    13f9 <analyze_zone+0x249>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x430(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
call   10c0 <analyze_constraint@plt>
mov    -0x430(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x430(%rbp)
jmp    1399 <analyze_zone+0x1e9>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<analyze_zone>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x410,%rsp
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r15
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1050 <print_parent_headers@plt>
lea    0x10(%rsp),%r12
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    $0x400,%r8d
call   1080 <powercap_sysfs_zone_get_name@plt>
mov    %rax,%rcx
sar    $0x3f,%rcx
and    %ecx,%eax
lea    0xdfe(%rip),%rdx
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r12,%rcx
mov    %eax,%r8d
call   10a0 <str_or_verbose@plt>
lea    0x8(%rsp),%rcx
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1090 <powercap_sysfs_zone_get_enabled@plt>
mov    0x8(%rsp),%ecx
lea    0xdd4(%rip),%rdx
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%r8d
call   1040 <u64_or_verbose@plt>
lea    0x4(%rsp),%r12
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   10d0 <powercap_sysfs_zone_get_max_energy_range_uj@plt>
mov    0x4(%rsp),%ecx
lea    0xdad(%rip),%rdx
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%r8d
call   1040 <u64_or_verbose@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1070 <powercap_sysfs_zone_get_energy_uj@plt>
mov    0x4(%rsp),%ecx
lea    0xd97(%rip),%rdx
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%r8d
call   1040 <u64_or_verbose@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   10b0 <powercap_sysfs_zone_get_max_power_range_uw@plt>
mov    0x4(%rsp),%ecx
lea    0xd77(%rip),%rdx
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%r8d
call   1040 <u64_or_verbose@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1060 <powercap_sysfs_zone_get_power_uw@plt>
mov    0x4(%rsp),%ecx
lea    0xd60(%rip),%rdx
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%r8d
call   1040 <u64_or_verbose@plt>
movq   $0x0,0x8(%rsp)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1030 <powercap_sysfs_constraint_exists@plt>
test   %eax,%eax
jne    1338 <analyze_zone+0x188>
mov    0x8(%rsp),%rcx
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r14d,%r8d
call   10c0 <analyze_constraint@plt>
mov    0x8(%rsp),%rcx
add    $0x1,%rcx
mov    %rcx,0x8(%rsp)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
jmp    1300 <analyze_zone+0x150>
add    $0x410,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"name\00"
@.str.1 = [8 x i8] c"enabled\00"
@.str.2 = [20 x i8] c"max_energy_range_uj\00"
@.str.3 = [10 x i8] c"energy_uj\00"
@.str.4 = [19 x i8] c"max_power_range_uw\00"
@.str.5 = [9 x i8] c"power_uw\00"
define void @analyze_zone(i8* %0, i64* %1, i64 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i64
%8 = alloca i32
%9 = alloca [1024 x i8]
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
store i8* %0, i8** %5
store i64* %1, i64** %6
store i64 %2, i64* %7
store i32 %3, i32* %8
%14 = load i64*, i64** %6
%15 = load i64, i64* %7
%16 = load i64, i64* %7
%17 = call i32 @print_parent_headers(i64* %14, i64 %15, i64 %16)
%18 = load i8*, i8** %5
%19 = load i64*, i64** %6
%20 = load i64, i64* %7
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%22 = call i64 @powercap_sysfs_zone_get_name(i8* %18, i64* %19, i64 %20, i8* %21, i32 1024)
store i64 %22, i64* %12
%23 = load i64, i64* %12
%24 = icmp sgt i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %4
br label %29
26: ; preds = %4
%27 = load i64, i64* %12
%28 = trunc i64 %27 to i32
br label %29
29: ; preds = %26, %25
%30 = phi i32 [ 0, %25 ], [ %28, %26 ]
store i32 %30, i32* %13
%31 = load i32, i32* %8
%32 = load i64, i64* %7
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%34 = load i32, i32* %13
%35 = call i32 @str_or_verbose(i32 %31, i64 %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %33, i32 %34)
%36 = load i8*, i8** %5
%37 = load i64*, i64** %6
%38 = load i64, i64* %7
%39 = call i32 @powercap_sysfs_zone_get_enabled(i8* %36, i64* %37, i64 %38, i64* %11)
store i32 %39, i32* %13
%40 = load i32, i32* %8
%41 = load i64, i64* %7
%42 = load i64, i64* %11
%43 = trunc i64 %42 to i32
%44 = load i32, i32* %13
%45 = call i32 @u64_or_verbose(i32 %40, i64 %41, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %43, i32 %44)
%46 = load i8*, i8** %5
%47 = load i64*, i64** %6
%48 = load i64, i64* %7
%49 = call i32 @powercap_sysfs_zone_get_max_energy_range_uj(i8* %46, i64* %47, i64 %48, i32* %10)
store i32 %49, i32* %13
%50 = load i32, i32* %8
%51 = load i64, i64* %7
%52 = load i32, i32* %10
%53 = load i32, i32* %13
%54 = call i32 @u64_or_verbose(i32 %50, i64 %51, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %52, i32 %53)
%55 = load i8*, i8** %5
%56 = load i64*, i64** %6
%57 = load i64, i64* %7
%58 = call i32 @powercap_sysfs_zone_get_energy_uj(i8* %55, i64* %56, i64 %57, i32* %10)
store i32 %58, i32* %13
%59 = load i32, i32* %8
%60 = load i64, i64* %7
%61 = load i32, i32* %10
%62 = load i32, i32* %13
%63 = call i32 @u64_or_verbose(i32 %59, i64 %60, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %61, i32 %62)
%64 = load i8*, i8** %5
%65 = load i64*, i64** %6
%66 = load i64, i64* %7
%67 = call i32 @powercap_sysfs_zone_get_max_power_range_uw(i8* %64, i64* %65, i64 %66, i32* %10)
store i32 %67, i32* %13
%68 = load i32, i32* %8
%69 = load i64, i64* %7
%70 = load i32, i32* %10
%71 = load i32, i32* %13
%72 = call i32 @u64_or_verbose(i32 %68, i64 %69, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %70, i32 %71)
%73 = load i8*, i8** %5
%74 = load i64*, i64** %6
%75 = load i64, i64* %7
%76 = call i32 @powercap_sysfs_zone_get_power_uw(i8* %73, i64* %74, i64 %75, i32* %10)
store i32 %76, i32* %13
%77 = load i32, i32* %8
%78 = load i64, i64* %7
%79 = load i32, i32* %10
%80 = load i32, i32* %13
%81 = call i32 @u64_or_verbose(i32 %77, i64 %78, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %79, i32 %80)
store i64 0, i64* %11
br label %82
82: ; preds = %97, %29
%83 = load i8*, i8** %5
%84 = load i64*, i64** %6
%85 = load i64, i64* %7
%86 = load i64, i64* %11
%87 = call i32 @powercap_sysfs_constraint_exists(i8* %83, i64* %84, i64 %85, i64 %86)
%88 = icmp ne i32 %87, 0
%89 = xor i1 %88, true
br i1 %89, label %90, label %100
90: ; preds = %82
%91 = load i8*, i8** %5
%92 = load i64*, i64** %6
%93 = load i64, i64* %7
%94 = load i64, i64* %11
%95 = load i32, i32* %8
%96 = call i32 @analyze_constraint(i8* %91, i64* %92, i64 %93, i64 %94, i32 %95)
br label %97
97: ; preds = %90
%98 = load i64, i64* %11
%99 = add nsw i64 %98, 1
store i64 %99, i64* %11
br label %82
100: ; preds = %82
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"name\00"
@.str.1 = [8 x i8] c"enabled\00"
@.str.2 = [20 x i8] c"max_energy_range_uj\00"
@.str.3 = [10 x i8] c"energy_uj\00"
@.str.4 = [19 x i8] c"max_power_range_uw\00"
@.str.5 = [9 x i8] c"power_uw\00"
define void @analyze_zone(i8* %0, i64* %1, i64 %2, i32 %3) {
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = alloca i64
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = bitcast i32* %6 to i8*
%10 = bitcast i64* %7 to i8*
%11 = tail call i32 @print_parent_headers(i64* %1, i64 %2, i64 %2)
%12 = call i64 @powercap_sysfs_zone_get_name(i8* %0, i64* %1, i64 %2, i8* %8, i32 1024)
%13 = icmp slt i64 %12, 0
%14 = select i1 %13, i64 %12, i64 0
%15 = trunc i64 %14 to i32
%16 = call i32 @str_or_verbose(i32 %3, i64 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %15)
%17 = call i32 @powercap_sysfs_zone_get_enabled(i8* %0, i64* %1, i64 %2, i64* %7)
%18 = load i64, i64* %7
%19 = trunc i64 %18 to i32
%20 = call i32 @u64_or_verbose(i32 %3, i64 %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %17)
%21 = call i32 @powercap_sysfs_zone_get_max_energy_range_uj(i8* %0, i64* %1, i64 %2, i32* %6)
%22 = load i32, i32* %6
%23 = call i32 @u64_or_verbose(i32 %3, i64 %2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %21)
%24 = call i32 @powercap_sysfs_zone_get_energy_uj(i8* %0, i64* %1, i64 %2, i32* %6)
%25 = load i32, i32* %6
%26 = call i32 @u64_or_verbose(i32 %3, i64 %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %25, i32 %24)
%27 = call i32 @powercap_sysfs_zone_get_max_power_range_uw(i8* %0, i64* %1, i64 %2, i32* %6)
%28 = load i32, i32* %6
%29 = call i32 @u64_or_verbose(i32 %3, i64 %2, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %28, i32 %27)
%30 = call i32 @powercap_sysfs_zone_get_power_uw(i8* %0, i64* %1, i64 %2, i32* %6)
%31 = load i32, i32* %6
%32 = call i32 @u64_or_verbose(i32 %3, i64 %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %31, i32 %30)
store i64 0, i64* %7
%33 = call i32 @powercap_sysfs_constraint_exists(i8* %0, i64* %1, i64 %2, i64 0)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %42
35: ; preds = %4, %35
%36 = load i64, i64* %7
%37 = call i32 @analyze_constraint(i8* %0, i64* %1, i64 %2, i64 %36, i32 %3)
%38 = load i64, i64* %7
%39 = add nsw i64 %38, 1
store i64 %39, i64* %7
%40 = call i32 @powercap_sysfs_constraint_exists(i8* %0, i64* %1, i64 %2, i64 %39)
%41 = icmp eq i32 %40, 0
br i1 %41, label %35, label %42
42: ; preds = %35, %4
ret void
}