#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*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ rdpmc(int);
int /*<<< orphan*/ rdpmc_actual_cycles();
int /*<<< orphan*/ rdpmc_instructions();
int /*<<< orphan*/ rdpmc_reference_cycles();
int main() {
  printf("Fixed-function 0 - rdpmc_instructions      : %lu \n",
         rdpmc_instructions());
  printf("Fixed-function 1 - rdpmc_actual_cycles     : %lu \n",
         rdpmc_actual_cycles());
  printf("Fixed-function 2 - rdpmc_reference_cycles  : %lu \n",
         rdpmc_reference_cycles());
  printf("PMC 1                                      : %lu \n", rdpmc(0));
  printf("PMC 2                                      : %lu \n", rdpmc(1));
  printf("PMC 3                                      : %lu \n", rdpmc(2));
  printf("PMC 4                                      : %lu \n", rdpmc(3));
  printf("Register 0x300                             : %lu \n", rdpmc(0x300));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1070 <rdpmc_instructions@plt>
mov    %eax,%esi
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <rdpmc_actual_cycles@plt>
mov    %eax,%esi
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <rdpmc_reference_cycles@plt>
mov    %eax,%esi
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <rdpmc@plt>
mov    %eax,%esi
lea    0xef6(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <rdpmc@plt>
mov    %eax,%esi
lea    0xf11(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2,%edi
call   1040 <rdpmc@plt>
mov    %eax,%esi
lea    0xf2c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x3,%edi
call   1040 <rdpmc@plt>
mov    %eax,%esi
lea    0xf47(%rip),%rdi
call   1030 <printf@plt>
mov    $0x300,%edi
call   1040 <rdpmc@plt>
mov    %eax,%esi
lea    0xf62(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1070 <rdpmc_instructions@plt>
lea    0xea1(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <rdpmc_actual_cycles@plt>
lea    0xebf(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <rdpmc_reference_cycles@plt>
lea    0xedd(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <rdpmc@plt>
lea    0xefb(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <rdpmc@plt>
lea    0xf16(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x2,%edi
call   1040 <rdpmc@plt>
lea    0xf31(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x3,%edi
call   1040 <rdpmc@plt>
lea    0xf4c(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x300,%edi
call   1040 <rdpmc@plt>
lea    0xf67(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [51 x i8] c"Fixed-function 0 - rdpmc_instructions : %lu \0A\00"
@.str.1 = [51 x i8] c"Fixed-function 1 - rdpmc_actual_cycles : %lu \0A\00"
@.str.2 = [51 x i8] c"Fixed-function 2 - rdpmc_reference_cycles : %lu \0A\00"
@.str.3 = [51 x i8] c"PMC 1 : %lu \0A\00"
@.str.4 = [51 x i8] c"PMC 2 : %lu \0A\00"
@.str.5 = [51 x i8] c"PMC 3 : %lu \0A\00"
@.str.6 = [51 x i8] c"PMC 4 : %lu \0A\00"
@.str.7 = [51 x i8] c"Register 0x300 : %lu \0A\00"
define i32 @main() {
%1 = call i32 (...) @rdpmc_instructions()
%2 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = call i32 (...) @rdpmc_actual_cycles()
%4 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = call i32 (...) @rdpmc_reference_cycles()
%6 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = call i32 @rdpmc(i32 0)
%8 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = call i32 @rdpmc(i32 1)
%10 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%11 = call i32 @rdpmc(i32 2)
%12 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%13 = call i32 @rdpmc(i32 3)
%14 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i32 %13)
%15 = call i32 @rdpmc(i32 768)
%16 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i32 %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [51 x i8] c"Fixed-function 0 - rdpmc_instructions : %lu \0A\00"
@.str.1 = [51 x i8] c"Fixed-function 1 - rdpmc_actual_cycles : %lu \0A\00"
@.str.2 = [51 x i8] c"Fixed-function 2 - rdpmc_reference_cycles : %lu \0A\00"
@.str.3 = [51 x i8] c"PMC 1 : %lu \0A\00"
@.str.4 = [51 x i8] c"PMC 2 : %lu \0A\00"
@.str.5 = [51 x i8] c"PMC 3 : %lu \0A\00"
@.str.6 = [51 x i8] c"PMC 4 : %lu \0A\00"
@.str.7 = [51 x i8] c"Register 0x300 : %lu \0A\00"
define i32 @main() {
%1 = tail call i32 (...) @rdpmc_instructions()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 (...) @rdpmc_actual_cycles()
%4 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 (...) @rdpmc_reference_cycles()
%6 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = tail call i32 @rdpmc(i32 0)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = tail call i32 @rdpmc(i32 1)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%11 = tail call i32 @rdpmc(i32 2)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%13 = tail call i32 @rdpmc(i32 3)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i32 %13)
%15 = tail call i32 @rdpmc(i32 768)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i32 %15)
ret i32 0
}