#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 cpuusage_jiffies_stat {
  int dummy;
};

/* Variables and functions */
double cpuusage_calc_usage(struct cpuusage_jiffies_stat *,
                           struct cpuusage_jiffies_stat *);
struct cpuusage_jiffies_stat *cpuusage_get_jiffies_stat(unsigned int);
int /*<<< orphan*/ sleep(unsigned int);
double cpuusage_get_usage(unsigned int cpuid, unsigned int delay) {
  struct cpuusage_jiffies_stat *first_stat = NULL;
  struct cpuusage_jiffies_stat *second_stat = NULL;
  double cpuusage = 0;
  first_stat = cpuusage_get_jiffies_stat(cpuid);
  sleep(delay);
  second_stat = cpuusage_get_jiffies_stat(cpuid);
  cpuusage = cpuusage_calc_usage(first_stat, second_stat);
  return cpuusage;
}


x86 assembly (clang, -O0):
<cpuusage_get_usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <cpuusage_get_jiffies_stat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <sleep@plt>
mov    -0x4(%rbp),%edi
call   1030 <cpuusage_get_jiffies_stat@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <cpuusage_calc_usage@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpuusage_get_usage>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
call   1030 <cpuusage_get_jiffies_stat@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1050 <sleep@plt>
mov    %ebp,%edi
call   1030 <cpuusage_get_jiffies_stat@plt>
mov    %r14,%rdi
mov    %rax,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <cpuusage_calc_usage@plt>

LLVM IR (-O0):
%struct.cpuusage_jiffies_stat = type { i32 }
define double @cpuusage_get_usage(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.cpuusage_jiffies_stat*
%6 = alloca %struct.cpuusage_jiffies_stat*
%7 = alloca double
store i32 %0, i32* %3
store i32 %1, i32* %4
store %struct.cpuusage_jiffies_stat* null, %struct.cpuusage_jiffies_stat** %5
store %struct.cpuusage_jiffies_stat* null, %struct.cpuusage_jiffies_stat** %6
store double 0.000000e+00, double* %7
%8 = load i32, i32* %3
%9 = call %struct.cpuusage_jiffies_stat* @cpuusage_get_jiffies_stat(i32 %8)
store %struct.cpuusage_jiffies_stat* %9, %struct.cpuusage_jiffies_stat** %5
%10 = load i32, i32* %4
%11 = call i32 @sleep(i32 %10)
%12 = load i32, i32* %3
%13 = call %struct.cpuusage_jiffies_stat* @cpuusage_get_jiffies_stat(i32 %12)
store %struct.cpuusage_jiffies_stat* %13, %struct.cpuusage_jiffies_stat** %6
%14 = load %struct.cpuusage_jiffies_stat*, %struct.cpuusage_jiffies_stat** %5
%15 = load %struct.cpuusage_jiffies_stat*, %struct.cpuusage_jiffies_stat** %6
%16 = call double @cpuusage_calc_usage(%struct.cpuusage_jiffies_stat* %14, %struct.cpuusage_jiffies_stat* %15)
store double %16, double* %7
%17 = load double, double* %7
ret double %17
}

LLVM IR (-O2):
%struct.cpuusage_jiffies_stat = type { i32 }
define double @cpuusage_get_usage(i32 %0, i32 %1) {
%3 = tail call %struct.cpuusage_jiffies_stat* @cpuusage_get_jiffies_stat(i32 %0)
%4 = tail call i32 @sleep(i32 %1)
%5 = tail call %struct.cpuusage_jiffies_stat* @cpuusage_get_jiffies_stat(i32 %0)
%6 = tail call double @cpuusage_calc_usage(%struct.cpuusage_jiffies_stat* %3, %struct.cpuusage_jiffies_stat* %5)
ret double %6
}