#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 display_binary(int x) {
  int c, v = 0x1000;
  for (c = 0; c < 13; c++) {
    if (x & v)
      putchar('1');
    else
      putchar('0');
    v >>= 1;
  }
}


x86 assembly (clang, -O0):
<display_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1000,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xd,-0x8(%rbp)
jge    1172 <display_binary+0x62>
mov    -0x4(%rbp),%eax
and    -0xc(%rbp),%eax
cmp    $0x0,%eax
je     1151 <display_binary+0x41>
mov    $0x31,%edi
call   1030 <putchar@plt>
jmp    115b <display_binary+0x4b>
mov    $0x30,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1129 <display_binary+0x19>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_binary>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%eax
and    $0x1000,%eax
cmp    $0x1,%eax
mov    $0x31,%ebp
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x800,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x400,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x200,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x100,%eax
cmp    $0x1,%eax
sbb    $0x0,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
movd   %ebx,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xe5d(%rip),%xmm1
pand   %xmm0,%xmm1
pand   0xe61(%rip),%xmm0
pxor   %xmm2,%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm1
packssdw %xmm0,%xmm1
packsswb %xmm1,%xmm1
pmovmskb %xmm1,%ebx
mov    %ebx,%eax
and    $0x2,%al
shr    %al
mov    %al,0x7(%rsp)
mov    %ebx,%r14d
and    $0x4,%r14b
shr    $0x2,%r14b
mov    %ebx,%r15d
and    $0x8,%r15b
shr    $0x3,%r15b
mov    %ebx,%r12d
and    $0x10,%r12b
shr    $0x4,%r12b
mov    %ebx,%r13d
and    $0x20,%r13b
shr    $0x5,%r13b
mov    %ebx,%ebp
and    $0x40,%bpl
shr    $0x6,%bpl
mov    %ebx,%eax
shr    $0x7,%al
movzbl %al,%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
movzbl %bpl,%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
movzbl %r13b,%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
movzbl %r12b,%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
movzbl %r15b,%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
movzbl %r14b,%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
movzbl 0x7(%rsp),%edi
xor    $0x31,%edi
call   1030 <putchar@plt>
and    $0x1,%ebx
xor    $0x31,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
define void @display_binary(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 4096, i32* %4
store i32 0, i32* %3
br label %5
5: ; preds = %20, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 13
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = load i32, i32* %2
%10 = load i32, i32* %4
%11 = and i32 %9, %10
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 @putchar(i8 signext 49)
br label %17
15: ; preds = %8
%16 = call i32 @putchar(i8 signext 48)
br label %17
17: ; preds = %15, %13
%18 = load i32, i32* %4
%19 = ashr i32 %18, 1
store i32 %19, i32* %4
br label %20
20: ; preds = %17
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %5
23: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @display_binary(i32 %0) {
%2 = and i32 %0, 4096
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i8 48, i8 49
%5 = tail call i32 @putchar(i8 signext %4)
%6 = and i32 %0, 2048
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8 48, i8 49
%9 = tail call i32 @putchar(i8 signext %8)
%10 = and i32 %0, 1024
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i8 48, i8 49
%13 = tail call i32 @putchar(i8 signext %12)
%14 = and i32 %0, 512
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i8 48, i8 49
%17 = tail call i32 @putchar(i8 signext %16)
%18 = and i32 %0, 256
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i8 48, i8 49
%21 = tail call i32 @putchar(i8 signext %20)
%22 = insertelement <8 x i32> poison, i32 %0, i64 0
%23 = shufflevector <8 x i32> %22, <8 x i32> poison, <8 x i32> zeroinitializer
%24 = and <8 x i32> %23, <i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64, i32 128>
%25 = icmp eq <8 x i32> %24, zeroinitializer
%26 = extractelement <8 x i1> %25, i64 7
%27 = select i1 %26, i8 48, i8 49
%28 = tail call i32 @putchar(i8 signext %27)
%29 = extractelement <8 x i1> %25, i64 6
%30 = select i1 %29, i8 48, i8 49
%31 = tail call i32 @putchar(i8 signext %30)
%32 = extractelement <8 x i1> %25, i64 5
%33 = select i1 %32, i8 48, i8 49
%34 = tail call i32 @putchar(i8 signext %33)
%35 = extractelement <8 x i1> %25, i64 4
%36 = select i1 %35, i8 48, i8 49
%37 = tail call i32 @putchar(i8 signext %36)
%38 = extractelement <8 x i1> %25, i64 3
%39 = select i1 %38, i8 48, i8 49
%40 = tail call i32 @putchar(i8 signext %39)
%41 = extractelement <8 x i1> %25, i64 2
%42 = select i1 %41, i8 48, i8 49
%43 = tail call i32 @putchar(i8 signext %42)
%44 = extractelement <8 x i1> %25, i64 1
%45 = select i1 %44, i8 48, i8 49
%46 = tail call i32 @putchar(i8 signext %45)
%47 = extractelement <8 x i1> %25, i64 0
%48 = select i1 %47, i8 48, i8 49
%49 = tail call i32 @putchar(i8 signext %48)
ret void
}