#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*/ puts(char *);
void binString(int value) {
  char bin[17];
  int x;
  for (x = 15; x >= 0; x--) {
    bin[x] = value % 2 ? '1' : '0';
    value >>= 1;
  }
  bin[16] = '\0';
  puts(bin);
}


x86 assembly (clang, -O0):
<binString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xf,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     1168 <binString+0x58>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
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
sar    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1122 <binString+0x12>
movb   $0x0,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <puts@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binString>:
sub    $0x18,%rsp
mov    %edi,%eax
and    $0x1,%al
or     $0x30,%al
mov    %al,0xf(%rsp)
mov    %edi,%eax
shr    %al
and    $0x1,%al
or     $0x30,%al
mov    %al,0xe(%rsp)
mov    %edi,%eax
shr    $0x2,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0xd(%rsp)
mov    %edi,%eax
shr    $0x3,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0xc(%rsp)
mov    %edi,%eax
shr    $0x4,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0xb(%rsp)
mov    %edi,%eax
shr    $0x5,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0xa(%rsp)
mov    %edi,%eax
shr    $0x6,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x9(%rsp)
mov    %edi,%eax
shr    $0x7,%al
or     $0x30,%al
mov    %al,0x8(%rsp)
mov    %edi,%eax
shr    $0x8,%eax
and    $0x1,%al
or     $0x30,%al
mov    %al,0x7(%rsp)
mov    %edi,%eax
shr    $0x9,%eax
and    $0x1,%al
or     $0x30,%al
mov    %al,0x6(%rsp)
mov    %edi,%eax
shr    $0xa,%eax
and    $0x1,%al
or     $0x30,%al
mov    %al,0x5(%rsp)
mov    %edi,%eax
shr    $0xb,%eax
and    $0x1,%al
or     $0x30,%al
mov    %al,0x4(%rsp)
mov    %edi,%eax
shr    $0xc,%eax
and    $0x1,%al
or     $0x30,%al
mov    %al,0x3(%rsp)
mov    %edi,%eax
shr    $0xd,%eax
and    $0x1,%al
or     $0x30,%al
mov    %al,0x2(%rsp)
mov    %edi,%eax
shr    $0xe,%eax
and    $0x1,%al
or     $0x30,%al
mov    %al,0x1(%rsp)
shr    $0xf,%edi
and    $0x1,%dil
or     $0x30,%dil
mov    %dil,(%rsp)
movb   $0x0,0x10(%rsp)
mov    %rsp,%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @binString(i32 %0) {
%2 = alloca i32
%3 = alloca [17 x i8]
%4 = alloca i32
store i32 %0, i32* %2
store i32 15, i32* %4
br label %5
5: ; preds = %20, %1
%6 = load i32, i32* %4
%7 = icmp sge i32 %6, 0
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = load i32, i32* %2
%10 = srem i32 %9, 2
%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 = ashr 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 @puts(i8* %25)
ret void
}

LLVM IR (-O2):
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 = trunc i32 %0 to i8
%5 = and i8 %4, 1
%6 = or i8 %5, 48
%7 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 15
store i8 %6, i8* %7
%8 = trunc i32 %0 to i8
%9 = lshr i8 %8, 1
%10 = and i8 %9, 1
%11 = or i8 %10, 48
%12 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 14
store i8 %11, i8* %12
%13 = trunc i32 %0 to i8
%14 = lshr i8 %13, 2
%15 = and i8 %14, 1
%16 = or i8 %15, 48
%17 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 13
store i8 %16, i8* %17
%18 = trunc i32 %0 to i8
%19 = lshr i8 %18, 3
%20 = and i8 %19, 1
%21 = or i8 %20, 48
%22 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 12
store i8 %21, i8* %22
%23 = trunc i32 %0 to i8
%24 = lshr i8 %23, 4
%25 = and i8 %24, 1
%26 = or i8 %25, 48
%27 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 11
store i8 %26, i8* %27
%28 = trunc i32 %0 to i8
%29 = lshr i8 %28, 5
%30 = and i8 %29, 1
%31 = or i8 %30, 48
%32 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 10
store i8 %31, i8* %32
%33 = trunc i32 %0 to i8
%34 = lshr i8 %33, 6
%35 = and i8 %34, 1
%36 = or i8 %35, 48
%37 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 9
store i8 %36, i8* %37
%38 = trunc i32 %0 to i8
%39 = lshr i8 %38, 7
%40 = or i8 %39, 48
%41 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 8
store i8 %40, i8* %41
%42 = lshr i32 %0, 8
%43 = trunc i32 %42 to i8
%44 = and i8 %43, 1
%45 = or i8 %44, 48
%46 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 7
store i8 %45, i8* %46
%47 = lshr i32 %0, 9
%48 = trunc i32 %47 to i8
%49 = and i8 %48, 1
%50 = or i8 %49, 48
%51 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 6
store i8 %50, i8* %51
%52 = lshr i32 %0, 10
%53 = trunc i32 %52 to i8
%54 = and i8 %53, 1
%55 = or i8 %54, 48
%56 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 5
store i8 %55, i8* %56
%57 = lshr i32 %0, 11
%58 = trunc i32 %57 to i8
%59 = and i8 %58, 1
%60 = or i8 %59, 48
%61 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 4
store i8 %60, i8* %61
%62 = lshr i32 %0, 12
%63 = trunc i32 %62 to i8
%64 = and i8 %63, 1
%65 = or i8 %64, 48
%66 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 3
store i8 %65, i8* %66
%67 = lshr i32 %0, 13
%68 = trunc i32 %67 to i8
%69 = and i8 %68, 1
%70 = or i8 %69, 48
%71 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 2
store i8 %70, i8* %71
%72 = lshr i32 %0, 14
%73 = trunc i32 %72 to i8
%74 = and i8 %73, 1
%75 = or i8 %74, 48
%76 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 1
store i8 %75, i8* %76
%77 = lshr i32 %0, 15
%78 = trunc i32 %77 to i8
%79 = and i8 %78, 1
%80 = or i8 %79, 48
store i8 %80, i8* %3
%81 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 16
store i8 0, i8* %81
%82 = call i32 @puts(i8* %3)
ret void
}