#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 */
long hex_to_dec(char *);
int /*<<< orphan*/ putchar(char);
void print_hex(char hex[]) {
  long number;
  int buffer[8];
  int length = 0;
  long temp;
  int i;
  number = hex_to_dec(hex);
  while (number != 0) {
    buffer[7 - length] = number % 2;
    temp = number / 2;
    number = temp;
    length++;
  }
  for (i = 0; i < 8; i++) {
    if (buffer[i] == 1) {
      putchar('#');
    } else {
      putchar(' ');
    }
  }
}


x86 assembly (clang, -O0):
<print_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <hex_to_dec@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1191 <print_hex+0x71>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %edx,%ecx
mov    $0x7,%eax
sub    -0x34(%rbp),%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1140 <print_hex+0x20>
movl   $0x0,-0x44(%rbp)
cmpl   $0x8,-0x44(%rbp)
jge    11dd <print_hex+0xbd>
movslq -0x44(%rbp),%rax
cmpl   $0x1,-0x30(%rbp,%rax,4)
jne    11c0 <print_hex+0xa0>
mov    $0x23,%edi
call   1030 <putchar@plt>
jmp    11ca <print_hex+0xaa>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11cf <print_hex+0xaf>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1198 <print_hex+0x78>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_hex>:
sub    $0x28,%rsp
call   1040 <hex_to_dec@plt>
test   %rax,%rax
je     1177 <print_hex+0x57>
lea    0x1c(%rsp),%rcx
mov    %rax,%rdx
cs nopw 0x0(%rax,%rax,1)
shr    $0x3f,%rdx
add    %rax,%rdx
mov    %edx,%esi
and    $0xfffffffe,%esi
mov    %eax,%edi
sub    %esi,%edi
mov    %edi,(%rcx)
sar    %rdx
add    $0x1,%rax
add    $0xfffffffffffffffc,%rcx
cmp    $0x3,%rax
mov    %rdx,%rax
jae    1140 <print_hex+0x20>
xor    %eax,%eax
cmpl   $0x1,(%rsp)
sete   %al
lea    (%rax,%rax,2),%eax
add    $0x20,%eax
jmp    1179 <print_hex+0x59>
mov    $0x23,%al
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
cmpl   $0x1,0x4(%rsp)
sete   %al
lea    (%rax,%rax,2),%edi
or     $0x20,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
cmpl   $0x1,0x8(%rsp)
sete   %al
lea    (%rax,%rax,2),%edi
or     $0x20,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
cmpl   $0x1,0xc(%rsp)
sete   %al
lea    (%rax,%rax,2),%edi
or     $0x20,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
cmpl   $0x1,0x10(%rsp)
sete   %al
lea    (%rax,%rax,2),%edi
or     $0x20,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
cmpl   $0x1,0x14(%rsp)
sete   %al
lea    (%rax,%rax,2),%edi
or     $0x20,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
cmpl   $0x1,0x18(%rsp)
sete   %al
lea    (%rax,%rax,2),%edi
or     $0x20,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
cmpl   $0x1,0x1c(%rsp)
sete   %al
lea    (%rax,%rax,2),%edi
or     $0x20,%edi
add    $0x28,%rsp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
define void @print_hex(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca [8 x i32]
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %5
%8 = load i8*, i8** %2
%9 = call i64 @hex_to_dec(i8* %8)
store i64 %9, i64* %3
br label %10
10: ; preds = %13, %1
%11 = load i64, i64* %3
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = load i64, i64* %3
%15 = srem i64 %14, 2
%16 = trunc i64 %15 to i32
%17 = load i32, i32* %5
%18 = sub nsw i32 7, %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %19
store i32 %16, i32* %20
%21 = load i64, i64* %3
%22 = sdiv i64 %21, 2
store i64 %22, i64* %6
%23 = load i64, i64* %6
store i64 %23, i64* %3
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %10
26: ; preds = %10
store i32 0, i32* %7
br label %27
27: ; preds = %41, %26
%28 = load i32, i32* %7
%29 = icmp slt i32 %28, 8
br i1 %29, label %30, label %44
30: ; preds = %27
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = call i32 @putchar(i8 signext 35)
br label %40
38: ; preds = %30
%39 = call i32 @putchar(i8 signext 32)
br label %40
40: ; preds = %38, %36
br label %41
41: ; preds = %40
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %27
44: ; preds = %27
ret void
}

LLVM IR (-O2):
define void @print_hex(i8* %0) {
%2 = alloca [8 x i32]
%3 = bitcast [8 x i32]* %2 to i8*
%4 = tail call i64 @hex_to_dec(i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %22, label %11
6: ; preds = %11
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 1
%10 = select i1 %9, i8 35, i8 32
br label %22
11: ; preds = %1, %11
%12 = phi i64 [ %19, %11 ], [ 0, %1 ]
%13 = phi i64 [ %18, %11 ], [ %4, %1 ]
%14 = srem i64 %13, 2
%15 = trunc i64 %14 to i32
%16 = sub nsw i64 7, %12
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %16
store i32 %15, i32* %17
%18 = sdiv i64 %13, 2
%19 = add nuw i64 %12, 1
%20 = add i64 %13, 1
%21 = icmp ult i64 %20, 3
br i1 %21, label %6, label %11
22: ; preds = %6, %1
%23 = phi i8 [ 35, %1 ], [ %10, %6 ]
%24 = tail call i32 @putchar(i8 signext %23)
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 1
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 1
%28 = select i1 %27, i8 35, i8 32
%29 = tail call i32 @putchar(i8 signext %28)
%30 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 2
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 1
%33 = select i1 %32, i8 35, i8 32
%34 = tail call i32 @putchar(i8 signext %33)
%35 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 3
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, 1
%38 = select i1 %37, i8 35, i8 32
%39 = tail call i32 @putchar(i8 signext %38)
%40 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 4
%41 = load i32, i32* %40
%42 = icmp eq i32 %41, 1
%43 = select i1 %42, i8 35, i8 32
%44 = tail call i32 @putchar(i8 signext %43)
%45 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 5
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, 1
%48 = select i1 %47, i8 35, i8 32
%49 = tail call i32 @putchar(i8 signext %48)
%50 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 6
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 1
%53 = select i1 %52, i8 35, i8 32
%54 = tail call i32 @putchar(i8 signext %53)
%55 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 7
%56 = load i32, i32* %55
%57 = icmp eq i32 %56, 1
%58 = select i1 %57, i8 35, i8 32
%59 = tail call i32 @putchar(i8 signext %58)
ret void
}