#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 pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, j, x;
  x = 0;
  i = 1;
  j = 10;
  printf("enter ur nember\n");
  scanf("%d", &x);
  while (x > (j - 1)) {
    i = i + 1;
    j = j * 10;
  }
  printf("The number is %d and it has %d length>>>\n", x, i);
  int k, sum;
  sum = 0;
  for (k = 0; k < i; k = k + 1) {
    sum = sum + pow(2, k);
  }
  printf("the decimal number is %d", sum);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    1198 <main+0x68>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <main+0x42>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f1 <main+0xc1>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ba <main+0x8a>
mov    -0x18(%rbp),%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%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
movl   $0x0,0xc(%rsp)
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
lea    0xed9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
mov    $0x1,%r14d
cmp    $0xa,%esi
jl     119d <main+0x5d>
mov    $0x1,%r14d
mov    $0xa,%eax
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14d
add    %eax,%eax
lea    (%rax,%rax,4),%eax
cmp    %eax,%esi
jge    1190 <main+0x50>
lea    0xe5c(%rip),%rdi
xor    %ebp,%ebp
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x1(%r14),%eax
mov    %r14d,%r12d
and    $0x7,%r12d
mov    $0x0,%ebx
cmp    $0x7,%eax
jb     127f <main+0x13f>
and    $0xfffffff8,%r14d
xor    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2,%edi
mov    %ebx,%esi
call   1060 <pow@plt>
mov    %eax,%r15d
add    %ebp,%r15d
lea    0x1(%rbx),%esi
mov    $0x2,%edi
call   1060 <pow@plt>
mov    %eax,%ebp
add    %r15d,%ebp
lea    0x2(%rbx),%esi
mov    $0x2,%edi
call   1060 <pow@plt>
mov    %eax,%r15d
add    %ebp,%r15d
lea    0x3(%rbx),%esi
mov    $0x2,%edi
call   1060 <pow@plt>
mov    %eax,%ebp
add    %r15d,%ebp
lea    0x4(%rbx),%esi
mov    $0x2,%edi
call   1060 <pow@plt>
mov    %eax,%r15d
add    %ebp,%r15d
lea    0x5(%rbx),%esi
mov    $0x2,%edi
call   1060 <pow@plt>
mov    %eax,%ebp
add    %r15d,%ebp
lea    0x6(%rbx),%esi
mov    $0x2,%edi
call   1060 <pow@plt>
mov    %eax,%r15d
add    %ebp,%r15d
lea    0x7(%rbx),%esi
mov    $0x2,%edi
call   1060 <pow@plt>
mov    %eax,%ebp
add    %r15d,%ebp
add    $0x8,%ebx
cmp    %r14d,%ebx
jne    11e0 <main+0xa0>
test   %r12d,%r12d
je     12a7 <main+0x167>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2,%edi
mov    %ebx,%esi
call   1060 <pow@plt>
add    %eax,%ebp
add    $0x1,%ebx
add    $0xffffffff,%r12d
jne    1290 <main+0x150>
lea    0xd7c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"enter ur nember\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [42 x i8] c"The number is %d and it has %d length>>>\0A\00"
@.str.3 = [25 x i8] c"the decimal number is %d\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 0, i32* %4
store i32 1, i32* %2
store i32 10, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %9
9: ; preds = %14, %0
%10 = load i32, i32* %4
%11 = load i32, i32* %3
%12 = sub nsw i32 %11, 1
%13 = icmp sgt i32 %10, %12
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
%17 = load i32, i32* %3
%18 = mul nsw i32 %17, 10
store i32 %18, i32* %3
br label %9
19: ; preds = %9
%20 = load i32, i32* %4
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %21)
store i32 0, i32* %6
store i32 0, i32* %5
br label %23
23: ; preds = %32, %19
%24 = load i32, i32* %5
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %35
27: ; preds = %23
%28 = load i32, i32* %6
%29 = load i32, i32* %5
%30 = call i32 @pow(i32 2, i32 %29)
%31 = add nsw i32 %28, %30
store i32 %31, i32* %6
br label %32
32: ; preds = %27
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %23
35: ; preds = %23
%36 = load i32, i32* %6
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %36)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [42 x i8] c"The number is %d and it has %d length>>>\0A\00"
@.str.3 = [25 x i8] c"the decimal number is %d\00"
@str = [16 x i8] c"enter ur nember\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 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 slt i32 %5, 10
br i1 %6, label %13, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %11, %7 ], [ 10, %0 ]
%9 = phi i32 [ %10, %7 ], [ 1, %0 ]
%10 = add nuw nsw i32 %9, 1
%11 = mul nsw i32 %8, 10
%12 = icmp slt i32 %5, %11
br i1 %12, label %13, label %7
13: ; preds = %7, %0
%14 = phi i32 [ 1, %0 ], [ %10, %7 ]
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %5, i32 %14)
%16 = add i32 %14, -1
%17 = and i32 %14, 7
%18 = icmp ult i32 %16, 7
br i1 %18, label %51, label %19
19: ; preds = %13
%20 = and i32 %14, -8
br label %21
21: ; preds = %21, %19
%22 = phi i32 [ 0, %19 ], [ %47, %21 ]
%23 = phi i32 [ 0, %19 ], [ %48, %21 ]
%24 = phi i32 [ 0, %19 ], [ %49, %21 ]
%25 = call i32 @pow(i32 2, i32 %23)
%26 = add nsw i32 %25, %22
%27 = or i32 %23, 1
%28 = call i32 @pow(i32 2, i32 %27)
%29 = add nsw i32 %28, %26
%30 = or i32 %23, 2
%31 = call i32 @pow(i32 2, i32 %30)
%32 = add nsw i32 %31, %29
%33 = or i32 %23, 3
%34 = call i32 @pow(i32 2, i32 %33)
%35 = add nsw i32 %34, %32
%36 = or i32 %23, 4
%37 = call i32 @pow(i32 2, i32 %36)
%38 = add nsw i32 %37, %35
%39 = or i32 %23, 5
%40 = call i32 @pow(i32 2, i32 %39)
%41 = add nsw i32 %40, %38
%42 = or i32 %23, 6
%43 = call i32 @pow(i32 2, i32 %42)
%44 = add nsw i32 %43, %41
%45 = or i32 %23, 7
%46 = call i32 @pow(i32 2, i32 %45)
%47 = add nsw i32 %46, %44
%48 = add nuw i32 %23, 8
%49 = add i32 %24, 8
%50 = icmp eq i32 %49, %20
br i1 %50, label %51, label %21
51: ; preds = %21, %13
%52 = phi i32 [ undef, %13 ], [ %47, %21 ]
%53 = phi i32 [ 0, %13 ], [ %47, %21 ]
%54 = phi i32 [ 0, %13 ], [ %48, %21 ]
%55 = icmp eq i32 %17, 0
br i1 %55, label %65, label %56
56: ; preds = %51, %56
%57 = phi i32 [ %61, %56 ], [ %53, %51 ]
%58 = phi i32 [ %62, %56 ], [ %54, %51 ]
%59 = phi i32 [ %63, %56 ], [ 0, %51 ]
%60 = call i32 @pow(i32 2, i32 %58)
%61 = add nsw i32 %60, %57
%62 = add nuw i32 %58, 1
%63 = add i32 %59, 1
%64 = icmp eq i32 %63, %17
br i1 %64, label %65, label %56
65: ; preds = %56, %51
%66 = phi i32 [ %52, %51 ], [ %61, %56 ]
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %66)
ret i32 0
}