#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 CHAR_BIT;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ malloc(int);
char *decimal_to_binary(int n) {
  int c, d, count;
  char *pointer;
  count = 0;
  pointer = (char *)malloc(256);
  if (pointer == NULL) {
    exit(EXIT_FAILURE);
  }
  for (c = sizeof n * CHAR_BIT - 1; c >= 0; --c) {
    d = n >> c;
    if (d & 1) {
      *(pointer + count) = 1 + '0';
    } else {
      *(pointer + count) = 0 + '0';
    }
    count++;
  }
  *(pointer + count) = '\0';
  return pointer;
}


x86 assembly (clang, -O0):
<decimal_to_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x100,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1159 <decimal_to_binary+0x39>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
mov    0x2e80(%rip),%rax
movslq (%rax),%rax
shl    $0x2,%rax
sub    $0x1,%rax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11c6 <decimal_to_binary+0xa6>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
sar    %cl,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a3 <decimal_to_binary+0x83>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x31,(%rax,%rcx,1)
jmp    11af <decimal_to_binary+0x8f>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    116e <decimal_to_binary+0x4e>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decimal_to_binary>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x100,%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     1560 <decimal_to_binary+0x440>
mov    0x2ea1(%rip),%rcx
mov    (%rcx),%esi
shl    $0x2,%esi
mov    %esi,%edx
add    $0xffffffff,%edx
js     1159 <decimal_to_binary+0x39>
mov    %esi,%ecx
cmp    $0x10,%esi
jae    1160 <decimal_to_binary+0x40>
xor    %esi,%esi
jmp    1530 <decimal_to_binary+0x410>
xor    %ecx,%ecx
jmp    1547 <decimal_to_binary+0x427>
mov    %ecx,%esi
and    $0xfffffff0,%esi
movd   %edx,%xmm0
pshufd $0x0,%xmm0,%xmm4
movdqa 0xe89(%rip),%xmm14
paddd  %xmm4,%xmm14
movdqa 0xe8b(%rip),%xmm15
paddd  %xmm4,%xmm15
movdqa 0xe8d(%rip),%xmm9
paddd  %xmm4,%xmm9
paddd  0xe90(%rip),%xmm4
movd   %ebp,%xmm0
pshufd $0x0,%xmm0,%xmm13
lea    -0x10(%rsi),%rdi
mov    %rdi,%r8
shr    $0x4,%r8
add    $0x1,%r8
test   %rdi,%rdi
je     1552 <decimal_to_binary+0x432>
mov    %r8,%rbx
and    $0xfffffffffffffffe,%rbx
xor    %edi,%edi
movdqa 0xe6c(%rip),%xmm11
movdqa 0xe74(%rip),%xmm6
pxor   %xmm12,%xmm12
movdqa 0xe76(%rip),%xmm10
nopw   0x0(%rax,%rax,1)
movdqa %xmm4,%xmm0
pslld  $0x17,%xmm0
paddd  %xmm11,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm1
pmuludq %xmm6,%xmm0
pshufd $0xe8,%xmm0,%xmm5
pmuludq %xmm6,%xmm1
pshufd $0xe8,%xmm1,%xmm0
punpckldq %xmm0,%xmm5
movdqa %xmm9,%xmm0
pslld  $0x17,%xmm0
paddd  %xmm11,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm7
pmuludq %xmm6,%xmm0
pshufd $0xe8,%xmm0,%xmm1
pmuludq %xmm6,%xmm7
pshufd $0xe8,%xmm7,%xmm0
punpckldq %xmm0,%xmm1
movdqa %xmm15,%xmm0
pslld  $0x17,%xmm0
paddd  %xmm11,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm7
pmuludq %xmm6,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm6,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm0
movdqa %xmm14,%xmm7
pslld  $0x17,%xmm7
paddd  %xmm11,%xmm7
cvttps2dq %xmm7,%xmm7
pshufd $0xf5,%xmm7,%xmm2
pmuludq %xmm6,%xmm7
pshufd $0xe8,%xmm7,%xmm7
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm7
pand   %xmm13,%xmm7
pand   %xmm13,%xmm0
pand   %xmm13,%xmm1
pand   %xmm13,%xmm5
pcmpeqd %xmm12,%xmm5
pcmpeqd %xmm12,%xmm1
packssdw %xmm1,%xmm5
pcmpeqd %xmm12,%xmm0
pcmpeqd %xmm12,%xmm7
packssdw %xmm7,%xmm0
packsswb %xmm0,%xmm5
paddb  %xmm10,%xmm5
movdqu %xmm5,(%rax,%rdi,1)
movdqa %xmm14,%xmm1
movdqa 0xd7e(%rip),%xmm3
paddd  %xmm3,%xmm1
movdqa %xmm15,%xmm7
paddd  %xmm3,%xmm7
movdqa %xmm9,%xmm0
paddd  %xmm3,%xmm0
movdqa %xmm4,%xmm2
paddd  %xmm3,%xmm2
pslld  $0x17,%xmm2
paddd  %xmm11,%xmm2
cvttps2dq %xmm2,%xmm2
pshufd $0xf5,%xmm2,%xmm8
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm5
pmuludq %xmm6,%xmm8
pshufd $0xe8,%xmm8,%xmm2
punpckldq %xmm2,%xmm5
pslld  $0x17,%xmm0
paddd  %xmm11,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm6,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm0
pslld  $0x17,%xmm7
paddd  %xmm11,%xmm7
cvttps2dq %xmm7,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm7
pmuludq %xmm6,%xmm3
pshufd $0xe8,%xmm3,%xmm2
punpckldq %xmm2,%xmm7
pslld  $0x17,%xmm1
paddd  %xmm11,%xmm1
cvttps2dq %xmm1,%xmm1
pshufd $0xf5,%xmm1,%xmm2
pmuludq %xmm6,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
pand   %xmm13,%xmm1
pand   %xmm13,%xmm7
pand   %xmm13,%xmm0
pand   %xmm13,%xmm5
pcmpeqd %xmm12,%xmm5
pcmpeqd %xmm12,%xmm0
packssdw %xmm0,%xmm5
pcmpeqd %xmm12,%xmm7
pcmpeqd %xmm12,%xmm1
packssdw %xmm1,%xmm7
packsswb %xmm7,%xmm5
paddb  %xmm10,%xmm5
movdqu %xmm5,0x10(%rax,%rdi,1)
add    $0x20,%rdi
movdqa 0xc7e(%rip),%xmm0
paddd  %xmm0,%xmm4
paddd  %xmm0,%xmm9
paddd  %xmm0,%xmm15
paddd  %xmm0,%xmm14
add    $0xfffffffffffffffe,%rbx
jne    11f0 <decimal_to_binary+0xd0>
test   $0x1,%r8b
je     1523 <decimal_to_binary+0x403>
pslld  $0x17,%xmm4
movdqa 0xc0a(%rip),%xmm0
paddd  %xmm0,%xmm4
cvttps2dq %xmm4,%xmm2
movdqa 0xc0a(%rip),%xmm1
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm1,%xmm2
pshufd $0xe8,%xmm2,%xmm4
pmuludq %xmm1,%xmm3
pshufd $0xe8,%xmm3,%xmm2
punpckldq %xmm2,%xmm4
pslld  $0x17,%xmm9
paddd  %xmm0,%xmm9
cvttps2dq %xmm9,%xmm2
pshufd $0xf5,%xmm2,%xmm5
pmuludq %xmm1,%xmm2
pshufd $0xe8,%xmm2,%xmm3
pmuludq %xmm1,%xmm5
pshufd $0xe8,%xmm5,%xmm2
punpckldq %xmm2,%xmm3
pslld  $0x17,%xmm15
paddd  %xmm0,%xmm15
cvttps2dq %xmm15,%xmm2
pshufd $0xf5,%xmm2,%xmm5
pmuludq %xmm1,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm1,%xmm5
pshufd $0xe8,%xmm5,%xmm5
punpckldq %xmm5,%xmm2
pslld  $0x17,%xmm14
paddd  %xmm0,%xmm14
cvttps2dq %xmm14,%xmm0
pshufd $0xf5,%xmm0,%xmm5
pmuludq %xmm1,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm1,%xmm5
pshufd $0xe8,%xmm5,%xmm1
punpckldq %xmm1,%xmm0
pand   %xmm13,%xmm0
pand   %xmm13,%xmm2
pand   %xmm13,%xmm3
pand   %xmm13,%xmm4
pxor   %xmm1,%xmm1
pcmpeqd %xmm1,%xmm4
pcmpeqd %xmm1,%xmm3
packssdw %xmm3,%xmm4
pcmpeqd %xmm1,%xmm2
pcmpeqd %xmm1,%xmm0
packssdw %xmm0,%xmm2
packsswb %xmm2,%xmm4
paddb  0xb42(%rip),%xmm4
movdqu %xmm4,(%rax,%rdi,1)
cmp    %rcx,%rsi
je     1547 <decimal_to_binary+0x427>
sub    %esi,%edx
nopw   0x0(%rax,%rax,1)
bt     %edx,%ebp
mov    $0x31,%bl
adc    $0xff,%bl
mov    %bl,(%rax,%rsi,1)
add    $0x1,%rsi
add    $0xffffffff,%edx
cmp    %rsi,%rcx
jne    1530 <decimal_to_binary+0x410>
movb   $0x0,(%rax,%rcx,1)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %edi,%edi
test   $0x1,%r8b
jne    1429 <decimal_to_binary+0x309>
jmp    1523 <decimal_to_binary+0x403>
mov    0x2a71(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@CHAR_BIT = global i32 0
define i8* @decimal_to_binary(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %2
store i32 0, i32* %5
%7 = call i64 @malloc(i32 256)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %1
%15 = load i32, i32* @CHAR_BIT
%16 = sext i32 %15 to i64
%17 = mul i64 4, %16
%18 = sub i64 %17, 1
%19 = trunc i64 %18 to i32
store i32 %19, i32* %3
br label %20
20: ; preds = %43, %14
%21 = load i32, i32* %3
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %46
23: ; preds = %20
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = ashr i32 %24, %25
store i32 %26, i32* %4
%27 = load i32, i32* %4
%28 = and i32 %27, 1
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %23
%31 = load i8*, i8** %6
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 49, i8* %34
br label %40
35: ; preds = %23
%36 = load i8*, i8** %6
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 48, i8* %39
br label %40
40: ; preds = %35, %30
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %43
43: ; preds = %40
%44 = load i32, i32* %3
%45 = add nsw i32 %44, -1
store i32 %45, i32* %3
br label %20
46: ; preds = %20
%47 = load i8*, i8** %6
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
store i8 0, i8* %50
%51 = load i8*, i8** %6
ret i8* %51
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@CHAR_BIT = global i32 0
define i8* @decimal_to_binary(i32 %0) {
%2 = tail call i64 @malloc(i32 256)
%3 = inttoptr i64 %2 to i8*
%4 = icmp eq i64 %2, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %1
%9 = load i32, i32* @CHAR_BIT
%10 = shl i32 %9, 2
%11 = add i32 %10, -1
%12 = icmp sgt i32 %11, -1
br i1 %12, label %13, label %83
13: ; preds = %8
%14 = zext i32 %10 to i64
%15 = icmp ult i32 %10, 16
br i1 %15, label %67, label %16
16: ; preds = %13
%17 = and i64 %14, 4294967280
%18 = trunc i64 %17 to i32
%19 = sub i32 %11, %18
%20 = insertelement <16 x i32> poison, i32 %11, i64 0
%21 = shufflevector <16 x i32> %20, <16 x i32> poison, <16 x i32> zeroinitializer
%22 = add <16 x i32> %21, <i32 0, i32 -1, i32 -2, i32 -3, i32 -4, i32 -5, i32 -6, i32 -7, i32 -8, i32 -9, i32 -10, i32 -11, i32 -12, i32 -13, i32 -14, i32 -15>
%23 = insertelement <16 x i32> poison, i32 %0, i64 0
%24 = shufflevector <16 x i32> %23, <16 x i32> poison, <16 x i32> zeroinitializer
%25 = add nsw i64 %17, -16
%26 = lshr exact i64 %25, 4
%27 = add nuw nsw i64 %26, 1
%28 = and i64 %27, 1
%29 = icmp eq i64 %25, 0
br i1 %29, label %54, label %30
30: ; preds = %16
%31 = and i64 %27, 2305843009213693950
br label %32
32: ; preds = %32, %30
%33 = phi i64 [ 0, %30 ], [ %50, %32 ]
%34 = phi <16 x i32> [ %22, %30 ], [ %51, %32 ]
%35 = phi i64 [ 0, %30 ], [ %52, %32 ]
%36 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %34
%37 = and <16 x i32> %36, %24
%38 = icmp eq <16 x i32> %37, zeroinitializer
%39 = select <16 x i1> %38, <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>
%40 = getelementptr inbounds i8, i8* %3, i64 %33
%41 = bitcast i8* %40 to <16 x i8>*
store <16 x i8> %39, <16 x i8>* %41
%42 = or i64 %33, 16
%43 = add <16 x i32> %34, <i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16>
%44 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %43
%45 = and <16 x i32> %44, %24
%46 = icmp eq <16 x i32> %45, zeroinitializer
%47 = select <16 x i1> %46, <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>
%48 = getelementptr inbounds i8, i8* %3, i64 %42
%49 = bitcast i8* %48 to <16 x i8>*
store <16 x i8> %47, <16 x i8>* %49
%50 = add nuw i64 %33, 32
%51 = add <16 x i32> %34, <i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32>
%52 = add i64 %35, 2
%53 = icmp eq i64 %52, %31
br i1 %53, label %54, label %32
54: ; preds = %32, %16
%55 = phi i64 [ 0, %16 ], [ %50, %32 ]
%56 = phi <16 x i32> [ %22, %16 ], [ %51, %32 ]
%57 = icmp eq i64 %28, 0
br i1 %57, label %65, label %58
58: ; preds = %54
%59 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %56
%60 = and <16 x i32> %59, %24
%61 = icmp eq <16 x i32> %60, zeroinitializer
%62 = select <16 x i1> %61, <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>
%63 = getelementptr inbounds i8, i8* %3, i64 %55
%64 = bitcast i8* %63 to <16 x i8>*
store <16 x i8> %62, <16 x i8>* %64
br label %65
65: ; preds = %54, %58
%66 = icmp eq i64 %17, %14
br i1 %66, label %81, label %67
67: ; preds = %13, %65
%68 = phi i64 [ 0, %13 ], [ %17, %65 ]
%69 = phi i32 [ %11, %13 ], [ %19, %65 ]
br label %70
70: ; preds = %67, %70
%71 = phi i64 [ %78, %70 ], [ %68, %67 ]
%72 = phi i32 [ %79, %70 ], [ %69, %67 ]
%73 = shl nuw i32 1, %72
%74 = and i32 %73, %0
%75 = icmp eq i32 %74, 0
%76 = select i1 %75, i8 48, i8 49
%77 = getelementptr inbounds i8, i8* %3, i64 %71
store i8 %76, i8* %77
%78 = add nuw nsw i64 %71, 1
%79 = add nsw i32 %72, -1
%80 = icmp eq i64 %78, %14
br i1 %80, label %81, label %70
81: ; preds = %70, %65
%82 = zext i32 %10 to i64
br label %83
83: ; preds = %8, %81
%84 = phi i64 [ %82, %81 ], [ 0, %8 ]
%85 = getelementptr inbounds i8, i8* %3, i64 %84
store i8 0, i8* %85
ret i8* %3
}