#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
void calcbin(int num) {
  const int dyo = 2;
  printf("O arithmos poy dwsate, se antistrofh dyadikh anaparastash einai: ");
  while (num > -1) {
    num % dyo == 1 ? putchar('1') : putchar('0');
    num = num / dyo;
    if (num == 0) {
      exit(0);
    }
  }
}


x86 assembly (clang, -O0):
<calcbin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0xffffffff,-0x4(%rbp)
jle    11a9 <calcbin+0x79>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    117b <calcbin+0x4b>
mov    $0x31,%edi
call   1030 <putchar@plt>
jmp    1185 <calcbin+0x55>
mov    $0x30,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11a4 <calcbin+0x74>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    114e <calcbin+0x1e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcbin>:
push   %rbx
mov    %edi,%ebx
lea    0xec6(%rip),%rdi
call   1040 <printf@plt>
nop
test   %ebx,%ebx
js     1163 <calcbin+0x33>
mov    %ebx,%edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
shr    %eax
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     1140 <calcbin+0x10>
xor    %edi,%edi
call   1050 <exit@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [66 x i8] c"O arithmos poy dwsate, se antistrofh dyadikh anaparastash einai: \00"
define void @calcbin(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 2, i32* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %24, %1
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, -1
br i1 %7, label %8, label %25
8: ; preds = %5
%9 = load i32, i32* %2
%10 = srem i32 %9, 2
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @putchar(i8 signext 49)
br label %16
14: ; preds = %8
%15 = call i32 @putchar(i8 signext 48)
br label %16
16: ; preds = %14, %12
%17 = phi i32 [ %13, %12 ], [ %15, %14 ]
%18 = load i32, i32* %2
%19 = sdiv i32 %18, 2
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %16
br label %5
25: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [66 x i8] c"O arithmos poy dwsate, se antistrofh dyadikh anaparastash einai: \00"
define void @calcbin(i32 %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %6, %1
%4 = phi i32 [ %0, %1 ], [ %11, %6 ]
%5 = icmp sgt i32 %4, -1
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = and i32 %4, 1
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8 48, i8 49
%10 = tail call i32 @putchar(i8 signext %9)
%11 = lshr i32 %4, 1
%12 = icmp ult i32 %4, 2
br i1 %12, label %13, label %3
13: ; preds = %6
%14 = tail call i32 @exit(i32 0)
unreachable
15: ; preds = %3
ret void
}