#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_total_jiffies_stat();
int /*<<< orphan*/ sleep(unsigned int);
double cpuusage_get_total_usage(unsigned int delay) {
  struct cpuusage_jiffies_stat *first_stat = NULL;
  struct cpuusage_jiffies_stat *second_stat = NULL;
  double cpuusage = 0;
  first_stat = cpuusage_get_total_jiffies_stat();
  sleep(delay);
  second_stat = cpuusage_get_total_jiffies_stat();
  cpuusage = cpuusage_calc_usage(first_stat, second_stat);
  return cpuusage;
}


x86 assembly (clang, -O0):
<cpuusage_get_total_usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1030 <cpuusage_get_total_jiffies_stat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <sleep@plt>
mov    $0x0,%al
call   1030 <cpuusage_get_total_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_total_usage>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <cpuusage_get_total_jiffies_stat@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1050 <sleep@plt>
xor    %eax,%eax
call   1030 <cpuusage_get_total_jiffies_stat@plt>
mov    %r14,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <cpuusage_calc_usage@plt>

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

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