#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 *, char *);
void binString(int n) {
  char bin[17];
  int x;
  for (x = 0; x < 16; x++) {
    bin[x] = n & 0x8000 ? '1' : '0';
    n <<= 1;
  }
  bin[16] = '\0';
  printf("%s", bin);
}


x86 assembly (clang, -O0):
<binString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x10,-0x24(%rbp)
jge    1166 <binString+0x56>
mov    -0x4(%rbp),%edx
and    $0x8000,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1122 <binString+0x12>
movb   $0x0,-0x10(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binString>:
sub    $0x18,%rsp
movd   %edi,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xedb(%rip),%xmm1
pand   %xmm0,%xmm1
movdqa 0xedf(%rip),%xmm2
pand   %xmm0,%xmm2
movdqa 0xee3(%rip),%xmm3
pand   %xmm0,%xmm3
pand   0xee7(%rip),%xmm0
pxor   %xmm4,%xmm4
pcmpeqd %xmm4,%xmm0
pcmpeqd %xmm4,%xmm3
packssdw %xmm0,%xmm3
pcmpeqd %xmm4,%xmm2
pcmpeqd %xmm4,%xmm1
packssdw %xmm2,%xmm1
packsswb %xmm3,%xmm1
paddb  0xecf(%rip),%xmm1
movdqa %xmm1,(%rsp)
movb   $0x0,0x10(%rsp)
lea    0xece(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @binString(i32 %0) {
%2 = alloca [17 x i8]
%3 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%4 = insertelement <16 x i32> poison, i32 %0, i64 0
%5 = shufflevector <16 x i32> %4, <16 x i32> poison, <16 x i32> zeroinitializer
%6 = and <16 x i32> %5, <i32 32768, i32 16384, i32 8192, i32 4096, i32 2048, i32 1024, i32 512, i32 256, i32 128, i32 64, i32 32, i32 16, i32 8, i32 4, i32 2, i32 1>
%7 = icmp eq <16 x i32> %6, zeroinitializer
%8 = select <16 x i1> %7, <16 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <16 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%9 = bitcast [17 x i8]* %2 to <16 x i8>*
store <16 x i8> %8, <16 x i8>* %9
%10 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 16
store i8 0, i8* %10
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}