#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 */
typedef scalar_t__ uint64_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, scalar_t__);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main(int argc, const char *argv[]) {
  uint32_t a, b;
  uint64_t result = 0;
  scanf("%u %u", &a, &b);
  size_t i;
  for (i = 0; i < sizeof(uint32_t) * 8; i++) {
    if (b & (0x1U << i)) {
      result += (uint64_t)(a << i);
    }
  }
  printf("%lu\n", result);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xebb(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
movq   $0x0,-0x28(%rbp)
cmpq   $0x20,-0x28(%rbp)
jae    11a9 <main+0x89>
mov    -0x18(%rbp),%eax
mov    -0x28(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1193 <main+0x73>
mov    -0x14(%rbp),%eax
mov    -0x28(%rbp),%rcx
shl    %cl,%eax
cltq
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1198 <main+0x78>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    115a <main+0x3a>
mov    -0x20(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%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    (%rsp),%r9d
xor    %r8d,%r8d
mov    0x4(%rsp),%r10d
xor    %eax,%eax
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r10d,%edi
mov    %eax,%ecx
shl    %cl,%edi
bt     %eax,%r9d
cmovae %r8d,%edi
movslq %edi,%rdi
lea    0x1(%rax),%ecx
movzbl %cl,%ecx
mov    %r10d,%edx
shl    %cl,%edx
add    %rsi,%rdi
bt     %ecx,%r9d
cmovae %r8d,%edx
movslq %edx,%rsi
add    %rdi,%rsi
add    $0x2,%rax
cmp    $0x20,%rax
jne    1150 <main+0x30>
lea    0xe77(%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 = [5 x i8] c"%lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %8
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %6, i32* %7)
store i64 0, i64* %9
br label %11
11: ; preds = %30, %2
%12 = load i64, i64* %9
%13 = icmp ult i64 %12, 32
br i1 %13, label %14, label %33
14: ; preds = %11
%15 = load i32, i32* %7
%16 = load i64, i64* %9
%17 = trunc i64 %16 to i32
%18 = shl i32 1, %17
%19 = and i32 %15, %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %14
%22 = load i32, i32* %6
%23 = load i64, i64* %9
%24 = trunc i64 %23 to i32
%25 = shl i32 %22, %24
%26 = sext i32 %25 to i64
%27 = load i64, i64* %8
%28 = add nsw i64 %27, %26
store i64 %28, i64* %8
br label %29
29: ; preds = %21, %14
br label %30
30: ; preds = %29
%31 = load i64, i64* %9
%32 = add i64 %31, 1
store i64 %32, i64* %9
br label %11
33: ; preds = %11
%34 = load i64, i64* %8
%35 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %34)
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [6 x i8] c"%u %u\00"
@.str.1 = [5 x i8] c"%lu\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%8 = load i32, i32* %4
%9 = load i32, i32* %3
br label %10
10: ; preds = %10, %2
%11 = phi i64 [ 0, %2 ], [ %30, %10 ]
%12 = phi i64 [ 0, %2 ], [ %29, %10 ]
%13 = trunc i64 %11 to i32
%14 = shl nuw i32 1, %13
%15 = and i32 %8, %14
%16 = icmp eq i32 %15, 0
%17 = shl i32 %9, %13
%18 = select i1 %16, i32 0, i32 %17
%19 = sext i32 %18 to i64
%20 = add nsw i64 %12, %19
%21 = trunc i64 %11 to i32
%22 = or i32 %21, 1
%23 = shl nuw i32 1, %22
%24 = and i32 %8, %23
%25 = icmp eq i32 %24, 0
%26 = shl i32 %9, %22
%27 = select i1 %25, i32 0, i32 %26
%28 = sext i32 %27 to i64
%29 = add nsw i64 %20, %28
%30 = add nuw nsw i64 %11, 2
%31 = icmp eq i64 %30, 32
br i1 %31, label %32, label %10
32: ; preds = %10
%33 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %29)
ret i32 0
}