#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 */
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ mpz_add_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_div(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int mpz_get_ui(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set_str(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ mpz_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
void bin_to_vector(int *vector_bin, int slots, mpz_t bits, mpz_t binary) {
  mpz_t aux, div, abin, cont, cont2, mod;
  mpz_init_set_str(aux, "1", 10);
  mpz_init_set_str(div, "10", 10);
  mpz_init_set_str(cont, "0", 10);
  mpz_init_set_str(cont2, "0", 10);
  mpz_init_set_str(mod, "1", 10);
  mpz_init_set_str(abin, "1", 10);
  mpz_set(abin, binary);
  while (mpz_cmp(bits, cont2) > 0) {
    mpz_mul(mod, div, mod);
    mpz_add_ui(cont2, cont2, 1);
  }
  mpz_div(mod, mod, div);
  int i = 0;
  do {
    if (mpz_cmp(abin, mod) >= 0) {
      mpz_div(aux, abin, mod);
      mpz_sub(abin, abin, mod);
      vector_bin[i] = mpz_get_ui(aux);
      mpz_div(mod, mod, div);
      mpz_add_ui(cont, cont, 1);
      i++;
    } else {
      mpz_div(aux, abin, mod);
      vector_bin[i] = mpz_get_ui(aux);
      mpz_div(mod, mod, div);
      mpz_add_ui(cont, cont, 1);
      i++;
    }
  } while (mpz_cmp(bits, cont) > 0);
  mpz_clear(aux);
  mpz_clear(div);
  mpz_clear(cont);
  mpz_clear(cont2);
  mpz_clear(mod);
  mpz_clear(abin);
}


x86 assembly (clang, -O0):
<bin_to_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x18(%rbp),%edi
lea    0xe51(%rip),%rsi
mov    $0xa,%edx
call   1070 <mpz_init_set_str@plt>
mov    -0x1c(%rbp),%edi
lea    0xe3f(%rip),%rsi
mov    $0xa,%edx
call   1070 <mpz_init_set_str@plt>
mov    -0x24(%rbp),%edi
lea    0xe2c(%rip),%rsi
mov    $0xa,%edx
call   1070 <mpz_init_set_str@plt>
mov    -0x28(%rbp),%edi
lea    0xe18(%rip),%rsi
mov    $0xa,%edx
call   1070 <mpz_init_set_str@plt>
mov    -0x2c(%rbp),%edi
lea    0xe01(%rip),%rsi
mov    $0xa,%edx
call   1070 <mpz_init_set_str@plt>
mov    -0x20(%rbp),%edi
lea    0xded(%rip),%rsi
mov    $0xa,%edx
call   1070 <mpz_init_set_str@plt>
mov    -0x20(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <mpz_set@plt>
mov    -0x10(%rbp),%edi
mov    -0x28(%rbp),%esi
call   10a0 <mpz_cmp@plt>
cmp    $0x0,%rax
jle    1260 <bin_to_vector+0xd0>
mov    -0x2c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1080 <mpz_mul@plt>
mov    -0x28(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    $0x1,%edx
call   1060 <mpz_add_ui@plt>
jmp    1228 <bin_to_vector+0x98>
mov    -0x2c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <mpz_div@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   10a0 <mpz_cmp@plt>
cmp    $0x0,%rax
jl     12e7 <bin_to_vector+0x157>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1030 <mpz_div@plt>
mov    -0x20(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1050 <mpz_sub@plt>
mov    -0x18(%rbp),%edi
call   1090 <mpz_get_ui@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <mpz_div@plt>
mov    -0x24(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    $0x1,%edx
call   1060 <mpz_add_ui@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1331 <bin_to_vector+0x1a1>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1030 <mpz_div@plt>
mov    -0x18(%rbp),%edi
call   1090 <mpz_get_ui@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <mpz_div@plt>
mov    -0x24(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    $0x1,%edx
call   1060 <mpz_add_ui@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1336 <bin_to_vector+0x1a6>
mov    -0x10(%rbp),%edi
mov    -0x24(%rbp),%esi
call   10a0 <mpz_cmp@plt>
cmp    $0x0,%rax
jg     1275 <bin_to_vector+0xe5>
mov    -0x18(%rbp),%edi
call   10b0 <mpz_clear@plt>
mov    -0x1c(%rbp),%edi
call   10b0 <mpz_clear@plt>
mov    -0x24(%rbp),%edi
call   10b0 <mpz_clear@plt>
mov    -0x28(%rbp),%edi
call   10b0 <mpz_clear@plt>
mov    -0x2c(%rbp),%edi
call   10b0 <mpz_clear@plt>
mov    -0x20(%rbp),%edi
call   10b0 <mpz_clear@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bin_to_vector>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r13d
mov    %rdi,%rbx
lea    0xe55(%rip),%r15
mov    %r15,%rsi
mov    $0xa,%edx
call   1070 <mpz_init_set_str@plt>
lea    0xe43(%rip),%rsi
mov    $0xa,%edx
call   1070 <mpz_init_set_str@plt>
lea    0xe33(%rip),%r12
mov    %r12,%rsi
mov    $0xa,%edx
call   1070 <mpz_init_set_str@plt>
mov    %r12,%rsi
mov    $0xa,%edx
call   1070 <mpz_init_set_str@plt>
mov    %r15,%rsi
mov    $0xa,%edx
call   1070 <mpz_init_set_str@plt>
mov    %r15,%rsi
mov    $0xa,%edx
call   1070 <mpz_init_set_str@plt>
mov    %r14d,%esi
call   1040 <mpz_set@plt>
nopl   0x0(%rax)
mov    %r13d,%edi
call   10a0 <mpz_cmp@plt>
test   %rax,%rax
jle    122e <bin_to_vector+0x9e>
call   1080 <mpz_mul@plt>
mov    $0x1,%edx
call   1060 <mpz_add_ui@plt>
jmp    1210 <bin_to_vector+0x80>
call   1030 <mpz_div@plt>
jmp    1267 <bin_to_vector+0xd7>
cs nopw 0x0(%rax,%rax,1)
nop
call   1090 <mpz_get_ui@plt>
mov    %eax,(%rbx)
call   1030 <mpz_div@plt>
mov    $0x1,%edx
call   1060 <mpz_add_ui@plt>
mov    %r13d,%edi
call   10a0 <mpz_cmp@plt>
add    $0x4,%rbx
test   %rax,%rax
jle    1280 <bin_to_vector+0xf0>
call   10a0 <mpz_cmp@plt>
mov    %rax,%rbp
call   1030 <mpz_div@plt>
test   %rbp,%rbp
js     1240 <bin_to_vector+0xb0>
call   1050 <mpz_sub@plt>
jmp    1240 <bin_to_vector+0xb0>
call   10b0 <mpz_clear@plt>
call   10b0 <mpz_clear@plt>
call   10b0 <mpz_clear@plt>
call   10b0 <mpz_clear@plt>
call   10b0 <mpz_clear@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <mpz_clear@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [3 x i8] c"10\00"
@.str.2 = [2 x i8] c"0\00"
define void @bin_to_vector(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%16 = load i32, i32* %9
%17 = call i32 @mpz_init_set_str(i32 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 10)
%18 = load i32, i32* %10
%19 = call i32 @mpz_init_set_str(i32 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 10)
%20 = load i32, i32* %12
%21 = call i32 @mpz_init_set_str(i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 10)
%22 = load i32, i32* %13
%23 = call i32 @mpz_init_set_str(i32 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 10)
%24 = load i32, i32* %14
%25 = call i32 @mpz_init_set_str(i32 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 10)
%26 = load i32, i32* %11
%27 = call i32 @mpz_init_set_str(i32 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 10)
%28 = load i32, i32* %11
%29 = load i32, i32* %8
%30 = call i32 @mpz_set(i32 %28, i32 %29)
br label %31
31: ; preds = %36, %4
%32 = load i32, i32* %7
%33 = load i32, i32* %13
%34 = call i64 @mpz_cmp(i32 %32, i32 %33)
%35 = icmp sgt i64 %34, 0
br i1 %35, label %36, label %44
36: ; preds = %31
%37 = load i32, i32* %14
%38 = load i32, i32* %10
%39 = load i32, i32* %14
%40 = call i32 @mpz_mul(i32 %37, i32 %38, i32 %39)
%41 = load i32, i32* %13
%42 = load i32, i32* %13
%43 = call i32 @mpz_add_ui(i32 %41, i32 %42, i32 1)
br label %31
44: ; preds = %31
%45 = load i32, i32* %14
%46 = load i32, i32* %14
%47 = load i32, i32* %10
%48 = call i32 @mpz_div(i32 %45, i32 %46, i32 %47)
store i32 0, i32* %15
br label %49
49: ; preds = %99, %44
%50 = load i32, i32* %11
%51 = load i32, i32* %14
%52 = call i64 @mpz_cmp(i32 %50, i32 %51)
%53 = icmp sge i64 %52, 0
br i1 %53, label %54, label %78
54: ; preds = %49
%55 = load i32, i32* %9
%56 = load i32, i32* %11
%57 = load i32, i32* %14
%58 = call i32 @mpz_div(i32 %55, i32 %56, i32 %57)
%59 = load i32, i32* %11
%60 = load i32, i32* %11
%61 = load i32, i32* %14
%62 = call i32 @mpz_sub(i32 %59, i32 %60, i32 %61)
%63 = load i32, i32* %9
%64 = call i32 @mpz_get_ui(i32 %63)
%65 = load i32*, i32** %5
%66 = load i32, i32* %15
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %65, i64 %67
store i32 %64, i32* %68
%69 = load i32, i32* %14
%70 = load i32, i32* %14
%71 = load i32, i32* %10
%72 = call i32 @mpz_div(i32 %69, i32 %70, i32 %71)
%73 = load i32, i32* %12
%74 = load i32, i32* %12
%75 = call i32 @mpz_add_ui(i32 %73, i32 %74, i32 1)
%76 = load i32, i32* %15
%77 = add nsw i32 %76, 1
store i32 %77, i32* %15
br label %98
78: ; preds = %49
%79 = load i32, i32* %9
%80 = load i32, i32* %11
%81 = load i32, i32* %14
%82 = call i32 @mpz_div(i32 %79, i32 %80, i32 %81)
%83 = load i32, i32* %9
%84 = call i32 @mpz_get_ui(i32 %83)
%85 = load i32*, i32** %5
%86 = load i32, i32* %15
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %85, i64 %87
store i32 %84, i32* %88
%89 = load i32, i32* %14
%90 = load i32, i32* %14
%91 = load i32, i32* %10
%92 = call i32 @mpz_div(i32 %89, i32 %90, i32 %91)
%93 = load i32, i32* %12
%94 = load i32, i32* %12
%95 = call i32 @mpz_add_ui(i32 %93, i32 %94, i32 1)
%96 = load i32, i32* %15
%97 = add nsw i32 %96, 1
store i32 %97, i32* %15
br label %98
98: ; preds = %78, %54
br label %99
99: ; preds = %98
%100 = load i32, i32* %7
%101 = load i32, i32* %12
%102 = call i64 @mpz_cmp(i32 %100, i32 %101)
%103 = icmp sgt i64 %102, 0
br i1 %103, label %49, label %104
104: ; preds = %99
%105 = load i32, i32* %9
%106 = call i32 @mpz_clear(i32 %105)
%107 = load i32, i32* %10
%108 = call i32 @mpz_clear(i32 %107)
%109 = load i32, i32* %12
%110 = call i32 @mpz_clear(i32 %109)
%111 = load i32, i32* %13
%112 = call i32 @mpz_clear(i32 %111)
%113 = load i32, i32* %14
%114 = call i32 @mpz_clear(i32 %113)
%115 = load i32, i32* %11
%116 = call i32 @mpz_clear(i32 %115)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [3 x i8] c"10\00"
@.str.2 = [2 x i8] c"0\00"
define void @bin_to_vector(i32* nocapture writeonly %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @mpz_init_set_str(i32 undef, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 10)
%6 = tail call i32 @mpz_init_set_str(i32 undef, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 10)
%7 = tail call i32 @mpz_init_set_str(i32 undef, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 10)
%8 = tail call i32 @mpz_init_set_str(i32 undef, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 10)
%9 = tail call i32 @mpz_init_set_str(i32 undef, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 10)
%10 = tail call i32 @mpz_init_set_str(i32 undef, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 10)
%11 = tail call i32 @mpz_set(i32 undef, i32 %3)
%12 = tail call i64 @mpz_cmp(i32 %2, i32 undef)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %4, %14
%15 = tail call i32 @mpz_mul(i32 undef, i32 undef, i32 undef)
%16 = tail call i32 @mpz_add_ui(i32 undef, i32 undef, i32 1)
%17 = tail call i64 @mpz_cmp(i32 %2, i32 undef)
%18 = icmp sgt i64 %17, 0
br i1 %18, label %14, label %19
19: ; preds = %14, %4
%20 = tail call i32 @mpz_div(i32 undef, i32 undef, i32 undef)
br label %21
21: ; preds = %28, %19
%22 = phi i64 [ %33, %28 ], [ 0, %19 ]
%23 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%24 = icmp sgt i64 %23, -1
%25 = tail call i32 @mpz_div(i32 undef, i32 undef, i32 undef)
br i1 %24, label %26, label %28
26: ; preds = %21
%27 = tail call i32 @mpz_sub(i32 undef, i32 undef, i32 undef)
br label %28
28: ; preds = %21, %26
%29 = tail call i32 @mpz_get_ui(i32 undef)
%30 = getelementptr inbounds i32, i32* %0, i64 %22
store i32 %29, i32* %30
%31 = tail call i32 @mpz_div(i32 undef, i32 undef, i32 undef)
%32 = tail call i32 @mpz_add_ui(i32 undef, i32 undef, i32 1)
%33 = add nuw i64 %22, 1
%34 = tail call i64 @mpz_cmp(i32 %2, i32 undef)
%35 = icmp sgt i64 %34, 0
br i1 %35, label %21, label %36
36: ; preds = %28
%37 = tail call i32 @mpz_clear(i32 undef)
%38 = tail call i32 @mpz_clear(i32 undef)
%39 = tail call i32 @mpz_clear(i32 undef)
%40 = tail call i32 @mpz_clear(i32 undef)
%41 = tail call i32 @mpz_clear(i32 undef)
%42 = tail call i32 @mpz_clear(i32 undef)
ret void
}