#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*/ putchar(char);
void ut_print_binary(unsigned long src) {
  int i;
  for (i = 0; i < 16; i++) {
    if (src & 1 << 15)
      putchar('x');
    else
      putchar('-');
    src <<= 1;
    if (!((i + 1) % 4))
      putchar(' ');
  }
}


x86 assembly (clang, -O0):
<ut_print_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    119a <ut_print_binary+0x8a>
mov    -0x8(%rbp),%rax
and    $0x8000,%rax
cmp    $0x0,%rax
je     1150 <ut_print_binary+0x40>
mov    $0x78,%edi
call   1030 <putchar@plt>
jmp    115a <ut_print_binary+0x4a>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1187 <ut_print_binary+0x77>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    118c <ut_print_binary+0x7c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <ut_print_binary+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ut_print_binary>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0x1,%ebp
mov    $0x2d,%r14d
jmp    113b <ut_print_binary+0x2b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %rbx,%rbx
add    $0x1,%ebp
cmp    $0x11,%ebp
je     1161 <ut_print_binary+0x51>
test   $0x8000,%ebx
mov    $0x78,%edi
cmove  %r14d,%edi
call   1030 <putchar@plt>
test   $0x3,%bpl
jne    1130 <ut_print_binary+0x20>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1130 <ut_print_binary+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @ut_print_binary(i64 %0) {
%2 = alloca i64
%3 = alloca i32
store i64 %0, i64* %2
store i32 0, i32* %3
br label %4
4: ; preds = %25, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 16
br i1 %6, label %7, label %28
7: ; preds = %4
%8 = load i64, i64* %2
%9 = and i64 %8, 32768
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @putchar(i8 signext 120)
br label %15
13: ; preds = %7
%14 = call i32 @putchar(i8 signext 45)
br label %15
15: ; preds = %13, %11
%16 = load i64, i64* %2
%17 = shl i64 %16, 1
store i64 %17, i64* %2
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
%20 = srem i32 %19, 4
%21 = icmp ne i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %15
%23 = call i32 @putchar(i8 signext 32)
br label %24
24: ; preds = %22, %15
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %4
28: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @ut_print_binary(i64 %0) {
br label %2
2: ; preds = %1, %15
%3 = phi i32 [ 0, %1 ], [ %10, %15 ]
%4 = phi i64 [ %0, %1 ], [ %9, %15 ]
%5 = and i64 %4, 32768
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i8 45, i8 120
%8 = tail call i32 @putchar(i8 signext %7)
%9 = shl i64 %4, 1
%10 = add nuw nsw i32 %3, 1
%11 = and i32 %10, 3
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = tail call i32 @putchar(i8 signext 32)
br label %15
15: ; preds = %2, %13
%16 = icmp eq i32 %10, 16
br i1 %16, label %17, label %2
17: ; preds = %15
ret void
}