#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 */
scalar_t__ pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
void main() {
  int number = 10000000, sum = 0, count = 0;
  printf("Enter a number in (01):");
  scanf("%d", &number);
  while (number != 0) {
    if (number % 10) {
      sum += (int)pow(2, count);
    }
    number /= 10;
    count++;
  }
  printf("Result:%d\n", sum);
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x989680,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
je     11c8 <main+0x88>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11ac <main+0x6c>
mov    -0xc(%rbp),%esi
mov    $0x2,%edi
call   1060 <pow@plt>
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117b <main+0x3b>
mov    -0x8(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
call   1030 <system@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
movl   $0x989680,0x4(%rsp)
lea    0xeae(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11d0 <main+0x90>
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    11a6 <main+0x66>
nopw   0x0(%rax,%rax,1)
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
mov    %eax,0x4(%rsp)
add    $0x1,%ebp
add    $0x9,%ecx
cmp    $0x12,%ecx
jbe    11d0 <main+0x90>
imul   $0xcccccccd,%eax,%ecx
add    $0x19999998,%ecx
ror    %ecx
cmp    $0x19999999,%ecx
jb     1180 <main+0x40>
mov    $0x2,%edi
mov    %ebp,%esi
call   1060 <pow@plt>
add    %eax,%ebx
mov    0x4(%rsp),%eax
jmp    1180 <main+0x40>
lea    0xe44(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3f(%rip),%rdi
call   1030 <system@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Enter a number in (01):\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"Result:%d\0A\00"
@.str.3 = [6 x i8] c"pause\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 10000000, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 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)
br label %6
6: ; preds = %19, %0
%7 = load i32, i32* %1
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = load i32, i32* %1
%11 = srem i32 %10, 10
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = load i32, i32* %3
%15 = call i64 @pow(i32 2, i32 %14)
%16 = trunc i64 %15 to i32
%17 = load i32, i32* %2
%18 = add nsw i32 %17, %16
store i32 %18, i32* %2
br label %19
19: ; preds = %13, %9
%20 = load i32, i32* %1
%21 = sdiv i32 %20, 10
store i32 %21, i32* %1
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %6
24: ; preds = %6
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Enter a number in (01):\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"Result:%d\0A\00"
@.str.3 = [6 x i8] c"pause\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 10000000, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 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 eq i32 %5, 0
br i1 %6, label %25, label %7
7: ; preds = %0, %18
%8 = phi i32 [ %22, %18 ], [ 0, %0 ]
%9 = phi i32 [ %20, %18 ], [ 0, %0 ]
%10 = phi i32 [ %21, %18 ], [ %5, %0 ]
%11 = srem i32 %10, 10
%12 = icmp eq i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %7
%14 = call i64 @pow(i32 2, i32 %8)
%15 = trunc i64 %14 to i32
%16 = add nsw i32 %9, %15
%17 = load i32, i32* %1
br label %18
18: ; preds = %13, %7
%19 = phi i32 [ %17, %13 ], [ %10, %7 ]
%20 = phi i32 [ %16, %13 ], [ %9, %7 ]
%21 = sdiv i32 %19, 10
store i32 %21, i32* %1
%22 = add nuw nsw i32 %8, 1
%23 = add i32 %19, 9
%24 = icmp ult i32 %23, 19
br i1 %24, label %25, label %7
25: ; preds = %18, %0
%26 = phi i32 [ 0, %0 ], [ %20, %18 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret void
}