#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 int CHAR_BIT;
int /*<<< orphan*/ printf(char *, unsigned int);
void print_byte(int num) {
  unsigned n_characters;
  unsigned n_bit;
  unsigned mask;
  int ch;
  n_characters = sizeof(int);
  n_bit = n_characters * CHAR_BIT;
  mask = 0xFF << (n_bit - CHAR_BIT);
  for (ch = 0; ch < n_characters; ++ch) {
    printf("%02x ", (unsigned)(num & mask) >> (n_bit - CHAR_BIT));
    num <<= CHAR_BIT;
  }
}


x86 assembly (clang, -O0):
<print_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x4,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2eb4(%rip),%rcx
imul   (%rcx),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    0x2ea4(%rip),%rax
sub    (%rax),%ecx
mov    $0xff,%eax
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    119a <print_byte+0x8a>
mov    -0x4(%rbp),%esi
and    -0x10(%rbp),%esi
mov    -0xc(%rbp),%ecx
mov    0x2e75(%rip),%rax
sub    (%rax),%ecx
shr    %cl,%esi
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%ecx
mov    -0x4(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114f <print_byte+0x3f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_byte>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%ebx
mov    0x2ebf(%rip),%r15
mov    (%r15),%eax
lea    (%rax,%rax,2),%ecx
mov    %eax,%ebp
shl    $0x2,%ebp
mov    $0xff,%r12d
shl    %cl,%r12d
mov    %r12d,%esi
and    %edi,%esi
shr    %cl,%esi
lea    0xebd(%rip),%r14
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r15),%ecx
shl    %cl,%ebx
mov    %ebx,%esi
and    %r12d,%esi
mov    %ebp,%eax
sub    %ecx,%eax
mov    %eax,%ecx
shr    %cl,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r15),%ecx
shl    %cl,%ebx
mov    %ebx,%esi
and    %r12d,%esi
mov    %ebp,%eax
sub    %ecx,%eax
mov    %eax,%ecx
shr    %cl,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r15),%ecx
shl    %cl,%ebx
and    %r12d,%ebx
sub    %ecx,%ebp
mov    %ebp,%ecx
shr    %cl,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@CHAR_BIT = global i32 0
@.str = [6 x i8] c"%02x \00"
define void @print_byte(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 4, i32* %3
%7 = load i32, i32* %3
%8 = load i32, i32* @CHAR_BIT
%9 = mul i32 %7, %8
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = load i32, i32* @CHAR_BIT
%12 = sub i32 %10, %11
%13 = shl i32 255, %12
store i32 %13, i32* %5
store i32 0, i32* %6
br label %14
14: ; preds = %30, %1
%15 = load i32, i32* %6
%16 = load i32, i32* %3
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %33
18: ; preds = %14
%19 = load i32, i32* %2
%20 = load i32, i32* %5
%21 = and i32 %19, %20
%22 = load i32, i32* %4
%23 = load i32, i32* @CHAR_BIT
%24 = sub i32 %22, %23
%25 = lshr i32 %21, %24
%26 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @CHAR_BIT
%28 = load i32, i32* %2
%29 = shl i32 %28, %27
store i32 %29, i32* %2
br label %30
30: ; preds = %18
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %14
33: ; preds = %14
ret void
}

LLVM IR (-O2):
@CHAR_BIT = global i32 0
@.str = [6 x i8] c"%02x \00"
define void @print_byte(i32 %0) {
%2 = load i32, i32* @CHAR_BIT
%3 = shl i32 %2, 2
%4 = mul i32 %2, 3
%5 = shl i32 255, %4
%6 = and i32 %5, %0
%7 = mul i32 %2, 3
%8 = lshr i32 %6, %7
%9 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @CHAR_BIT
%11 = shl i32 %0, %10
%12 = and i32 %11, %5
%13 = sub i32 %3, %10
%14 = lshr i32 %12, %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @CHAR_BIT
%17 = shl i32 %11, %16
%18 = and i32 %17, %5
%19 = sub i32 %3, %16
%20 = lshr i32 %18, %19
%21 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @CHAR_BIT
%23 = shl i32 %17, %22
%24 = and i32 %23, %5
%25 = sub i32 %3, %22
%26 = lshr i32 %24, %25
%27 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %26)
ret void
}