#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*/ printf(char *, int);
void dec_to_bin(int liczba) {
  int i = 0, tab[31], j;
  while (liczba) {
    tab[i++] = liczba % 2;
    liczba /= 2;
  }
  for (j = i - 1; j >= 0; j--)
    printf("%d", tab[j]);
}


x86 assembly (clang, -O0):
<dec_to_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1161 <dec_to_bin+0x51>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
cltq
mov    %edx,-0x90(%rbp,%rax,4)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1125 <dec_to_bin+0x15>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x94(%rbp)
cmpl   $0x0,-0x94(%rbp)
jl     11a8 <dec_to_bin+0x98>
movslq -0x94(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%esi
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
mov    -0x94(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x94(%rbp)
jmp    116d <dec_to_bin+0x5d>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dec_to_bin>:
push   %r14
push   %rbx
sub    $0x88,%rsp
test   %edi,%edi
je     1188 <dec_to_bin+0x78>
xor    %eax,%eax
mov    %edi,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
shr    $0x1f,%ecx
add    %edi,%ecx
mov    %ecx,%edx
and    $0xfffffffe,%edx
mov    %edi,%esi
sub    %edx,%esi
mov    %esi,(%rsp,%rax,4)
add    $0x1,%rax
sar    %ecx
add    $0x1,%edi
cmp    $0x3,%edi
mov    %ecx,%edi
jae    1130 <dec_to_bin+0x20>
test   %eax,%eax
jle    1188 <dec_to_bin+0x78>
mov    %eax,%ebx
add    $0x1,%rbx
lea    0xe9e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x2(%rbx),%eax
mov    (%rsp,%rax,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1170 <dec_to_bin+0x60>
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @dec_to_bin(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [31 x i32]
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %9, %1
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* %2
%11 = srem i32 %10, 2
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
%14 = sext i32 %12 to i64
%15 = getelementptr inbounds [31 x i32], [31 x i32]* %4, i64 0, i64 %14
store i32 %11, i32* %15
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 2
store i32 %17, i32* %2
br label %6
18: ; preds = %6
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 1
store i32 %20, i32* %5
br label %21
21: ; preds = %30, %18
%22 = load i32, i32* %5
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %21
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [31 x i32], [31 x i32]* %4, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %24
%31 = load i32, i32* %5
%32 = add nsw i32 %31, -1
store i32 %32, i32* %5
br label %21
33: ; preds = %21
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @dec_to_bin(i32 %0) {
%2 = alloca [31 x i32]
%3 = bitcast [31 x i32]* %2 to i8*
%4 = icmp eq i32 %0, 0
br i1 %4, label %27, label %10
5: ; preds = %10
%6 = trunc i64 %14 to i32
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %27
8: ; preds = %5
%9 = and i64 %14, 4294967295
br label %19
10: ; preds = %1, %10
%11 = phi i64 [ %14, %10 ], [ 0, %1 ]
%12 = phi i32 [ %16, %10 ], [ %0, %1 ]
%13 = srem i32 %12, 2
%14 = add nuw i64 %11, 1
%15 = getelementptr inbounds [31 x i32], [31 x i32]* %2, i64 0, i64 %11
store i32 %13, i32* %15
%16 = sdiv i32 %12, 2
%17 = add i32 %12, 1
%18 = icmp ult i32 %17, 3
br i1 %18, label %5, label %10
19: ; preds = %8, %19
%20 = phi i64 [ %9, %8 ], [ %21, %19 ]
%21 = add nsw i64 %20, -1
%22 = and i64 %21, 4294967295
%23 = getelementptr inbounds [31 x i32], [31 x i32]* %2, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = icmp ugt i64 %20, 1
br i1 %26, label %19, label %27
27: ; preds = %19, %1, %5
ret void
}