#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*/ arrcpy(int *, int *);
scalar_t__ int_pow(int, int);
int /*<<< orphan*/ negate(int *);
int /*<<< orphan*/ setnull(int *);
int dectobin(int bin_a[16]) {
  int bin[16];
  setnull(bin);
  arrcpy(bin, bin_a);
  int erg = 0;
  bool isneg = false;
  if (bin[0] == 1)
    isneg = true;
  else
    isneg = false;
  if (isneg) {
    negate(bin);
  }
  for (int i = 16 - 1; i >= 0; i--) {
    if (bin[i] == 1) {
      erg += int_pow(2, 16 - 1 - i);
    }
  }
  if (isneg)
    erg = -erg - 1;
  return erg;
}


x86 assembly (clang, -O0):
<dectobin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
call   1060 <setnull@plt>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <arrcpy@plt>
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
cmpl   $0x1,-0x50(%rbp)
jne    1186 <dectobin+0x46>
movl   $0x1,-0x58(%rbp)
jmp    118d <dectobin+0x4d>
movl   $0x0,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
je     11a0 <dectobin+0x60>
lea    -0x50(%rbp),%rdi
call   1050 <negate@plt>
movl   $0xf,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jl     11f2 <dectobin+0xb2>
movslq -0x5c(%rbp),%rax
cmpl   $0x1,-0x50(%rbp,%rax,4)
jne    11df <dectobin+0x9f>
mov    $0xf,%esi
sub    -0x5c(%rbp),%esi
mov    $0x2,%edi
call   1030 <int_pow@plt>
mov    %rax,%rcx
movslq -0x54(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x54(%rbp)
jmp    11e4 <dectobin+0xa4>
mov    -0x5c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x5c(%rbp)
jmp    11a7 <dectobin+0x67>
cmpl   $0x0,-0x58(%rbp)
je     1207 <dectobin+0xc7>
xor    %eax,%eax
sub    -0x54(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dectobin>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%rbx
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1060 <setnull@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <arrcpy@plt>
mov    (%rsp),%r14d
cmp    $0x1,%r14d
jne    1175 <dectobin+0x35>
mov    %rsp,%rdi
call   1050 <negate@plt>
lea    0x3c(%rsp),%rbp
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    119e <dectobin+0x5e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
add    $0xfffffffffffffffc,%rbp
cmp    $0x10,%rbx
je     11b5 <dectobin+0x75>
cmpl   $0x1,0x0(%rbp)
jne    1190 <dectobin+0x50>
mov    $0x2,%edi
mov    %ebx,%esi
call   1030 <int_pow@plt>
add    %eax,%r15d
jmp    1190 <dectobin+0x50>
xor    %eax,%eax
cmp    $0x1,%r14d
sete   %al
neg    %eax
xor    %eax,%r15d
mov    %r15d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @dectobin(i32* %0) {
%2 = alloca i32*
%3 = alloca [16 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %2
%7 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%8 = call i32 @setnull(i32* %7)
%9 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%10 = load i32*, i32** %2
%11 = call i32 @arrcpy(i32* %9, i32* %10)
store i32 0, i32* %4
store i32 0, i32* %5
%12 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %1
store i32 1, i32* %5
br label %17
16: ; preds = %1
store i32 0, i32* %5
br label %17
17: ; preds = %16, %15
%18 = load i32, i32* %5
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%22 = call i32 @negate(i32* %21)
br label %23
23: ; preds = %20, %17
store i32 15, i32* %6
br label %24
24: ; preds = %42, %23
%25 = load i32, i32* %6
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %45
27: ; preds = %24
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %41
33: ; preds = %27
%34 = load i32, i32* %6
%35 = sub nsw i32 15, %34
%36 = call i64 @int_pow(i32 2, i32 %35)
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = add nsw i64 %38, %36
%40 = trunc i64 %39 to i32
store i32 %40, i32* %4
br label %41
41: ; preds = %33, %27
br label %42
42: ; preds = %41
%43 = load i32, i32* %6
%44 = add nsw i32 %43, -1
store i32 %44, i32* %6
br label %24
45: ; preds = %24
%46 = load i32, i32* %5
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = load i32, i32* %4
%50 = sub nsw i32 0, %49
%51 = sub nsw i32 %50, 1
store i32 %51, i32* %4
br label %52
52: ; preds = %48, %45
%53 = load i32, i32* %4
ret i32 %53
}

LLVM IR (-O2):
define i32 @dectobin(i32* %0) {
%2 = alloca [16 x i32]
%3 = bitcast [16 x i32]* %2 to i8*
%4 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
%5 = call i32 @setnull(i32* %4)
%6 = call i32 @arrcpy(i32* %4, i32* %0)
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %10, label %9
9: ; preds = %10, %1
br label %15
10: ; preds = %1
%11 = call i32 @negate(i32* %4)
br label %9
12: ; preds = %27
%13 = sext i1 %8 to i32
%14 = xor i32 %28, %13
ret i32 %14
15: ; preds = %9, %27
%16 = phi i64 [ %29, %27 ], [ 15, %9 ]
%17 = phi i32 [ %28, %27 ], [ 0, %9 ]
%18 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 %16
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %27
21: ; preds = %15
%22 = trunc i64 %16 to i32
%23 = sub i32 15, %22
%24 = call i64 @int_pow(i32 2, i32 %23)
%25 = trunc i64 %24 to i32
%26 = add i32 %17, %25
br label %27
27: ; preds = %15, %21
%28 = phi i32 [ %26, %21 ], [ %17, %15 ]
%29 = add nsw i64 %16, -1
%30 = icmp eq i64 %16, 0
br i1 %30, label %12, label %15
}