#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 /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  const int C = 2;
  int x = 0;
  while (1) {
    printf("Dwste to dekadiko arithmo pou thelete na metatrapei se dyadiko:\n");
    scanf(" %d", &x);
    if (x == 0)
      break;
    printf("\nO arithmos %d ANTESTRAMENOS sto dyadiko systhma einai : ", x);
    short mod = x % C;
    mod == 1 ? putchar('1') : putchar('0');
    do {
      if (x == 0)
        break;
      x /= C;
      mod = x % C;
      mod == 1 ? printf("%d", 1) : printf("%d", 0);
    } while (x != 0);
    printf("\n\n");
    x = 0;
  }
  printf(
      "\n\nClosing Program. . .\nAutor: Vasilis Anastasiadis\nAM: 123533\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    117a <main+0x4a>
jmp    124b <main+0x11b>
mov    -0xc(%rbp),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %dx,%ax
mov    %ax,-0xe(%rbp)
movswl -0xe(%rbp),%eax
cmp    $0x1,%eax
jne    11b9 <main+0x89>
mov    $0x31,%edi
call   1030 <putchar@plt>
jmp    11c3 <main+0x93>
mov    $0x30,%edi
call   1030 <putchar@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11d2 <main+0xa2>
jmp    1231 <main+0x101>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %dx,%ax
mov    %ax,-0xe(%rbp)
movswl -0xe(%rbp),%eax
cmp    $0x1,%eax
jne    1217 <main+0xe7>
lea    0xe3c(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1227 <main+0xf7>
lea    0xe24(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11c3 <main+0x93>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
jmp    114d <main+0x1d>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xee4(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9a(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     1246 <main+0x106>
lea    0xe81(%rip),%r14
lea    0xf31(%rip),%r15
lea    0xead(%rip),%r12
lea    0xe68(%rip),%r13
lea    0x4(%rsp),%rbx
lea    0xe5d(%rip),%rbp
jmp    11db <main+0x9b>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1040 <puts@plt>
movl   $0x0,0x4(%rsp)
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     1246 <main+0x106>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
cs nopw 0x0(%rax,%rax,1)
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11b0 <main+0x70>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
mov    %ecx,%eax
sar    %eax
mov    %eax,0x4(%rsp)
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
xor    %esi,%esi
cmp    $0x1,%eax
sete   %sil
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1210 <main+0xd0>
lea    0xe31(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [65 x i8] c"Dwste to dekadiko arithmo pou thelete na metatrapei se dyadiko:\0A\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [58 x i8] c"\0AO arithmos %d ANTESTRAMENOS sto dyadiko systhma einai : \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"\0A\0A\00"
@.str.5 = [64 x i8] c"\0A\0AClosing Program. . .\0AAutor: Vasilis Anastasiadis\0AAM: 123533\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i16
store i32 0, i32* %1
store i32 2, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %0, %48
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %5
br label %50
11: ; preds = %5
%12 = load i32, i32* %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %3
%15 = srem i32 %14, 2
%16 = trunc i32 %15 to i16
store i16 %16, i16* %4
%17 = load i16, i16* %4
%18 = sext i16 %17 to i32
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %22
20: ; preds = %11
%21 = call i32 @putchar(i8 signext 49)
br label %24
22: ; preds = %11
%23 = call i32 @putchar(i8 signext 48)
br label %24
24: ; preds = %22, %20
%25 = phi i32 [ %21, %20 ], [ %23, %22 ]
br label %26
26: ; preds = %45, %24
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %26
br label %48
30: ; preds = %26
%31 = load i32, i32* %3
%32 = sdiv i32 %31, 2
store i32 %32, i32* %3
%33 = load i32, i32* %3
%34 = srem i32 %33, 2
%35 = trunc i32 %34 to i16
store i16 %35, i16* %4
%36 = load i16, i16* %4
%37 = sext i16 %36 to i32
%38 = icmp eq i32 %37, 1
br i1 %38, label %39, label %41
39: ; preds = %30
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 1)
br label %43
41: ; preds = %30
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 0)
br label %43
43: ; preds = %41, %39
%44 = phi i32 [ %40, %39 ], [ %42, %41 ]
br label %45
45: ; preds = %43
%46 = load i32, i32* %3
%47 = icmp ne i32 %46, 0
br i1 %47, label %26, label %48
48: ; preds = %45, %29
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %5
50: ; preds = %10
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [58 x i8] c"\0AO arithmos %d ANTESTRAMENOS sto dyadiko systhma einai : \00"
@.str.3 = [3 x i8] c"%d\00"
@str = [64 x i8] c"Dwste to dekadiko arithmo pou thelete na metatrapei se dyadiko:\00"
@str.6 = [2 x i8] c"\0A\00"
@str.7 = [63 x i8] c"\0A\0AClosing Program. . .\0AAutor: Vasilis Anastasiadis\0AAM: 123533\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %32, label %7
7: ; preds = %0, %26
%8 = phi i32 [ %30, %26 ], [ %5, %0 ]
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %1
%11 = srem i32 %10, 2
%12 = icmp eq i32 %11, 1
%13 = select i1 %12, i8 49, i8 48
%14 = call i32 @putchar(i8 signext %13)
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %7, %17
%18 = phi i32 [ %24, %17 ], [ %15, %7 ]
%19 = sdiv i32 %18, 2
store i32 %19, i32* %1
%20 = srem i32 %19, 2
%21 = icmp eq i32 %20, 1
%22 = zext i1 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %1
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %17
26: ; preds = %17, %7
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
store i32 0, i32* %1
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%30 = load i32, i32* %1
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %7
32: ; preds = %26, %0
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}