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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0x0,-0x10(%rbp)
jle    11c6 <main+0xa6>
mov    -0x10(%rbp),%rsi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    11b3 <main+0x93>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rdx,%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
jmp    1172 <main+0x52>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e2 <main+0xc2>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e7 <main+0xc7>
cmpq   $0x0,-0x10(%rbp)
jne    112f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xee0(%rip),%r14
lea    0xea5(%rip),%rbx
lea    0x8(%rsp),%r15
lea    0xe9c(%rip),%r12
lea    0xed8(%rip),%r13
jmp    118a <main+0x4a>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpq   $0x0,0x8(%rsp)
je     11ec <main+0xac>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
jle    1170 <main+0x30>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
jle    1178 <main+0x38>
nopl   0x0(%rax,%rax,1)
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rax
mov    %rax,%rsi
shr    $0x3f,%rsi
add    %rax,%rsi
sar    %rsi
mov    %rsi,0x8(%rsp)
cmp    $0x1,%rax
jg     11c0 <main+0x80>
jmp    1178 <main+0x38>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 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 = [2 x i8] c"\0A\00"
@.str.4 = [16 x i8] c"Lathos epilogi\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
br label %3
3: ; preds = %28, %0
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 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), i64* %2)
%6 = load i64, i64* %2
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %3
%9 = load i64, i64* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i64 %9)
%11 = load i64, i64* %2
store i64 %11, i64* %2
br label %12
12: ; preds = %19, %8
%13 = load i64, i64* %2
%14 = icmp sgt i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i64, i64* %2
%17 = srem i64 %16, 2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 %17)
br label %19
19: ; preds = %15
%20 = load i64, i64* %2
%21 = sdiv i64 %20, 2
store i64 %21, i64* %2
br label %12
22: ; preds = %12
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %27
24: ; preds = %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %24, %22
br label %28
28: ; preds = %27
%29 = load i64, i64* %2
%30 = icmp ne i64 %29, 0
br i1 %30, label %3, label %31
31: ; preds = %28
%32 = load i32, i32* %1
ret i32 %32
}

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"
@str = [18 x i8] c"Dwse neo arithmo:\00"
@str.5 = [15 x i8] c"Lathos epilogi\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
br label %3
3: ; preds = %21, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 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), i64* %1)
%6 = load i64, i64* %1
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %3
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i64 %6)
%10 = load i64, i64* %1
%11 = icmp sgt i64 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %8, %12
%13 = phi i64 [ %17, %12 ], [ %10, %8 ]
%14 = and i64 %13, 1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 %14)
%16 = load i64, i64* %1
%17 = sdiv i64 %16, 2
store i64 %17, i64* %1
%18 = icmp sgt i64 %16, 1
br i1 %18, label %12, label %21
19: ; preds = %3
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0))
br label %21
21: ; preds = %12, %8, %19
%22 = call i32 @putchar(i32 10)
%23 = load i64, i64* %1
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %3
25: ; preds = %21
ret i32 0
}