#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 *, unsigned int);
int /*<<< orphan*/ scanf(char *, unsigned int *, unsigned int *);
int main() {
  unsigned a, b;
  unsigned sum;
  sum = 0;
  scanf("%u %u", &a, &b);
  while (a > 0) {
    if (a & 1) {
      sum += b;
    }
    a >>= 1;
    b <<= 1;
  }
  printf("%u\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jbe    1183 <main+0x63>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     116c <main+0x4c>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114a <main+0x2a>
mov    -0x10(%rbp),%esi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
xor    %esi,%esi
test   %eax,%eax
je     116d <main+0x4d>
mov    (%rsp),%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%edx
mov    %eax,%edi
and    $0x1,%edi
neg    %edi
and    %ecx,%edi
add    %edi,%esi
shr    %eax
add    %ecx,%ecx
cmp    $0x1,%edx
ja     1150 <main+0x30>
mov    %eax,0x4(%rsp)
mov    %ecx,(%rsp)
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%u %u\00"
@.str.1 = [4 x i8] c"%u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
br label %6
6: ; preds = %17, %0
%7 = load i32, i32* %2
%8 = icmp ugt i32 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32, i32* %2
%11 = and i32 %10, 1
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = add i32 %15, %14
store i32 %16, i32* %4
br label %17
17: ; preds = %13, %9
%18 = load i32, i32* %2
%19 = lshr i32 %18, 1
store i32 %19, i32* %2
%20 = load i32, i32* %3
%21 = shl i32 %20, 1
store i32 %21, i32* %3
br label %6
22: ; preds = %6
%23 = load i32, i32* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%u %u\00"
@.str.1 = [4 x i8] c"%u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %22, label %8
8: ; preds = %0
%9 = load i32, i32* %2
br label %10
10: ; preds = %8, %10
%11 = phi i32 [ %17, %10 ], [ 0, %8 ]
%12 = phi i32 [ %18, %10 ], [ %6, %8 ]
%13 = phi i32 [ %19, %10 ], [ %9, %8 ]
%14 = and i32 %12, 1
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 0, i32 %13
%17 = add i32 %16, %11
%18 = lshr i32 %12, 1
%19 = shl i32 %13, 1
%20 = icmp ult i32 %12, 2
br i1 %20, label %21, label %10
21: ; preds = %10
store i32 %18, i32* %1
store i32 %19, i32* %2
br label %22
22: ; preds = %21, %0
%23 = phi i32 [ %17, %21 ], [ 0, %0 ]
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret i32 0
}