#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 */
unsigned char inb(int);
int /*<<< orphan*/ outb(unsigned char, int);
int /*<<< orphan*/ print_debug(char *);
int /*<<< orphan*/ print_debug_hex8(unsigned char);
void print_reg(unsigned char index) {
  unsigned char data;
  outb(index, 0x2e);
  data = inb(0x2f);
  print_debug("0x");
  print_debug_hex8(index);
  print_debug(": 0x");
  print_debug_hex8(data);
  print_debug("\n");
  return;
}


x86 assembly (clang, -O0):
<print_reg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0x2e,%esi
movzbl -0x1(%rbp),%edi
call   1040 <outb@plt>
mov    $0x2f,%edi
call   1050 <inb@plt>
mov    %al,-0x2(%rbp)
lea    0xe92(%rip),%rdi
call   1060 <print_debug@plt>
movzbl -0x1(%rbp),%edi
call   1030 <print_debug_hex8@plt>
lea    0xe7b(%rip),%rdi
call   1060 <print_debug@plt>
movzbl -0x2(%rbp),%edi
call   1030 <print_debug_hex8@plt>
lea    0xe6b(%rip),%rdi
call   1060 <print_debug@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_reg>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x2e,%esi
call   1040 <outb@plt>
mov    $0x2f,%edi
call   1050 <inb@plt>
mov    %eax,%ebp
lea    0xea0(%rip),%rdi
call   1060 <print_debug@plt>
mov    %ebx,%edi
call   1030 <print_debug_hex8@plt>
lea    0xe8b(%rip),%rdi
call   1060 <print_debug@plt>
movzbl %bpl,%edi
call   1030 <print_debug_hex8@plt>
lea    0xe7b(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <print_debug@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"0x\00"
@.str.1 = [5 x i8] c": 0x\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_reg(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = call i32 @outb(i8 zeroext %4, i32 46)
%6 = call zeroext i8 @inb(i32 47)
store i8 %6, i8* %3
%7 = call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = load i8, i8* %2
%9 = call i32 @print_debug_hex8(i8 zeroext %8)
%10 = call i32 @print_debug(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = load i8, i8* %3
%12 = call i32 @print_debug_hex8(i8 zeroext %11)
%13 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"0x\00"
@.str.1 = [5 x i8] c": 0x\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_reg(i8 zeroext %0) {
%2 = tail call i32 @outb(i8 zeroext %0, i32 46)
%3 = tail call zeroext i8 @inb(i32 47)
%4 = tail call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @print_debug_hex8(i8 zeroext %0)
%6 = tail call i32 @print_debug(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @print_debug_hex8(i8 zeroext %3)
%8 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}