#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(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num, a, b, c;
  const int t = 2;
  do {
    printf("Please give a possetive number\n");
    scanf("%d", &num);
    if (num < 0)
      printf("Wrong number. Prlease give a positive one\n");
  } while (num <= 0);
  a = num;
  while (a != 0) {
    b = a % t;
    a = a / t;
    c = ((b == 1) ? 1 : 0);
    putchar('0' + c);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x18(%rbp)
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    1178 <main+0x48>
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
jmp    117d <main+0x4d>
cmpl   $0x0,-0x8(%rbp)
jle    1146 <main+0x16>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11d6 <main+0xa6>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x1,%edx
cmove  %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
add    $0x30,%edi
call   1030 <putchar@plt>
jmp    118d <main+0x5d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%r14
lea    0xeb6(%rip),%r15
lea    0xc(%rsp),%rbx
lea    0xecc(%rip),%r12
jmp    1164 <main+0x34>
nopl   0x0(%rax,%rax,1)
test   %ebp,%ebp
jg     1190 <main+0x60>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
jns    1160 <main+0x30>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%ebp
jmp    1160 <main+0x30>
nopl   (%rax)
mov    %ebp,%eax
shr    $0x1f,%eax
add    %ebp,%eax
mov    %eax,%ebx
sar    %ebx
and    $0xfffffffe,%eax
mov    %ebp,%ecx
sub    %eax,%ecx
xor    %edi,%edi
cmp    $0x1,%ecx
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    $0x2,%ebp
mov    %ebx,%ebp
ja     1190 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Please give a possetive number\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [43 x i8] c"Wrong number. Prlease give a positive one\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %6
br label %7
7: ; preds = %15, %0
%8 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %7
br label %15
15: ; preds = %14
%16 = load i32, i32* %2
%17 = icmp sle i32 %16, 0
br i1 %17, label %7, label %18
18: ; preds = %15
%19 = load i32, i32* %2
store i32 %19, i32* %3
br label %20
20: ; preds = %23, %18
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %20
%24 = load i32, i32* %3
%25 = srem i32 %24, 2
store i32 %25, i32* %4
%26 = load i32, i32* %3
%27 = sdiv i32 %26, 2
store i32 %27, i32* %3
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 1
%30 = zext i1 %29 to i64
%31 = select i1 %29, i32 1, i32 0
store i32 %31, i32* %5
%32 = load i32, i32* %5
%33 = add nsw i32 48, %32
%34 = call i32 @putchar(i32 %33)
br label %20
35: ; preds = %20
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [31 x i8] c"Please give a possetive number\00"
@str.3 = [42 x i8] c"Wrong number. Prlease give a positive one\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %11, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 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 = load i32, i32* %1
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.3, i64 0, i64 0))
%10 = load i32, i32* %1
br label %11
11: ; preds = %3, %8
%12 = phi i32 [ %6, %3 ], [ %10, %8 ]
%13 = icmp slt i32 %12, 1
br i1 %13, label %3, label %14
14: ; preds = %11, %14
%15 = phi i32 [ %17, %14 ], [ %12, %11 ]
%16 = srem i32 %15, 2
%17 = sdiv i32 %15, 2
%18 = icmp eq i32 %16, 1
%19 = select i1 %18, i32 49, i32 48
%20 = call i32 @putchar(i32 %19)
%21 = add i32 %15, 1
%22 = icmp ult i32 %21, 3
br i1 %22, label %23, label %14
23: ; preds = %14
ret i32 0
}