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

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ get_sysdata(char *, char **, char *);
int /*<<< orphan*/ print_system_configuration();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
double strtod(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ update_sysdata();
void print_scaled_output(int interval, int count) {
  char purr[32], purr_idle[32], spurr[32], spurr_idle[32];
  char nominal_f[32], effective_f[32];
  double nominal_freq, effective_freq;
  char *descr;
  print_system_configuration();
  fprintf(stdout, "---Actual---                 -Normalized-\n");
  fprintf(stdout, "%%busy  %%idle   Frequency     %%busy  %%idle\n");
  fprintf(stdout, "------ ------  ------------- ------ ------\n");
  do {
    if (interval) {
      sleep(interval);
      update_sysdata();
    }
    get_sysdata("purr_cpu_util", &descr, purr);
    get_sysdata("purr_cpu_idle", &descr, purr_idle);
    get_sysdata("spurr_cpu_util", &descr, spurr);
    get_sysdata("spurr_cpu_idle", &descr, spurr_idle);
    get_sysdata("nominal_freq", &descr, nominal_f);
    get_sysdata("effective_freq", &descr, effective_f);
    nominal_freq = strtod(nominal_f, NULL);
    effective_freq = strtod(effective_f, NULL);
    fprintf(stdout, "%6s %6s %5.2fGHz[%3d%%] %6s %6s\n", purr, purr_idle,
            effective_freq / 1000,
            (int)((effective_freq / nominal_freq * 100) + 0.44), spurr,
            spurr_idle);
    fflush(stdout);
  } while (--count > 0);
}


x86 assembly (clang, -O0):
<print_scaled_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1080 <print_system_configuration@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpl   $0x0,-0x4(%rbp)
je     11e6 <print_scaled_output+0x76>
mov    -0x4(%rbp),%edi
call   1090 <sleep@plt>
mov    $0x0,%al
call   1070 <update_sysdata@plt>
lea    -0x30(%rbp),%rdx
lea    0xeae(%rip),%rdi
lea    -0xe8(%rbp),%rsi
call   1040 <get_sysdata@plt>
lea    -0x50(%rbp),%rdx
lea    0xea6(%rip),%rdi
lea    -0xe8(%rbp),%rsi
call   1040 <get_sysdata@plt>
lea    -0x70(%rbp),%rdx
lea    0xe7f(%rip),%rdi
lea    -0xe8(%rbp),%rsi
call   1040 <get_sysdata@plt>
lea    -0x90(%rbp),%rdx
lea    0xe74(%rip),%rdi
lea    -0xe8(%rbp),%rsi
call   1040 <get_sysdata@plt>
lea    -0xb0(%rbp),%rdx
lea    0xe69(%rip),%rdi
lea    -0xe8(%rbp),%rsi
call   1040 <get_sysdata@plt>
lea    -0xd0(%rbp),%rdx
lea    0xe5c(%rip),%rdi
lea    -0xe8(%rbp),%rsi
call   1040 <get_sysdata@plt>
lea    -0xb0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
movsd  %xmm0,-0xd8(%rbp)
ff
lea    -0xd0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
movsd  %xmm0,-0xe0(%rbp)
ff
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rdx
lea    -0x50(%rbp),%rcx
movsd  -0xe0(%rbp),%xmm0
ff
movsd  0xd46(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0xe0(%rbp),%xmm1
ff
divsd  -0xd8(%rbp),%xmm1
ff
movsd  0xd1a(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd16(%rip),%xmm2
addsd  %xmm2,%xmm1
cvttsd2si %xmm1,%r8d
lea    -0x70(%rbp),%r9
lea    -0x90(%rbp),%rax
lea    0xdcb(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jg     11cd <print_scaled_output+0x5d>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_scaled_output>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %esi,%r12d
mov    %edi,%ebp
xor    %eax,%eax
call   1080 <print_system_configuration@plt>
mov    0x2e4c(%rip),%r14
mov    (%r14),%edi
lea    0xe7a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xe94(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xeb2(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%r12d
jmp    12e0 <print_scaled_output+0x170>
lea    0xec8(%rip),%rdi
lea    0x18(%rsp),%rbx
mov    %rbx,%rsi
lea    0x40(%rsp),%rdx
call   1040 <get_sysdata@plt>
lea    0xebe(%rip),%rdi
mov    %rbx,%rsi
lea    0x20(%rsp),%rdx
call   1040 <get_sysdata@plt>
lea    0xe9a(%rip),%rdi
mov    %rbx,%rsi
lea    0xc0(%rsp),%r15
mov    %r15,%rdx
call   1040 <get_sysdata@plt>
lea    0xe8f(%rip),%rdi
mov    %rbx,%rsi
lea    0xa0(%rsp),%r14
mov    %r14,%rdx
call   1040 <get_sysdata@plt>
lea    0xe84(%rip),%rdi
mov    %rbx,%rsi
lea    0x80(%rsp),%r13
mov    %r13,%rdx
call   1040 <get_sysdata@plt>
lea    0xe77(%rip),%rdi
mov    %rbx,%rsi
lea    0x60(%rsp),%rbx
mov    %rbx,%rdx
call   1040 <get_sysdata@plt>
mov    %r13,%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
mov    0x2d5d(%rip),%rbx
mov    (%rbx),%edi
movapd %xmm0,%xmm1
divsd  0xd6f(%rip),%xmm1
divsd  0x10(%rsp),%xmm0
mulsd  0xd69(%rip),%xmm0
addsd  0xd69(%rip),%xmm0
cvttsd2si %xmm0,%r8d
mov    %r14,(%rsp)
lea    0xe21(%rip),%rsi
lea    0x40(%rsp),%rdx
lea    0x20(%rsp),%rcx
movapd %xmm1,%xmm0
mov    %r15,%r9
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    (%rbx),%edi
call   1060 <fflush@plt>
add    $0xffffffff,%r12d
cmp    $0x1,%r12d
jle    12fb <print_scaled_output+0x18b>
test   %ebp,%ebp
je     11d0 <print_scaled_output+0x60>
mov    %ebp,%edi
call   1090 <sleep@plt>
xor    %eax,%eax
call   1070 <update_sysdata@plt>
jmp    11d0 <print_scaled_output+0x60>
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [43 x i8] c"---Actual--- -Normalized-\0A\00"
@.str.1 = [47 x i8] c"%%busy %%idle Frequency %%busy %%idle\0A\00"
@.str.2 = [44 x i8] c"------ ------ ------------- ------ ------\0A\00"
@.str.3 = [14 x i8] c"purr_cpu_util\00"
@.str.4 = [14 x i8] c"purr_cpu_idle\00"
@.str.5 = [15 x i8] c"spurr_cpu_util\00"
@.str.6 = [15 x i8] c"spurr_cpu_idle\00"
@.str.7 = [13 x i8] c"nominal_freq\00"
@.str.8 = [15 x i8] c"effective_freq\00"
@.str.9 = [33 x i8] c"%6s %6s %5.2fGHz[%3d%%] %6s %6s\0A\00"
define void @print_scaled_output(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca [32 x i8]
%8 = alloca [32 x i8]
%9 = alloca [32 x i8]
%10 = alloca [32 x i8]
%11 = alloca double
%12 = alloca double
%13 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%14 = call i32 (...) @print_system_configuration()
%15 = load i32, i32* @stdout
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @stdout
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @stdout
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %60, %2
%22 = load i32, i32* %3
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i32, i32* %3
%26 = call i32 @sleep(i32 %25)
%27 = call i32 (...) @update_sysdata()
br label %28
28: ; preds = %24, %21
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%30 = call i32 @get_sysdata(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %13, i8* %29)
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%32 = call i32 @get_sysdata(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %13, i8* %31)
%33 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%34 = call i32 @get_sysdata(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8** %13, i8* %33)
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%36 = call i32 @get_sysdata(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8** %13, i8* %35)
%37 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%38 = call i32 @get_sysdata(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8** %13, i8* %37)
%39 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%40 = call i32 @get_sysdata(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8** %13, i8* %39)
%41 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%42 = call double @strtod(i8* %41, i32* null)
store double %42, double* %11
%43 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%44 = call double @strtod(i8* %43, i32* null)
store double %44, double* %12
%45 = load i32, i32* @stdout
%46 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%47 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%48 = load double, double* %12
%49 = fdiv double %48, 1.000000e+03
%50 = load double, double* %12
%51 = load double, double* %11
%52 = fdiv double %50, %51
%53 = call double @llvm.fmuladd.f64(double %52, double 1.000000e+02, double 4.400000e-01)
%54 = fptosi double %53 to i32
%55 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%56 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i8* %46, i8* %47, double %49, i32 %54, i8* %55, i8* %56)
%58 = load i32, i32* @stdout
%59 = call i32 @fflush(i32 %58)
br label %60
60: ; preds = %28
%61 = load i32, i32* %4
%62 = add nsw i32 %61, -1
store i32 %62, i32* %4
%63 = icmp sgt i32 %62, 0
br i1 %63, label %21, label %64
64: ; preds = %60
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [43 x i8] c"---Actual--- -Normalized-\0A\00"
@.str.1 = [47 x i8] c"%%busy %%idle Frequency %%busy %%idle\0A\00"
@.str.2 = [44 x i8] c"------ ------ ------------- ------ ------\0A\00"
@.str.3 = [14 x i8] c"purr_cpu_util\00"
@.str.4 = [14 x i8] c"purr_cpu_idle\00"
@.str.5 = [15 x i8] c"spurr_cpu_util\00"
@.str.6 = [15 x i8] c"spurr_cpu_idle\00"
@.str.7 = [13 x i8] c"nominal_freq\00"
@.str.8 = [15 x i8] c"effective_freq\00"
@.str.9 = [33 x i8] c"%6s %6s %5.2fGHz[%3d%%] %6s %6s\0A\00"
define void @print_scaled_output(i32 %0, i32 %1) {
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca [32 x i8]
%8 = alloca [32 x i8]
%9 = alloca i8*
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%16 = bitcast i8** %9 to i8*
%17 = tail call i32 (...) @print_system_configuration()
%18 = load i32, i32* @stdout
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @stdout
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @stdout
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i32 %0, 0
br label %25
25: ; preds = %30, %2
%26 = phi i32 [ %1, %2 ], [ %47, %30 ]
br i1 %24, label %30, label %27
27: ; preds = %25
%28 = call i32 @sleep(i32 %0)
%29 = call i32 (...) @update_sysdata()
br label %30
30: ; preds = %27, %25
%31 = call i32 @get_sysdata(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %9, i8* %10)
%32 = call i32 @get_sysdata(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %9, i8* %11)
%33 = call i32 @get_sysdata(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8** %9, i8* %12)
%34 = call i32 @get_sysdata(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8** %9, i8* %13)
%35 = call i32 @get_sysdata(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8** %9, i8* %14)
%36 = call i32 @get_sysdata(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8** %9, i8* %15)
%37 = call double @strtod(i8* nocapture %14, i32* null)
%38 = call double @strtod(i8* nocapture %15, i32* null)
%39 = load i32, i32* @stdout
%40 = fdiv double %38, 1.000000e+03
%41 = fdiv double %38, %37
%42 = call double @llvm.fmuladd.f64(double %41, double 1.000000e+02, double 4.400000e-01)
%43 = fptosi double %42 to i32
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i8* %10, i8* %11, double %40, i32 %43, i8* %12, i8* %13)
%45 = load i32, i32* @stdout
%46 = call i32 @fflush(i32 %45)
%47 = add nsw i32 %26, -1
%48 = icmp sgt i32 %26, 1
br i1 %48, label %25, label %49
49: ; preds = %30
ret void
}