#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(scalar_t__, scalar_t__, int, scalar_t__,
                                      int);
int /*<<< orphan*/ print_headers(int /*<<< orphan*/, int /*<<< orphan*/,
                                 scalar_t__, int);
int /*<<< orphan*/ rapl_sysfs_constraint_exists(scalar_t__, scalar_t__, int,
                                                scalar_t__);
int rapl_sysfs_zone_get_enabled(scalar_t__, scalar_t__, int, scalar_t__ *);
int rapl_sysfs_zone_get_energy_uj(scalar_t__, scalar_t__, int,
                                  int /*<<< orphan*/ *);
int rapl_sysfs_zone_get_max_energy_range_uj(scalar_t__, scalar_t__, int,
                                            int /*<<< orphan*/ *);
int rapl_sysfs_zone_get_max_power_range_uw(scalar_t__, scalar_t__, int,
                                           int /*<<< orphan*/ *);
scalar_t__ rapl_sysfs_zone_get_name(scalar_t__, scalar_t__, int, char *, int);
int rapl_sysfs_zone_get_power_uw(scalar_t__, scalar_t__, int,
                                 int /*<<< orphan*/ *);
int /*<<< orphan*/ str_or_verbose(int, int, char *, char *, int);
int /*<<< orphan*/ u64_or_verbose(int, int, char *, int /*<<< orphan*/, int);
void analyze_zone(uint32_t zone, uint32_t sz, int is_sz, int verbose) {
  char name[1024];
  uint64_t val64;
  uint32_t val32;
  ssize_t sret;
  int ret;
  print_headers(0, 0, sz, is_sz);
  sret = rapl_sysfs_zone_get_name(zone, sz, is_sz, name, sizeof(name));
  ret = sret > 0 ? 0 : (int)sret;
  str_or_verbose(verbose, is_sz + 1, "name", name, ret);
  ret = rapl_sysfs_zone_get_enabled(zone, sz, is_sz, &val32);
  u64_or_verbose(verbose, is_sz + 1, "enabled", (uint64_t)val32, ret);
  ret = rapl_sysfs_zone_get_max_energy_range_uj(zone, sz, is_sz, &val64);
  u64_or_verbose(verbose, is_sz + 1, "max_energy_range_uj", val64, ret);
  ret = rapl_sysfs_zone_get_energy_uj(zone, sz, is_sz, &val64);
  u64_or_verbose(verbose, is_sz + 1, "energy_uj", val64, ret);
  ret = rapl_sysfs_zone_get_max_power_range_uw(zone, sz, is_sz, &val64);
  u64_or_verbose(verbose, is_sz + 1, "max_power_range_uw", val64, ret);
  ret = rapl_sysfs_zone_get_power_uw(zone, sz, is_sz, &val64);
  u64_or_verbose(verbose, is_sz + 1, "power_uw", val64, ret);
  for (val32 = 0; !rapl_sysfs_constraint_exists(zone, sz, is_sz, val32);
       val32++) {
    analyze_constraint(zone, sz, is_sz, 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    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
xor    %esi,%esi
mov    %esi,%edi
call   1080 <print_headers@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x420(%rbp),%rcx
mov    $0x400,%r8d
call   1050 <rapl_sysfs_zone_get_name@plt>
mov    %rax,-0x438(%rbp)
cmpq   $0x0,-0x438(%rbp)
jle    1218 <analyze_zone+0x68>
xor    %eax,%eax
mov    %eax,-0x440(%rbp)
jmp    1225 <analyze_zone+0x75>
mov    -0x438(%rbp),%rax
mov    %eax,-0x440(%rbp)
mov    -0x440(%rbp),%eax
mov    %eax,-0x43c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    -0x420(%rbp),%rcx
mov    -0x43c(%rbp),%r8d
lea    0xdb1(%rip),%rdx
call   10a0 <str_or_verbose@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x430(%rbp),%rcx
call   1040 <rapl_sysfs_zone_get_enabled@plt>
mov    %eax,-0x43c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x430(%rbp),%rax
mov    %eax,%ecx
mov    -0x43c(%rbp),%r8d
lea    0xd74(%rip),%rdx
call   1070 <u64_or_verbose@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x424(%rbp),%rcx
call   1030 <rapl_sysfs_zone_get_max_energy_range_uj@plt>
mov    %eax,-0x43c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x424(%rbp),%ecx
mov    -0x43c(%rbp),%r8d
lea    0xd3d(%rip),%rdx
call   1070 <u64_or_verbose@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x424(%rbp),%rcx
call   1090 <rapl_sysfs_zone_get_energy_uj@plt>
mov    %eax,-0x43c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x424(%rbp),%ecx
mov    -0x43c(%rbp),%r8d
lea    0xd12(%rip),%rdx
call   1070 <u64_or_verbose@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x424(%rbp),%rcx
call   10c0 <rapl_sysfs_zone_get_max_power_range_uw@plt>
mov    %eax,-0x43c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x424(%rbp),%ecx
mov    -0x43c(%rbp),%r8d
lea    0xcdd(%rip),%rdx
call   1070 <u64_or_verbose@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x424(%rbp),%rcx
call   10b0 <rapl_sysfs_zone_get_power_uw@plt>
mov    %eax,-0x43c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x424(%rbp),%ecx
mov    -0x43c(%rbp),%r8d
lea    0xcb1(%rip),%rdx
call   1070 <u64_or_verbose@plt>
movq   $0x0,-0x430(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x430(%rbp),%rcx
call   1060 <rapl_sysfs_constraint_exists@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    13c9 <analyze_zone+0x219>
jmp    13fb <analyze_zone+0x24b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x430(%rbp),%rcx
mov    -0x18(%rbp),%r8d
call   10d0 <analyze_constraint@plt>
mov    -0x430(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x430(%rbp)
jmp    139d <analyze_zone+0x1ed>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<analyze_zone>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %ecx,%r14d
mov    %edx,%ebx
mov    %rsi,%rbp
mov    %rdi,%r15
xor    %edi,%edi
xor    %esi,%esi
mov    %rbp,%rdx
mov    %ebx,%ecx
call   1080 <print_headers@plt>
lea    0x10(%rsp),%r13
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
mov    %r13,%rcx
mov    $0x400,%r8d
call   1050 <rapl_sysfs_zone_get_name@plt>
mov    %rax,%rcx
sar    $0x3f,%rcx
and    %ecx,%eax
lea    0x1(%rbx),%r12d
lea    0xdf7(%rip),%rdx
mov    %r14d,%edi
mov    %r12d,%esi
mov    %r13,%rcx
mov    %eax,%r8d
call   10a0 <str_or_verbose@plt>
lea    0x8(%rsp),%rcx
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1040 <rapl_sysfs_zone_get_enabled@plt>
mov    0x8(%rsp),%ecx
lea    0xdce(%rip),%rdx
mov    %r14d,%edi
mov    %r12d,%esi
mov    %eax,%r8d
call   1070 <u64_or_verbose@plt>
lea    0x4(%rsp),%r13
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
mov    %r13,%rcx
call   1030 <rapl_sysfs_zone_get_max_energy_range_uj@plt>
mov    0x4(%rsp),%ecx
lea    0xda8(%rip),%rdx
mov    %r14d,%edi
mov    %r12d,%esi
mov    %eax,%r8d
call   1070 <u64_or_verbose@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
mov    %r13,%rcx
call   1090 <rapl_sysfs_zone_get_energy_uj@plt>
mov    0x4(%rsp),%ecx
lea    0xd93(%rip),%rdx
mov    %r14d,%edi
mov    %r12d,%esi
mov    %eax,%r8d
call   1070 <u64_or_verbose@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
mov    %r13,%rcx
call   10c0 <rapl_sysfs_zone_get_max_power_range_uw@plt>
mov    0x4(%rsp),%ecx
lea    0xd74(%rip),%rdx
mov    %r14d,%edi
mov    %r12d,%esi
mov    %eax,%r8d
call   1070 <u64_or_verbose@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
mov    %r13,%rcx
call   10b0 <rapl_sysfs_zone_get_power_uw@plt>
mov    0x4(%rsp),%ecx
lea    0xd5e(%rip),%rdx
mov    %r14d,%edi
mov    %r12d,%esi
mov    %eax,%r8d
call   1070 <u64_or_verbose@plt>
movq   $0x0,0x8(%rsp)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1060 <rapl_sysfs_constraint_exists@plt>
test   %eax,%eax
jne    1346 <analyze_zone+0x196>
mov    0x8(%rsp),%rcx
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
mov    %r14d,%r8d
call   10d0 <analyze_constraint@plt>
mov    0x8(%rsp),%rcx
add    $0x1,%rcx
mov    %rcx,0x8(%rsp)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
jmp    1310 <analyze_zone+0x160>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
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(i64 %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca [1024 x i8]
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
store i64 %0, i64* %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%14 = load i64, i64* %6
%15 = load i32, i32* %7
%16 = call i32 @print_headers(i32 0, i32 0, i64 %14, i32 %15)
%17 = load i64, i64* %5
%18 = load i64, i64* %6
%19 = load i32, i32* %7
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%21 = call i64 @rapl_sysfs_zone_get_name(i64 %17, i64 %18, i32 %19, i8* %20, i32 1024)
store i64 %21, i64* %12
%22 = load i64, i64* %12
%23 = icmp sgt i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %4
br label %28
25: ; preds = %4
%26 = load i64, i64* %12
%27 = trunc i64 %26 to i32
br label %28
28: ; preds = %25, %24
%29 = phi i32 [ 0, %24 ], [ %27, %25 ]
store i32 %29, i32* %13
%30 = load i32, i32* %8
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
%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 %30, i32 %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %33, i32 %34)
%36 = load i64, i64* %5
%37 = load i64, i64* %6
%38 = load i32, i32* %7
%39 = call i32 @rapl_sysfs_zone_get_enabled(i64 %36, i64 %37, i32 %38, i64* %11)
store i32 %39, i32* %13
%40 = load i32, i32* %8
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
%43 = load i64, i64* %11
%44 = trunc i64 %43 to i32
%45 = load i32, i32* %13
%46 = call i32 @u64_or_verbose(i32 %40, i32 %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %44, i32 %45)
%47 = load i64, i64* %5
%48 = load i64, i64* %6
%49 = load i32, i32* %7
%50 = call i32 @rapl_sysfs_zone_get_max_energy_range_uj(i64 %47, i64 %48, i32 %49, i32* %10)
store i32 %50, i32* %13
%51 = load i32, i32* %8
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
%54 = load i32, i32* %10
%55 = load i32, i32* %13
%56 = call i32 @u64_or_verbose(i32 %51, i32 %53, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %54, i32 %55)
%57 = load i64, i64* %5
%58 = load i64, i64* %6
%59 = load i32, i32* %7
%60 = call i32 @rapl_sysfs_zone_get_energy_uj(i64 %57, i64 %58, i32 %59, i32* %10)
store i32 %60, i32* %13
%61 = load i32, i32* %8
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 1
%64 = load i32, i32* %10
%65 = load i32, i32* %13
%66 = call i32 @u64_or_verbose(i32 %61, i32 %63, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %64, i32 %65)
%67 = load i64, i64* %5
%68 = load i64, i64* %6
%69 = load i32, i32* %7
%70 = call i32 @rapl_sysfs_zone_get_max_power_range_uw(i64 %67, i64 %68, i32 %69, i32* %10)
store i32 %70, i32* %13
%71 = load i32, i32* %8
%72 = load i32, i32* %7
%73 = add nsw i32 %72, 1
%74 = load i32, i32* %10
%75 = load i32, i32* %13
%76 = call i32 @u64_or_verbose(i32 %71, i32 %73, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %74, i32 %75)
%77 = load i64, i64* %5
%78 = load i64, i64* %6
%79 = load i32, i32* %7
%80 = call i32 @rapl_sysfs_zone_get_power_uw(i64 %77, i64 %78, i32 %79, i32* %10)
store i32 %80, i32* %13
%81 = load i32, i32* %8
%82 = load i32, i32* %7
%83 = add nsw i32 %82, 1
%84 = load i32, i32* %10
%85 = load i32, i32* %13
%86 = call i32 @u64_or_verbose(i32 %81, i32 %83, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %84, i32 %85)
store i64 0, i64* %11
br label %87
87: ; preds = %102, %28
%88 = load i64, i64* %5
%89 = load i64, i64* %6
%90 = load i32, i32* %7
%91 = load i64, i64* %11
%92 = call i32 @rapl_sysfs_constraint_exists(i64 %88, i64 %89, i32 %90, i64 %91)
%93 = icmp ne i32 %92, 0
%94 = xor i1 %93, true
br i1 %94, label %95, label %105
95: ; preds = %87
%96 = load i64, i64* %5
%97 = load i64, i64* %6
%98 = load i32, i32* %7
%99 = load i64, i64* %11
%100 = load i32, i32* %8
%101 = call i32 @analyze_constraint(i64 %96, i64 %97, i32 %98, i64 %99, i32 %100)
br label %102
102: ; preds = %95
%103 = load i64, i64* %11
%104 = add nsw i64 %103, 1
store i64 %104, i64* %11
br label %87
105: ; preds = %87
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(i64 %0, i64 %1, i32 %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_headers(i32 0, i32 0, i64 %1, i32 %2)
%12 = call i64 @rapl_sysfs_zone_get_name(i64 %0, i64 %1, i32 %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 = add nsw i32 %2, 1
%17 = call i32 @str_or_verbose(i32 %3, i32 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %15)
%18 = call i32 @rapl_sysfs_zone_get_enabled(i64 %0, i64 %1, i32 %2, i64* %7)
%19 = load i64, i64* %7
%20 = trunc i64 %19 to i32
%21 = call i32 @u64_or_verbose(i32 %3, i32 %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %18)
%22 = call i32 @rapl_sysfs_zone_get_max_energy_range_uj(i64 %0, i64 %1, i32 %2, i32* %6)
%23 = load i32, i32* %6
%24 = call i32 @u64_or_verbose(i32 %3, i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %22)
%25 = call i32 @rapl_sysfs_zone_get_energy_uj(i64 %0, i64 %1, i32 %2, i32* %6)
%26 = load i32, i32* %6
%27 = call i32 @u64_or_verbose(i32 %3, i32 %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 %25)
%28 = call i32 @rapl_sysfs_zone_get_max_power_range_uw(i64 %0, i64 %1, i32 %2, i32* %6)
%29 = load i32, i32* %6
%30 = call i32 @u64_or_verbose(i32 %3, i32 %16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %29, i32 %28)
%31 = call i32 @rapl_sysfs_zone_get_power_uw(i64 %0, i64 %1, i32 %2, i32* %6)
%32 = load i32, i32* %6
%33 = call i32 @u64_or_verbose(i32 %3, i32 %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %32, i32 %31)
store i64 0, i64* %7
%34 = call i32 @rapl_sysfs_constraint_exists(i64 %0, i64 %1, i32 %2, i64 0)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %4, %36
%37 = load i64, i64* %7
%38 = call i32 @analyze_constraint(i64 %0, i64 %1, i32 %2, i64 %37, i32 %3)
%39 = load i64, i64* %7
%40 = add nsw i64 %39, 1
store i64 %40, i64* %7
%41 = call i32 @rapl_sysfs_constraint_exists(i64 %0, i64 %1, i32 %2, i64 %40)
%42 = icmp eq i32 %41, 0
br i1 %42, label %36, label %43
43: ; preds = %36, %4
ret void
}