#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*/ setnull(int *);
void converttobinary(int result[16], int dec) {
  int d[16];
  setnull(d);
  int i = 0;
  while (dec > 0) {
    d[i] = dec % 2;
    i++;
    dec = dec / 2;
  }
  for (i = 16; i >= 0; i--) {
    result[16 - 1 - i] = d[i];
  }
}


x86 assembly (clang, -O0):
<converttobinary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <setnull@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1168 <converttobinary+0x58>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq -0x54(%rbp),%rax
mov    %edx,-0x50(%rbp,%rax,4)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    112f <converttobinary+0x1f>
movl   $0x10,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jl     11a1 <converttobinary+0x91>
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
mov    -0x8(%rbp),%rax
mov    $0xf,%ecx
sub    -0x54(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x54(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x54(%rbp)
jmp    116f <converttobinary+0x5f>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<converttobinary>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <setnull@plt>
test   %ebp,%ebp
jle    1144 <converttobinary+0x34>
mov    %ebp,%eax
xchg   %ax,%ax
mov    %ebp,%ecx
and    $0x1,%ecx
mov    %ecx,(%rbx)
shr    %eax
add    $0x4,%rbx
cmp    $0x2,%ebp
mov    %eax,%ebp
jae    1130 <converttobinary+0x20>
movdqu 0x34(%rsp),%xmm0
pshufd $0x1b,%xmm0,%xmm0
movdqu %xmm0,-0x4(%r14)
movdqu 0x24(%rsp),%xmm0
pshufd $0x1b,%xmm0,%xmm0
movdqu %xmm0,0xc(%r14)
movdqu 0x14(%rsp),%xmm0
pshufd $0x1b,%xmm0,%xmm0
movdqu %xmm0,0x1c(%r14)
movdqu 0x4(%rsp),%xmm0
pshufd $0x1b,%xmm0,%xmm0
movdqu %xmm0,0x2c(%r14)
mov    (%rsp),%eax
mov    %eax,0x3c(%r14)
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @converttobinary(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [16 x i32]
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 0
%8 = call i32 @setnull(i32* %7)
store i32 0, i32* %6
br label %9
9: ; preds = %12, %2
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i32, i32* %4
%14 = srem i32 %13, 2
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 %16
store i32 %14, i32* %17
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
%20 = load i32, i32* %4
%21 = sdiv i32 %20, 2
store i32 %21, i32* %4
br label %9
22: ; preds = %9
store i32 16, i32* %6
br label %23
23: ; preds = %36, %22
%24 = load i32, i32* %6
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %39
26: ; preds = %23
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = load i32*, i32** %3
%32 = load i32, i32* %6
%33 = sub nsw i32 15, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %31, i64 %34
store i32 %30, i32* %35
br label %36
36: ; preds = %26
%37 = load i32, i32* %6
%38 = add nsw i32 %37, -1
store i32 %38, i32* %6
br label %23
39: ; preds = %23
ret void
}

LLVM IR (-O2):
define void @converttobinary(i32* nocapture writeonly %0, i32 %1) {
%3 = alloca [16 x i32]
%4 = bitcast [16 x i32]* %3 to i8*
%5 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%6 = call i32 @setnull(i32* %5)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %35, label %8
8: ; preds = %35, %2
%9 = getelementptr inbounds i32, i32* %0, i64 -1
%10 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 13
%11 = bitcast i32* %10 to <4 x i32>*
%12 = load <4 x i32>, <4 x i32>* %11
%13 = shufflevector <4 x i32> %12, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
%14 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> %13, <4 x i32>* %14
%15 = getelementptr inbounds i32, i32* %0, i64 3
%16 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 9
%17 = bitcast i32* %16 to <4 x i32>*
%18 = load <4 x i32>, <4 x i32>* %17
%19 = shufflevector <4 x i32> %18, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
%20 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> %19, <4 x i32>* %20
%21 = getelementptr inbounds i32, i32* %0, i64 7
%22 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 5
%23 = bitcast i32* %22 to <4 x i32>*
%24 = load <4 x i32>, <4 x i32>* %23
%25 = shufflevector <4 x i32> %24, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
%26 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> %25, <4 x i32>* %26
%27 = getelementptr inbounds i32, i32* %0, i64 11
%28 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 1
%29 = bitcast i32* %28 to <4 x i32>*
%30 = load <4 x i32>, <4 x i32>* %29
%31 = shufflevector <4 x i32> %30, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
%32 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> %31, <4 x i32>* %32
%33 = load i32, i32* %5
%34 = getelementptr inbounds i32, i32* %0, i64 15
store i32 %33, i32* %34
ret void
35: ; preds = %2, %35
%36 = phi i64 [ %40, %35 ], [ 0, %2 ]
%37 = phi i32 [ %41, %35 ], [ %1, %2 ]
%38 = and i32 %37, 1
%39 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 %36
store i32 %38, i32* %39
%40 = add nuw nsw i64 %36, 1
%41 = lshr i32 %37, 1
%42 = icmp ult i32 %37, 2
br i1 %42, label %8, label %35
}