#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 SHRT_MIN;
int /*<<< orphan*/ printf(char *, char);
void printBinary(unsigned short decimal) {
  int mask = SHRT_MIN, count = 0;
  for (count = 0; count < 16; count++) {
    char ch = (decimal & mask) ? '1' : '0';
    decimal = decimal << 1;
    printf("%c", ch);
  }
}


x86 assembly (clang, -O0):
<printBinary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    0x2eba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    1186 <printBinary+0x76>
movzwl -0x2(%rbp),%edx
and    -0x8(%rbp),%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0xd(%rbp)
movzwl -0x2(%rbp),%eax
shl    $0x1,%eax
mov    %ax,-0x2(%rbp)
lea    0xe91(%rip),%rdi
movsbl -0xd(%rbp),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1139 <printBinary+0x29>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBinary>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%ebx
mov    0x2ebf(%rip),%rax
mov    (%rax),%r12d
mov    %r12d,%eax
and    %edi,%eax
lea    (%rbx,%rbx,1),%ebp
cmp    $0x1,%eax
mov    $0x31,%r14d
mov    $0x31,%esi
sbb    $0x0,%esi
lea    0xebc(%rip),%r15
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
lea    0x0(,%rbx,4),%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
lea    0x0(,%rbx,8),%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
mov    %ebx,%ebp
shl    $0x4,%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
mov    %ebx,%ebp
shl    $0x5,%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
mov    %ebx,%ebp
shl    $0x6,%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
mov    %ebx,%ebp
shl    $0x7,%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
mov    %ebx,%ebp
shl    $0x8,%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
mov    %ebx,%ebp
shl    $0x9,%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
mov    %ebx,%ebp
shl    $0xa,%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
mov    %ebx,%ebp
shl    $0xb,%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
mov    %ebx,%ebp
shl    $0xc,%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
mov    %ebx,%ebp
shl    $0xd,%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
mov    %ebx,%ebp
shl    $0xe,%ebp
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebp
movzwl %bp,%eax
shl    $0xf,%ebx
cmp    $0x1,%eax
mov    $0x31,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
and    %r12d,%ebx
movzwl %bx,%eax
cmp    $0x1,%eax
sbb    $0x0,%r14d
mov    %r15,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@SHRT_MIN = global i32 0
@.str = [3 x i8] c"%c\00"
define void @printBinary(i16 zeroext %0) {
%2 = load i32, i32* @SHRT_MIN
%3 = zext i16 %0 to i32
%4 = and i32 %2, %3
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i8 48, i8 49
%7 = shl i16 %0, 1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %6)
%9 = zext i16 %7 to i32
%10 = and i32 %2, %9
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i8 48, i8 49
%13 = shl i16 %0, 2
%14 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %12)
%15 = zext i16 %13 to i32
%16 = and i32 %2, %15
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i8 48, i8 49
%19 = shl i16 %0, 3
%20 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %18)
%21 = zext i16 %19 to i32
%22 = and i32 %2, %21
%23 = icmp eq i32 %22, 0
%24 = select i1 %23, i8 48, i8 49
%25 = shl i16 %0, 4
%26 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %24)
%27 = zext i16 %25 to i32
%28 = and i32 %2, %27
%29 = icmp eq i32 %28, 0
%30 = select i1 %29, i8 48, i8 49
%31 = shl i16 %0, 5
%32 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %30)
%33 = zext i16 %31 to i32
%34 = and i32 %2, %33
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i8 48, i8 49
%37 = shl i16 %0, 6
%38 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %36)
%39 = zext i16 %37 to i32
%40 = and i32 %2, %39
%41 = icmp eq i32 %40, 0
%42 = select i1 %41, i8 48, i8 49
%43 = shl i16 %0, 7
%44 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %42)
%45 = zext i16 %43 to i32
%46 = and i32 %2, %45
%47 = icmp eq i32 %46, 0
%48 = select i1 %47, i8 48, i8 49
%49 = shl i16 %0, 8
%50 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %48)
%51 = zext i16 %49 to i32
%52 = and i32 %2, %51
%53 = icmp eq i32 %52, 0
%54 = select i1 %53, i8 48, i8 49
%55 = shl i16 %0, 9
%56 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %54)
%57 = zext i16 %55 to i32
%58 = and i32 %2, %57
%59 = icmp eq i32 %58, 0
%60 = select i1 %59, i8 48, i8 49
%61 = shl i16 %0, 10
%62 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %60)
%63 = zext i16 %61 to i32
%64 = and i32 %2, %63
%65 = icmp eq i32 %64, 0
%66 = select i1 %65, i8 48, i8 49
%67 = shl i16 %0, 11
%68 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %66)
%69 = zext i16 %67 to i32
%70 = and i32 %2, %69
%71 = icmp eq i32 %70, 0
%72 = select i1 %71, i8 48, i8 49
%73 = shl i16 %0, 12
%74 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %72)
%75 = zext i16 %73 to i32
%76 = and i32 %2, %75
%77 = icmp eq i32 %76, 0
%78 = select i1 %77, i8 48, i8 49
%79 = shl i16 %0, 13
%80 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %78)
%81 = zext i16 %79 to i32
%82 = and i32 %2, %81
%83 = icmp eq i32 %82, 0
%84 = select i1 %83, i8 48, i8 49
%85 = shl i16 %0, 14
%86 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %84)
%87 = zext i16 %85 to i32
%88 = and i32 %2, %87
%89 = icmp eq i32 %88, 0
%90 = select i1 %89, i8 48, i8 49
%91 = shl i16 %0, 15
%92 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %90)
%93 = zext i16 %91 to i32
%94 = and i32 %2, %93
%95 = icmp eq i32 %94, 0
%96 = select i1 %95, i8 48, i8 49
%97 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %96)
ret void
}