#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 HexBin(int data) {
  int i;
  for (i = 0; i < 16; i++) {
    printf((data << i) & 0x8000 ? "1" : "0");
    if (i % 4 == 3)
      printf(" ");
  }
}


x86 assembly (clang, -O0):
<HexBin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x10,-0x8(%rbp)
jge    1189 <HexBin+0x79>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    %cl,%eax
mov    %eax,%ecx
and    $0x8000,%ecx
lea    0xebf(%rip),%rdi
lea    0xeb6(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x3,%edx
jne    1176 <HexBin+0x66>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
jmp    117b <HexBin+0x6b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <HexBin+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HexBin>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %ebp,%ebp
lea    0xed0(%rip),%r14
lea    0xec7(%rip),%r15
jmp    1148 <HexBin+0x28>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x10,%ebp
je     1174 <HexBin+0x54>
mov    %ebx,%eax
mov    %ebp,%ecx
shl    %cl,%eax
mov    %r14,%rdi
test   $0x8000,%eax
je     115b <HexBin+0x3b>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %ebp,%eax
not    %eax
test   $0x3,%al
jne    1140 <HexBin+0x20>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1140 <HexBin+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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 @HexBin(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %22, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 16
br i1 %6, label %7, label %25
7: ; preds = %4
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = shl i32 %8, %9
%11 = and i32 %10, 32768
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%15 = call i32 @printf(i8* %14)
%16 = load i32, i32* %3
%17 = srem i32 %16, 4
%18 = icmp eq i32 %17, 3
br i1 %18, label %19, label %21
19: ; preds = %7
%20 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %7
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %4
25: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
define void @HexBin(i32 %0) {
br label %2
2: ; preds = %1, %13
%3 = phi i32 [ 0, %1 ], [ %14, %13 ]
%4 = lshr i32 32768, %3
%5 = and i32 %4, %0
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%8 = tail call i32 @printf(i8* dereferenceable(1) %7)
%9 = and i32 %3, 3
%10 = icmp eq i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @putchar(i32 32)
br label %13
13: ; preds = %2, %11
%14 = add nuw nsw i32 %3, 1
%15 = icmp eq i32 %14, 16
br i1 %15, label %16, label %2
16: ; preds = %13
ret void
}