#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*/ print_cpustats(int, int);
int /*<<< orphan*/ printf(char *);
void cpustat_test(int fildes) {
  int i = 0;
  printf("==CPU STAT TEST==\n");
  print_cpustats(fildes, 4 * 2);
  for (i = 0; i < 2 * 4; ++i) {
    print_cpustats(fildes, i);
  }
}


x86 assembly (clang, -O0):
<cpustat_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec7(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1030 <print_cpustats@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1175 <cpustat_test+0x55>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <print_cpustats@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1152 <cpustat_test+0x32>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpustat_test>:
push   %rbx
mov    %edi,%ebx
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    $0x8,%esi
call   1040 <print_cpustats@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <print_cpustats@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   1040 <print_cpustats@plt>
mov    %ebx,%edi
mov    $0x2,%esi
call   1040 <print_cpustats@plt>
mov    %ebx,%edi
mov    $0x3,%esi
call   1040 <print_cpustats@plt>
mov    %ebx,%edi
mov    $0x4,%esi
call   1040 <print_cpustats@plt>
mov    %ebx,%edi
mov    $0x5,%esi
call   1040 <print_cpustats@plt>
mov    %ebx,%edi
mov    $0x6,%esi
call   1040 <print_cpustats@plt>
mov    %ebx,%edi
mov    $0x7,%esi
pop    %rbx
jmp    1040 <print_cpustats@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"==CPU STAT TEST==\0A\00"
define void @cpustat_test(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* %2
%6 = call i32 @print_cpustats(i32 %5, i32 8)
store i32 0, i32* %3
br label %7
7: ; preds = %14, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 8
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 @print_cpustats(i32 %11, i32 %12)
br label %14
14: ; preds = %10
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %7
17: ; preds = %7
ret void
}

LLVM IR (-O2):
@str = [18 x i8] c"==CPU STAT TEST==\00"
define void @cpustat_test(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @print_cpustats(i32 %0, i32 8)
%4 = tail call i32 @print_cpustats(i32 %0, i32 0)
%5 = tail call i32 @print_cpustats(i32 %0, i32 1)
%6 = tail call i32 @print_cpustats(i32 %0, i32 2)
%7 = tail call i32 @print_cpustats(i32 %0, i32 3)
%8 = tail call i32 @print_cpustats(i32 %0, i32 4)
%9 = tail call i32 @print_cpustats(i32 %0, i32 5)
%10 = tail call i32 @print_cpustats(i32 %0, i32 6)
%11 = tail call i32 @print_cpustats(i32 %0, i32 7)
ret void
}