#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 */
typedef scalar_t__ n;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void print_binary(signed short int n) {
  size_t i;
  for (i = sizeof(signed short int) * 8; i > 0; i--)
    printf("%d", (((n) & ((signed short int)1 << (i - 1))) && 1));
}


x86 assembly (clang, -O0):
<print_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movq   $0x10,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jbe    118c <print_binary+0x7c>
movswl -0x2(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x18(%rbp),%ecx
and    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     1167 <print_binary+0x57>
mov    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1167 <print_binary+0x57>
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%esi
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1127 <print_binary+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_binary>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
movzwl %r14w,%ebp
mov    %ebp,%esi
shr    $0xf,%esi
lea    0xed9(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0xe,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0xd,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0xc,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0xb,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0xa,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0x9,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0x8,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0x7,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %ebp,%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
shr    %ebp
and    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
and    $0x1,%r14d
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @print_binary(i16 signext %0) {
%2 = alloca i16
%3 = alloca i64
store i16 %0, i16* %2
store i64 16, i64* %3
br label %4
4: ; preds = %21, %1
%5 = load i64, i64* %3
%6 = icmp ugt i64 %5, 0
br i1 %6, label %7, label %24
7: ; preds = %4
%8 = load i16, i16* %2
%9 = sext i16 %8 to i32
%10 = load i64, i64* %3
%11 = sub i64 %10, 1
%12 = trunc i64 %11 to i32
%13 = shl i32 1, %12
%14 = and i32 %9, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %7
br label %17
17: ; preds = %16, %7
%18 = phi i1 [ false, %7 ], [ true, %16 ]
%19 = zext i1 %18 to i32
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %17
%22 = load i64, i64* %3
%23 = add i64 %22, -1
store i64 %23, i64* %3
br label %4
24: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @print_binary(i16 signext %0) {
%2 = zext i16 %0 to i32
%3 = lshr i32 %2, 15
%4 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = lshr i32 %2, 14
%6 = and i32 %5, 1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = lshr i32 %2, 13
%9 = and i32 %8, 1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = lshr i32 %2, 12
%12 = and i32 %11, 1
%13 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = lshr i32 %2, 11
%15 = and i32 %14, 1
%16 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = lshr i32 %2, 10
%18 = and i32 %17, 1
%19 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = lshr i32 %2, 9
%21 = and i32 %20, 1
%22 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = lshr i32 %2, 8
%24 = and i32 %23, 1
%25 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = lshr i32 %2, 7
%27 = and i32 %26, 1
%28 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = lshr i32 %2, 6
%30 = and i32 %29, 1
%31 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = lshr i32 %2, 5
%33 = and i32 %32, 1
%34 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = lshr i32 %2, 4
%36 = and i32 %35, 1
%37 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = lshr i32 %2, 3
%39 = and i32 %38, 1
%40 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = lshr i32 %2, 2
%42 = and i32 %41, 1
%43 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = lshr i32 %2, 1
%45 = and i32 %44, 1
%46 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %45)
%47 = and i32 %2, 1
%48 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %47)
ret void
}