#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*/ cpuid(int, unsigned int, unsigned int *, unsigned int *,
                         unsigned int *, unsigned int *);
int /*<<< orphan*/ printf(char *, ...);
void dumpregs(int cpunum, unsigned int begin, unsigned int end) {
  unsigned int i;
  unsigned int eax, ebx, ecx, edx;
  for (i = begin; i <= end; i++) {
    cpuid(cpunum, i, &eax, &ebx, &ecx, &edx);
    printf("eax in: 0x%08x, eax = %08x ebx = %08x ecx = %08x edx = %08x\n", i,
           eax, ebx, ecx, edx);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dumpregs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     118b <dumpregs+0x6b>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    -0x20(%rbp),%r9
call   1040 <cpuid@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1137 <dumpregs+0x17>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpregs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    %edx,%esi
ja     119f <dumpregs+0x6f>
mov    %edx,%ebx
mov    %esi,%ebp
mov    %edi,%r14d
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%r15
lea    0xea6(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %ebp,%esi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %r13,%r8
mov    %r15,%r9
call   1050 <cpuid@plt>
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x8(%rsp),%r9d
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebx,%ebp
jbe    1160 <dumpregs+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [61 x i8] c"eax in: 0x%08x, eax = %08x ebx = %08x ecx = %08x edx = %08x\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @dumpregs(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%12 = load i32, i32* %5
store i32 %12, i32* %7
br label %13
13: ; preds = %27, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %6
%16 = icmp ule i32 %14, %15
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load i32, i32* %4
%19 = load i32, i32* %7
%20 = call i32 @cpuid(i32 %18, i32 %19, i32* %8, i32* %9, i32* %10, i32* %11)
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = load i32, i32* %9
%24 = load i32, i32* %10
%25 = load i32, i32* %11
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i32 %23, i32 %24, i32 %25)
br label %27
27: ; preds = %17
%28 = load i32, i32* %7
%29 = add i32 %28, 1
store i32 %29, i32* %7
br label %13
30: ; preds = %13
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [61 x i8] c"eax in: 0x%08x, eax = %08x ebx = %08x ecx = %08x edx = %08x\0A\00"
define void @dumpregs(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = bitcast i32* %7 to i8*
%12 = icmp ugt i32 %1, %2
br i1 %12, label %23, label %13
13: ; preds = %3, %13
%14 = phi i32 [ %21, %13 ], [ %1, %3 ]
%15 = call i32 @cpuid(i32 %0, i32 %14, i32* %4, i32* %5, i32* %6, i32* %7)
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %16, i32 %17, i32 %18, i32 %19)
%21 = add i32 %14, 1
%22 = icmp ugt i32 %21, %2
br i1 %22, label %23, label %13
23: ; preds = %13, %3
%24 = call i32 @putchar(i32 10)
ret void
}