#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 */
long pow(int, short);
long dec2bin(long decimal) {
  long modulo = 0;
  long binaire = 0;
  short int i = 0;
  do {
    modulo = decimal % 2;
    decimal = decimal - modulo;
    decimal = decimal / 2;
    binaire = binaire + modulo * pow(10, i);
    i++;
  } while (decimal >= 1);
  return binaire;
}


x86 assembly (clang, -O0):
<dec2bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movw   $0x0,-0x1a(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
sub    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0xa,%edi
movswl -0x1a(%rbp),%esi
call   1030 <pow@plt>
mov    -0x30(%rbp),%rcx
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
imul   %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1a(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1a(%rbp)
cmpq   $0x1,-0x8(%rbp)
jge    1132 <dec2bin+0x22>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dec2bin>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r15
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rax
shr    $0x3f,%rax
add    %r15,%rax
mov    %rax,%r12
sar    %r12
and    $0xfffffffffffffffe,%rax
mov    %r15,%r13
sub    %rax,%r13
movswl %bx,%esi
mov    $0xa,%edi
call   1030 <pow@plt>
imul   %r13,%rax
add    %rax,%r14
add    $0x1,%ebx
cmp    $0x1,%r15
mov    %r12,%r15
jg     1130 <dec2bin+0x20>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @dec2bin(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i16
store i64 %0, i64* %2
store i64 0, i64* %3
store i64 0, i64* %4
store i16 0, i16* %5
br label %6
6: ; preds = %22, %1
%7 = load i64, i64* %2
%8 = srem i64 %7, 2
store i64 %8, i64* %3
%9 = load i64, i64* %2
%10 = load i64, i64* %3
%11 = sub nsw i64 %9, %10
store i64 %11, i64* %2
%12 = load i64, i64* %2
%13 = sdiv i64 %12, 2
store i64 %13, i64* %2
%14 = load i64, i64* %4
%15 = load i64, i64* %3
%16 = load i16, i16* %5
%17 = call i64 @pow(i32 10, i16 signext %16)
%18 = mul nsw i64 %15, %17
%19 = add nsw i64 %14, %18
store i64 %19, i64* %4
%20 = load i16, i16* %5
%21 = add i16 %20, 1
store i16 %21, i16* %5
br label %22
22: ; preds = %6
%23 = load i64, i64* %2
%24 = icmp sge i64 %23, 1
br i1 %24, label %6, label %25
25: ; preds = %22
%26 = load i64, i64* %4
ret i64 %26
}

LLVM IR (-O2):
define i64 @dec2bin(i64 %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ %0, %1 ], [ %7, %2 ]
%4 = phi i64 [ 0, %1 ], [ %10, %2 ]
%5 = phi i16 [ 0, %1 ], [ %11, %2 ]
%6 = srem i64 %3, 2
%7 = sdiv i64 %3, 2
%8 = tail call i64 @pow(i32 10, i16 signext %5)
%9 = mul nsw i64 %8, %6
%10 = add nsw i64 %9, %4
%11 = add i16 %5, 1
%12 = icmp sgt i64 %3, 1
br i1 %12, label %2, label %13
13: ; preds = %2
ret i64 %10
}