#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 *, int *);
main() {
  int a, b, c, d;
  printf("Vvedite chislo");
  scanf("%d", &a);
  d = 0;
  while (a > 0) {
    b = a % 2;
    printf("%d", b);
    a /= 2;
  }
  while (b > 0) {
    d = b % 10;
    if (b = 0)
      ;
    printf("0");
    printf("%d", d);
    b = b / 10;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1190 <main+0x70>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x34>
jmp    1195 <main+0x75>
cmpl   $0x0,-0xc(%rbp)
jle    11fa <main+0xda>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
test   $0x1,%al
jne    11c3 <main+0xa3>
jmp    11c8 <main+0xa8>
jmp    11c8 <main+0xa8>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    1195 <main+0x75>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec7(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    119b <main+0x6b>
lea    0xeae(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebp
and    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
mov    %eax,0x4(%rsp)
cmp    $0x1,%ecx
jg     1170 <main+0x40>
test   %ebp,%ebp
je     11b8 <main+0x88>
mov    $0x30,%edi
call   1030 <putchar@plt>
lea    0xe63(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"Vvedite chislo\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %9, label %16
7: ; preds = %9
%8 = icmp eq i32 %11, 0
br i1 %8, label %19, label %16
9: ; preds = %0, %9
%10 = phi i32 [ %14, %9 ], [ %5, %0 ]
%11 = and i32 %10, 1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %1
%14 = sdiv i32 %13, 2
store i32 %14, i32* %1
%15 = icmp sgt i32 %13, 1
br i1 %15, label %9, label %7
16: ; preds = %0, %7
%17 = call i32 @putchar(i32 48)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %19
19: ; preds = %16, %7
ret i32 0
}