#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ stderr;
void printPowerMode() {
  FILE *fp =
      fopen("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", "rt");
  if (fp) {
    char s[1000];
    int ret = fscanf(fp, "%s", s);
    if (ret == 1) {
      fprintf(stderr, "*info* power mode: '%s' (%s)\n", s,
              "/sys/devices/system/cpu/cpufreq/policy0/scaling_governor");
    } else {
      fprintf(stderr, "*info* power mode partial: '%s'\n", s);
    }
    fclose(fp);
  }
}


x86 assembly (clang, -O0):
<printPowerMode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
lea    0xeae(%rip),%rdi
lea    0xee0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11e8 <printPowerMode+0xa8>
mov    -0x8(%rbp),%rdi
lea    -0x3f0(%rbp),%rdx
lea    0xebd(%rip),%rsi
call   1040 <fscanf@plt>
mov    %eax,-0x3f4(%rbp)
cmpl   $0x1,-0x3f4(%rbp)
jne    11c1 <printPowerMode+0x81>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    -0x3f0(%rbp),%rdx
lea    0xe91(%rip),%rsi
lea    0xe4b(%rip),%rcx
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    11df <printPowerMode+0x9f>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    -0x3f0(%rbp),%rdx
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printPowerMode>:
push   %rbx
sub    $0x3f0,%rsp
lea    0xeb1(%rip),%rdi
lea    0xee3(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11b6 <printPowerMode+0x76>
mov    %rax,%rbx
lea    0xed2(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
mov    0x2e64(%rip),%rcx
mov    (%rcx),%edi
cmp    $0x1,%eax
jne    119d <printPowerMode+0x5d>
lea    0xeb5(%rip),%rsi
lea    0xe6f(%rip),%rcx
mov    %rsp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11ae <printPowerMode+0x6e>
lea    0xeb9(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x3f0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [57 x i8] c"/sys/devices/system/cpu/cpufreq/policy0/scaling_governor\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [3 x i8] c"%s\00"
@stderr = global i32 0
@.str.3 = [30 x i8] c"*info* power mode: '%s' (%s)\0A\00"
@.str.4 = [33 x i8] c"*info* power mode partial: '%s'\0A\00"
define void @printPowerMode() {
%1 = alloca i32*
%2 = alloca [1000 x i8]
%3 = alloca i32
%4 = call i32* @fopen(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %1
%5 = load i32*, i32** %1
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %24
7: ; preds = %0
%8 = load i32*, i32** %1
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%10 = call i32 @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = load i32, i32* @stderr
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%16 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %15, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %21
17: ; preds = %7
%18 = load i32, i32* @stderr
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%20 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %17, %13
%22 = load i32*, i32** %1
%23 = call i32 @fclose(i32* %22)
br label %24
24: ; preds = %21, %0
ret void
}

LLVM IR (-O2):
@.str = [57 x i8] c"/sys/devices/system/cpu/cpufreq/policy0/scaling_governor\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [3 x i8] c"%s\00"
@stderr = global i32 0
@.str.3 = [30 x i8] c"*info* power mode: '%s' (%s)\0A\00"
@.str.4 = [33 x i8] c"*info* power mode partial: '%s'\0A\00"
define void @printPowerMode() {
%1 = alloca [1000 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %15, label %4
4: ; preds = %0
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%6 = call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%7 = icmp eq i32 %6, 1
%8 = load i32, i32* @stderr
br i1 %7, label %9, label %11
9: ; preds = %4
%10 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %13
11: ; preds = %4
%12 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %5)
br label %13
13: ; preds = %11, %9
%14 = call i32 @fclose(i32* %2)
br label %15
15: ; preds = %13, %0
ret void
}