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


x86 assembly (clang, -O0):
<decimal_to_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    115a <decimal_to_binary+0x3a>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11bb <decimal_to_binary+0x9b>
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
sar    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1198 <decimal_to_binary+0x78>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x31,(%rax,%rcx,1)
jmp    11a4 <decimal_to_binary+0x84>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1163 <decimal_to_binary+0x43>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decimal_to_binary>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%r14d
mov    %esi,%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     157b <decimal_to_binary+0x45b>
test   %ebx,%ebx
jle    1568 <decimal_to_binary+0x448>
mov    %ebx,%ebp
cmp    $0x10,%ebx
jae    114f <decimal_to_binary+0x2f>
xor    %edx,%edx
jmp    1547 <decimal_to_binary+0x427>
mov    %ebp,%edx
and    $0xfffffff0,%edx
movd   %ebx,%xmm0
pshufd $0x0,%xmm0,%xmm4
movdqa 0xe9a(%rip),%xmm15
paddd  %xmm4,%xmm15
movdqa 0xe9c(%rip),%xmm8
paddd  %xmm4,%xmm8
movdqa 0xe9e(%rip),%xmm10
paddd  %xmm4,%xmm10
paddd  0xea1(%rip),%xmm4
movd   %r14d,%xmm0
pshufd $0x0,%xmm0,%xmm14
lea    -0x10(%rdx),%rsi
mov    %rsi,%r8
shr    $0x4,%r8
add    $0x1,%r8
test   %rsi,%rsi
je     156d <decimal_to_binary+0x44d>
mov    %r8,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
movdqa 0xe7c(%rip),%xmm12
movdqa 0xe84(%rip),%xmm7
pxor   %xmm13,%xmm13
movdqa 0xea6(%rip),%xmm11
nopw   0x0(%rax,%rax,1)
movdqa %xmm15,%xmm1
pcmpeqd %xmm2,%xmm2
paddd  %xmm2,%xmm1
movdqa %xmm8,%xmm5
paddd  %xmm2,%xmm5
movdqa %xmm10,%xmm0
paddd  %xmm2,%xmm0
movdqa %xmm4,%xmm6
paddd  %xmm2,%xmm6
pslld  $0x17,%xmm6
paddd  %xmm12,%xmm6
cvttps2dq %xmm6,%xmm6
pshufd $0xf5,%xmm6,%xmm9
pmuludq %xmm7,%xmm6
pshufd $0xe8,%xmm6,%xmm6
pmuludq %xmm7,%xmm9
pshufd $0xe8,%xmm9,%xmm2
punpckldq %xmm2,%xmm6
pslld  $0x17,%xmm0
paddd  %xmm12,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm7,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm0
pslld  $0x17,%xmm5
paddd  %xmm12,%xmm5
cvttps2dq %xmm5,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm5
pmuludq %xmm7,%xmm3
pshufd $0xe8,%xmm3,%xmm2
punpckldq %xmm2,%xmm5
pslld  $0x17,%xmm1
paddd  %xmm12,%xmm1
cvttps2dq %xmm1,%xmm1
pshufd $0xf5,%xmm1,%xmm2
pmuludq %xmm7,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
pand   %xmm14,%xmm1
pand   %xmm14,%xmm5
pand   %xmm14,%xmm0
pand   %xmm14,%xmm6
pcmpeqd %xmm13,%xmm6
pcmpeqd %xmm13,%xmm0
packssdw %xmm0,%xmm6
pcmpeqd %xmm13,%xmm5
pcmpeqd %xmm13,%xmm1
packssdw %xmm1,%xmm5
packsswb %xmm5,%xmm6
movdqa 0xd75(%rip),%xmm9
paddb  %xmm9,%xmm6
movdqu %xmm6,(%rax,%rsi,1)
movdqa %xmm15,%xmm1
movdqa 0xd6e(%rip),%xmm3
paddd  %xmm3,%xmm1
movdqa %xmm8,%xmm5
paddd  %xmm3,%xmm5
movdqa %xmm10,%xmm0
paddd  %xmm3,%xmm0
movdqa %xmm4,%xmm2
paddd  %xmm3,%xmm2
pslld  $0x17,%xmm2
paddd  %xmm12,%xmm2
cvttps2dq %xmm2,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm6
pmuludq %xmm7,%xmm3
pshufd $0xe8,%xmm3,%xmm2
punpckldq %xmm2,%xmm6
pslld  $0x17,%xmm0
paddd  %xmm12,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm7,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm0
pslld  $0x17,%xmm5
paddd  %xmm12,%xmm5
cvttps2dq %xmm5,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm5
pmuludq %xmm7,%xmm3
pshufd $0xe8,%xmm3,%xmm2
punpckldq %xmm2,%xmm5
pslld  $0x17,%xmm1
paddd  %xmm12,%xmm1
cvttps2dq %xmm1,%xmm1
pshufd $0xf5,%xmm1,%xmm2
pmuludq %xmm7,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
pand   %xmm14,%xmm0
pand   %xmm14,%xmm6
pcmpeqd %xmm13,%xmm6
pcmpeqd %xmm13,%xmm0
packssdw %xmm0,%xmm6
pand   %xmm14,%xmm1
pand   %xmm14,%xmm5
pcmpeqd %xmm13,%xmm5
pcmpeqd %xmm13,%xmm1
packssdw %xmm1,%xmm5
packsswb %xmm5,%xmm6
paddb  %xmm9,%xmm6
movdqu %xmm6,0x10(%rax,%rsi,1)
add    $0x20,%rsi
paddd  %xmm11,%xmm4
paddd  %xmm11,%xmm10
paddd  %xmm11,%xmm8
paddd  %xmm11,%xmm15
add    $0xfffffffffffffffe,%rdi
jne    11e0 <decimal_to_binary+0xc0>
test   $0x1,%r8b
je     1540 <decimal_to_binary+0x420>
pcmpeqd %xmm0,%xmm0
paddd  %xmm0,%xmm15
paddd  %xmm0,%xmm8
paddd  %xmm0,%xmm10
paddd  %xmm0,%xmm4
pslld  $0x17,%xmm4
movdqa 0xbed(%rip),%xmm0
paddd  %xmm0,%xmm4
cvttps2dq %xmm4,%xmm2
movdqa 0xbed(%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,%xmm10
paddd  %xmm0,%xmm10
cvttps2dq %xmm10,%xmm2
pshufd $0xf5,%xmm2,%xmm5
pmuludq %xmm1,%xmm2
pshufd $0xe8,%xmm2,%xmm3
pmuludq %xmm1,%xmm5
pshufd $0xe8,%xmm5,%xmm2
punpckldq %xmm2,%xmm3
pslld  $0x17,%xmm8
paddd  %xmm0,%xmm8
cvttps2dq %xmm8,%xmm2
pshufd $0xf5,%xmm2,%xmm5
pmuludq %xmm1,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm1,%xmm5
pshufd $0xe8,%xmm5,%xmm5
punpckldq %xmm5,%xmm2
pslld  $0x17,%xmm15
paddd  %xmm0,%xmm15
cvttps2dq %xmm15,%xmm0
pshufd $0xf5,%xmm0,%xmm5
pmuludq %xmm1,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm1,%xmm5
pshufd $0xe8,%xmm5,%xmm1
punpckldq %xmm1,%xmm0
pand   %xmm14,%xmm0
pand   %xmm14,%xmm2
pand   %xmm14,%xmm3
pand   %xmm14,%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  0xb25(%rip),%xmm4
movdqu %xmm4,(%rax,%rsi,1)
cmp    %rbp,%rdx
je     1568 <decimal_to_binary+0x448>
sub    %edx,%ebx
add    $0xffffffff,%ebx
nopw   0x0(%rax,%rax,1)
bt     %ebx,%r14d
mov    $0x31,%cl
adc    $0xff,%cl
mov    %cl,(%rax,%rdx,1)
add    $0x1,%rdx
add    $0xffffffff,%ebx
cmp    %rdx,%rbp
jne    1550 <decimal_to_binary+0x430>
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %esi,%esi
test   $0x1,%r8b
jne    142f <decimal_to_binary+0x30f>
jmp    1540 <decimal_to_binary+0x420>
mov    0x2a5e(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
define i8* @decimal_to_binary(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %7
%9 = load i32, i32* %4
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %8
%12 = load i8*, i8** %8
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %5
br label %20
20: ; preds = %43, %17
%21 = load i32, i32* %5
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %46
23: ; preds = %20
%24 = load i32, i32* %3
%25 = load i32, i32* %5
%26 = ashr i32 %24, %25
store i32 %26, i32* %6
%27 = load i32, i32* %6
%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** %8
%32 = load i32, i32* %7
%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** %8
%37 = load i32, i32* %7
%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* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %43
43: ; preds = %40
%44 = load i32, i32* %5
%45 = add nsw i32 %44, -1
store i32 %45, i32* %5
br label %20
46: ; preds = %20
%47 = load i8*, i8** %8
ret i8* %47
}

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