#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 *);
void hex_to_binary(unsigned hex) {
  unsigned i;
  for (i = 0; i < 8; i++) {
    if (hex & (1 << i)) {
      printf("1");
    } else {
      printf("0");
    }
    if ((i + 1) % 8 == 0) {
      printf(" ");
    }
  }
}


x86 assembly (clang, -O0):
<hex_to_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jae    1194 <hex_to_binary+0x84>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1157 <hex_to_binary+0x47>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
jmp    1163 <hex_to_binary+0x53>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    1181 <hex_to_binary+0x71>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
jmp    1186 <hex_to_binary+0x76>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <hex_to_binary+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_to_binary>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x2,%eax
cmp    $0x1,%eax
mov    $0x31,%ebp
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x4,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x8,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x10,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x20,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x40,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
and    $0x80,%ebx
cmp    $0x1,%ebx
sbb    $0x0,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
define void @hex_to_binary(i32 %0) {
%2 = and i32 %0, 1
%3 = or i32 %2, 48
%4 = tail call i32 @putchar(i32 %3)
%5 = and i32 %0, 2
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i32 48, i32 49
%8 = tail call i32 @putchar(i32 %7)
%9 = and i32 %0, 4
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i32 48, i32 49
%12 = tail call i32 @putchar(i32 %11)
%13 = and i32 %0, 8
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i32 48, i32 49
%16 = tail call i32 @putchar(i32 %15)
%17 = and i32 %0, 16
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i32 48, i32 49
%20 = tail call i32 @putchar(i32 %19)
%21 = and i32 %0, 32
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i32 48, i32 49
%24 = tail call i32 @putchar(i32 %23)
%25 = and i32 %0, 64
%26 = icmp eq i32 %25, 0
%27 = select i1 %26, i32 48, i32 49
%28 = tail call i32 @putchar(i32 %27)
%29 = and i32 %0, 128
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i32 48, i32 49
%32 = tail call i32 @putchar(i32 %31)
%33 = tail call i32 @putchar(i32 32)
ret void
}