#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);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int a, b, ans = 1;
  scanf("%d%d", &a, &b);
  do
    ans = (ans * a) % 1000;
  while (--b);
  printf("%03d\n", ans);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jne    114a <main+0x2a>
mov    -0x10(%rbp),%esi
lea    0xe8d(%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),%r8d
mov    (%rsp),%edx
lea    -0x1(%rdx),%esi
mov    %edx,%ecx
and    $0x3,%ecx
cmp    $0x3,%esi
jae    1154 <main+0x34>
mov    $0x1,%esi
jmp    11f4 <main+0xd4>
and    $0xfffffffc,%edx
mov    $0x1,%esi
nopl   0x0(%rax)
imul   %r8d,%esi
movslq %esi,%rsi
imul   $0x10624dd3,%rsi,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x26,%rdi
add    %eax,%edi
imul   $0x3e8,%edi,%eax
sub    %eax,%esi
imul   %r8d,%esi
movslq %esi,%rax
imul   $0x10624dd3,%rax,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x26,%rsi
add    %edi,%esi
imul   $0x3e8,%esi,%esi
sub    %esi,%eax
imul   %r8d,%eax
cltq
imul   $0x10624dd3,%rax,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x26,%rsi
add    %edi,%esi
imul   $0x3e8,%esi,%esi
sub    %esi,%eax
imul   %r8d,%eax
movslq %eax,%rsi
imul   $0x10624dd3,%rsi,%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
sar    $0x26,%rax
add    %edi,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%esi
add    $0xfffffffc,%edx
jne    1160 <main+0x40>
test   %ecx,%ecx
je     1228 <main+0x108>
nopl   0x0(%rax,%rax,1)
imul   %r8d,%esi
movslq %esi,%rsi
imul   $0x10624dd3,%rsi,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rax
add    %edx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%esi
add    $0xffffffff,%ecx
jne    1200 <main+0xe0>
movl   $0x0,(%rsp)
lea    0xdcf(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [6 x i8] c"%03d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
br label %6
6: ; preds = %11, %0
%7 = load i32, i32* %4
%8 = load i32, i32* %2
%9 = mul nsw i32 %7, %8
%10 = srem i32 %9, 1000
store i32 %10, i32* %4
br label %11
11: ; preds = %6
%12 = load i32, i32* %3
%13 = add nsw i32 %12, -1
store i32 %13, i32* %3
%14 = icmp ne i32 %13, 0
br i1 %14, label %6, label %15
15: ; preds = %11
%16 = load i32, i32* %4
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [6 x i8] c"%03d\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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = add i32 %7, -1
%9 = and i32 %7, 3
%10 = icmp ult i32 %8, 3
br i1 %10, label %26, label %11
11: ; preds = %0
%12 = and i32 %7, -4
br label %13
13: ; preds = %13, %11
%14 = phi i32 [ 1, %11 ], [ %23, %13 ]
%15 = phi i32 [ 0, %11 ], [ %24, %13 ]
%16 = mul nsw i32 %6, %14
%17 = srem i32 %16, 1000
%18 = mul nsw i32 %6, %17
%19 = srem i32 %18, 1000
%20 = mul nsw i32 %6, %19
%21 = srem i32 %20, 1000
%22 = mul nsw i32 %6, %21
%23 = srem i32 %22, 1000
%24 = add i32 %15, 4
%25 = icmp eq i32 %24, %12
br i1 %25, label %26, label %13
26: ; preds = %13, %0
%27 = phi i32 [ undef, %0 ], [ %23, %13 ]
%28 = phi i32 [ 1, %0 ], [ %23, %13 ]
%29 = icmp eq i32 %9, 0
br i1 %29, label %37, label %30
30: ; preds = %26, %30
%31 = phi i32 [ %34, %30 ], [ %28, %26 ]
%32 = phi i32 [ %35, %30 ], [ 0, %26 ]
%33 = mul nsw i32 %6, %31
%34 = srem i32 %33, 1000
%35 = add i32 %32, 1
%36 = icmp eq i32 %35, %9
br i1 %36, label %37, label %30
37: ; preds = %30, %26
%38 = phi i32 [ %27, %26 ], [ %34, %30 ]
store i32 0, i32* %2
%39 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %38)
ret i32 0
}