#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 */
struct sysentry {
  int dummy;
};

/* Variables and functions */
double get_delta_value(char *);
double get_scaled_tb();
int /*<<< orphan*/ sprintf(char *, char *, double);
void get_cpu_util_purr(struct sysentry *unused_se, char *buf) {
  double delta_tb, delta_purr, delta_idle_purr;
  double physc;
  delta_tb = get_scaled_tb();
  delta_purr = get_delta_value("purr");
  delta_idle_purr = get_delta_value("idle_purr");
  physc = (delta_purr - delta_idle_purr) / delta_tb;
  physc *= 100.00;
  sprintf(buf, "%.2f", physc);
}


x86 assembly (clang, -O0):
<get_cpu_util_purr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <get_scaled_tb@plt>
movsd  %xmm0,-0x18(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <get_delta_value@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xea4(%rip),%rdi
call   1040 <get_delta_value@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe76(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
movsd  -0x30(%rbp),%xmm0
lea    0xe6e(%rip),%rsi
call   1050 <sprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cpu_util_purr>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
xor    %eax,%eax
call   1030 <get_scaled_tb@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xec1(%rip),%rdi
call   1040 <get_delta_value@plt>
movsd  %xmm0,(%rsp)
lea    0xeab(%rip),%rdi
call   1040 <get_delta_value@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
divsd  0x8(%rsp),%xmm1
mulsd  0xe87(%rip),%xmm1
movapd %xmm1,%xmm0
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1050 <sprintf@plt>

LLVM IR (-O0):
%struct.sysentry = type { i32 }
@.str = [5 x i8] c"purr\00"
@.str.1 = [10 x i8] c"idle_purr\00"
@.str.2 = [5 x i8] c"%.2f\00"
define void @get_cpu_util_purr(%struct.sysentry* %0, i8* %1) {
%3 = alloca %struct.sysentry*
%4 = alloca i8*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store %struct.sysentry* %0, %struct.sysentry** %3
store i8* %1, i8** %4
%9 = call double (...) @get_scaled_tb()
store double %9, double* %5
%10 = call double @get_delta_value(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store double %10, double* %6
%11 = call double @get_delta_value(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store double %11, double* %7
%12 = load double, double* %6
%13 = load double, double* %7
%14 = fsub double %12, %13
%15 = load double, double* %5
%16 = fdiv double %14, %15
store double %16, double* %8
%17 = load double, double* %8
%18 = fmul double %17, 1.000000e+02
store double %18, double* %8
%19 = load i8*, i8** %4
%20 = load double, double* %8
%21 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %20)
ret void
}

LLVM IR (-O2):
%struct.sysentry = type { i32 }
@.str = [5 x i8] c"purr\00"
@.str.1 = [10 x i8] c"idle_purr\00"
@.str.2 = [5 x i8] c"%.2f\00"
define void @get_cpu_util_purr(%struct.sysentry* nocapture readnone %0, i8* nocapture writeonly %1) {
%3 = tail call double (...) @get_scaled_tb()
%4 = tail call double @get_delta_value(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = tail call double @get_delta_value(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%6 = fsub double %4, %5
%7 = fdiv double %6, %3
%8 = fmul double %7, 1.000000e+02
%9 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %8)
ret void
}