#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 a;
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, d;
  const a = 2;
  do {
    printf("Dwse neo arithmo\n");
    scanf("%d", &n);
    d = getchar();
    printf("H antistrofi dyadiki anaparastasi tou %d einai: ", n);
    for (n = n; n > 0; n = n / a) {
      d = n % a;
      n > 0 ? putchar(d) : printf("Lathos epilogi\n");
    }
  } while (n != 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x10(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11e5 <main+0xa5>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11c4 <main+0x84>
mov    -0xc(%rbp),%edi
call   1030 <putchar@plt>
jmp    11d2 <main+0x92>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1195 <main+0x55>
jmp    11ea <main+0xaa>
cmpl   $0x0,-0x8(%rbp)
jne    1156 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed5(%rip),%r14
lea    0xe9a(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe91(%rip),%rbx
jmp    1184 <main+0x34>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %edi,%edi
je     11e0 <main+0x90>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
jle    1180 <main+0x30>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
and    $0x1,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
mov    %edi,0x4(%rsp)
cmp    $0x1,%eax
jg     11c0 <main+0x70>
jmp    1180 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Dwse neo arithmo\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [49 x i8] c"H antistrofi dyadiki anaparastasi tou %d einai: \00"
@.str.3 = [16 x i8] c"Lathos epilogi\0A\00"
@a = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %4
br label %5
5: ; preds = %31, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 (...) @getchar()
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %2
store i32 %11, i32* %2
br label %12
12: ; preds = %27, %5
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %30
15: ; preds = %12
%16 = load i32, i32* %2
%17 = srem i32 %16, 2
store i32 %17, i32* %3
%18 = load i32, i32* %2
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* %3
%22 = call i32 @putchar(i32 %21)
br label %25
23: ; preds = %15
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %23, %20
%26 = phi i32 [ %22, %20 ], [ %24, %23 ]
br label %27
27: ; preds = %25
%28 = load i32, i32* %2
%29 = sdiv i32 %28, 2
store i32 %29, i32* %2
br label %12
30: ; preds = %12
br label %31
31: ; preds = %30
%32 = load i32, i32* %2
%33 = icmp ne i32 %32, 0
br i1 %33, label %5, label %34
34: ; preds = %31
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [49 x i8] c"H antistrofi dyadiki anaparastasi tou %d einai: \00"
@a = global i32 0
@str = [17 x i8] c"Dwse neo arithmo\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %18, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = call i32 (...) @getchar()
%7 = load i32, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %3, %11
%12 = phi i32 [ %16, %11 ], [ %9, %3 ]
%13 = and i32 %12, 1
%14 = call i32 @putchar(i32 %13)
%15 = load i32, i32* %1
%16 = sdiv i32 %15, 2
store i32 %16, i32* %1
%17 = icmp sgt i32 %15, 1
br i1 %17, label %11, label %18
18: ; preds = %11, %3
%19 = phi i32 [ %9, %3 ], [ %16, %11 ]
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %3
21: ; preds = %18
ret i32 0
}