#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 */
char *malloc(int);
char *dec2bin(long n) {
  int c, k = 0;
  char *result;
  result = malloc(33 * sizeof(char));
  result[32] = '\0';
  for (c = 0; c <= 31; c++) {
    k = n >> c;
    result[31 - c] = (k & 1) ? '1' : '0';
  }
  return result;
}


x86 assembly (clang, -O0):
<dec2bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x21,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,0x20(%rax)
movl   $0x0,-0xc(%rbp)
cmpl   $0x1f,-0xc(%rbp)
jg     118f <dec2bin+0x7f>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sar    %cl,%rax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edx
and    $0x1,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    $0x1f,%ecx
sub    -0xc(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1140 <dec2bin+0x30>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dec2bin>:
push   %rbx
mov    %rdi,%rbx
mov    $0x21,%edi
call   1030 <malloc@plt>
movb   $0x0,0x20(%rax)
movq   %rbx,%xmm0
pshufd $0x44,%xmm0,%xmm1
movdqa 0xecb(%rip),%xmm9
pand   %xmm1,%xmm9
movdqa 0xecd(%rip),%xmm10
pand   %xmm1,%xmm10
movdqa 0xed0(%rip),%xmm4
pand   %xmm1,%xmm4
movdqa 0xed4(%rip),%xmm5
pand   %xmm1,%xmm5
movdqa 0xed8(%rip),%xmm6
pand   %xmm1,%xmm6
movdqa 0xedc(%rip),%xmm7
pand   %xmm1,%xmm7
movdqa 0xee0(%rip),%xmm0
pand   %xmm1,%xmm0
movdqa 0xee4(%rip),%xmm2
pand   %xmm1,%xmm2
pxor   %xmm8,%xmm8
pcmpeqd %xmm8,%xmm2
pshufd $0xb1,%xmm2,%xmm3
pand   %xmm2,%xmm3
pcmpeqd %xmm8,%xmm0
pshufd $0xb1,%xmm0,%xmm2
pand   %xmm0,%xmm2
packssdw %xmm3,%xmm2
pcmpeqd %xmm8,%xmm7
pshufd $0xb1,%xmm7,%xmm0
pand   %xmm7,%xmm0
pcmpeqd %xmm8,%xmm6
pshufd $0xb1,%xmm6,%xmm7
pand   %xmm6,%xmm7
packssdw %xmm0,%xmm7
packssdw %xmm2,%xmm7
pcmpeqd %xmm8,%xmm5
pshufd $0xb1,%xmm5,%xmm0
pand   %xmm5,%xmm0
pcmpeqd %xmm8,%xmm4
pshufd $0xb1,%xmm4,%xmm2
pand   %xmm4,%xmm2
packssdw %xmm0,%xmm2
pcmpeqd %xmm8,%xmm10
pshufd $0xb1,%xmm10,%xmm0
pand   %xmm10,%xmm0
pcmpeqd %xmm8,%xmm9
pshufd $0xb1,%xmm9,%xmm3
pand   %xmm9,%xmm3
packssdw %xmm0,%xmm3
packssdw %xmm2,%xmm3
packsswb %xmm7,%xmm3
movdqa 0xe52(%rip),%xmm9
paddb  %xmm9,%xmm3
movdqa %xmm3,%xmm0
punpcklbw %xmm8,%xmm0
pshufd $0x4e,%xmm0,%xmm0
pshuflw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm0,%xmm0
punpckhbw %xmm8,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
packuswb %xmm0,%xmm3
movdqu %xmm3,0x10(%rax)
movdqa 0xe1f(%rip),%xmm10
pand   %xmm1,%xmm10
movdqa 0xe21(%rip),%xmm11
pand   %xmm1,%xmm11
movdqa 0xe24(%rip),%xmm5
pand   %xmm1,%xmm5
movdqa 0xe28(%rip),%xmm6
pand   %xmm1,%xmm6
movdqa 0xe2c(%rip),%xmm0
pand   %xmm1,%xmm0
movdqa 0xe30(%rip),%xmm7
pand   %xmm1,%xmm7
movdqa 0xe34(%rip),%xmm2
pand   %xmm1,%xmm2
pand   0xe38(%rip),%xmm1
pcmpeqd %xmm8,%xmm1
pshufd $0xb1,%xmm1,%xmm3
pand   %xmm1,%xmm3
pcmpeqd %xmm8,%xmm2
pshufd $0xb1,%xmm2,%xmm4
pand   %xmm2,%xmm4
packssdw %xmm3,%xmm4
pcmpeqd %xmm8,%xmm7
pshufd $0xb1,%xmm7,%xmm2
pand   %xmm7,%xmm2
pcmpeqd %xmm8,%xmm0
pshufd $0xb1,%xmm0,%xmm1
pand   %xmm0,%xmm1
packssdw %xmm2,%xmm1
packssdw %xmm4,%xmm1
pcmpeqd %xmm8,%xmm6
pshufd $0xb1,%xmm6,%xmm0
pand   %xmm6,%xmm0
pcmpeqd %xmm8,%xmm5
pshufd $0xb1,%xmm5,%xmm2
pand   %xmm5,%xmm2
packssdw %xmm0,%xmm2
pcmpeqd %xmm8,%xmm11
pshufd $0xb1,%xmm11,%xmm0
pand   %xmm11,%xmm0
pcmpeqd %xmm8,%xmm10
pshufd $0xb1,%xmm10,%xmm3
pand   %xmm10,%xmm3
packssdw %xmm0,%xmm3
packssdw %xmm2,%xmm3
packsswb %xmm1,%xmm3
paddb  %xmm9,%xmm3
movdqa %xmm3,%xmm0
punpcklbw %xmm8,%xmm0
pshufd $0x4e,%xmm0,%xmm0
pshuflw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm0,%xmm0
punpckhbw %xmm8,%xmm3
pshufd $0x4e,%xmm3,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm0,%xmm1
movdqu %xmm1,(%rax)
pop    %rbx
ret

LLVM IR (-O0):
define i8* @dec2bin(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i64 %0, i64* %2
store i32 0, i32* %4
%6 = call i8* @malloc(i32 33)
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = getelementptr inbounds i8, i8* %7, i64 32
store i8 0, i8* %8
store i32 0, i32* %3
br label %9
9: ; preds = %29, %1
%10 = load i32, i32* %3
%11 = icmp sle i32 %10, 31
br i1 %11, label %12, label %32
12: ; preds = %9
%13 = load i64, i64* %2
%14 = load i32, i32* %3
%15 = zext i32 %14 to i64
%16 = ashr i64 %13, %15
%17 = trunc i64 %16 to i32
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = and i32 %18, 1
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 49, i32 48
%23 = trunc i32 %22 to i8
%24 = load i8*, i8** %5
%25 = load i32, i32* %3
%26 = sub nsw i32 31, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
store i8 %23, i8* %28
br label %29
29: ; preds = %12
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %9
32: ; preds = %9
%33 = load i8*, i8** %5
ret i8* %33
}

LLVM IR (-O2):
define noalias i8* @dec2bin(i64 %0) {
%2 = tail call dereferenceable_or_null(33) i8* @malloc(i32 33)
%3 = getelementptr inbounds i8, i8* %2, i64 32
store i8 0, i8* %3
%4 = insertelement <16 x i64> poison, i64 %0, i64 0
%5 = shufflevector <16 x i64> %4, <16 x i64> poison, <16 x i32> zeroinitializer
%6 = and <16 x i64> %5, <i64 1, i64 2, i64 4, i64 8, i64 16, i64 32, i64 64, i64 128, i64 256, i64 512, i64 1024, i64 2048, i64 4096, i64 8192, i64 16384, i64 32768>
%7 = icmp eq <16 x i64> %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 = shufflevector <16 x i8> %8, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%10 = getelementptr inbounds i8, i8* %2, i64 16
%11 = bitcast i8* %10 to <16 x i8>*
store <16 x i8> %9, <16 x i8>* %11
%12 = and <16 x i64> %5, <i64 65536, i64 131072, i64 262144, i64 524288, i64 1048576, i64 2097152, i64 4194304, i64 8388608, i64 16777216, i64 33554432, i64 67108864, i64 134217728, i64 268435456, i64 536870912, i64 1073741824, i64 2147483648>
%13 = icmp eq <16 x i64> %12, zeroinitializer
%14 = select <16 x i1> %13, <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>
%15 = shufflevector <16 x i8> %14, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%16 = bitcast i8* %2 to <16 x i8>*
store <16 x i8> %15, <16 x i8>* %16
ret i8* %2
}