#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 helper(int, int);
int superPow(int a, int *b, int bSize) {
  int res = 1;
  for (int i = bSize - 1; i >= 0; i--) {
    res = ((res * helper(a, b[i])) % 1337);
    a = helper(a, 10);
  }
  return res;
}


x86 assembly (clang, -O0):
<superPow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1186 <superPow+0x76>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1030 <helper@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
imul   %ecx,%eax
mov    $0x539,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xa,%esi
call   1030 <helper@plt>
mov    %eax,-0x4(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1132 <superPow+0x22>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<superPow>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edx,%edx
jle    117d <superPow+0x6d>
mov    %rsi,%r14
mov    %edi,%r15d
mov    %edx,%ebp
add    $0x1,%rbp
mov    $0x1,%ebx
nopl   0x0(%rax)
lea    -0x2(%rbp),%eax
mov    (%r14,%rax,4),%esi
mov    %r15d,%edi
call   1030 <helper@plt>
imul   %ebx,%eax
movslq %eax,%rbx
imul   $0x6208cecb,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x29,%rax
add    %ecx,%eax
imul   $0x539,%eax,%eax
sub    %eax,%ebx
mov    %r15d,%edi
mov    $0xa,%esi
call   1030 <helper@plt>
mov    %eax,%r15d
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
ja     1130 <superPow+0x20>
jmp    1182 <superPow+0x72>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @superPow(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 1, i32* %7
%9 = load i32, i32* %6
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %8
br label %11
11: ; preds = %27, %3
%12 = load i32, i32* %8
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %11
%15 = load i32, i32* %7
%16 = load i32, i32* %4
%17 = load i32*, i32** %5
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = call i32 @helper(i32 %16, i32 %21)
%23 = mul nsw i32 %15, %22
%24 = srem i32 %23, 1337
store i32 %24, i32* %7
%25 = load i32, i32* %4
%26 = call i32 @helper(i32 %25, i32 10)
store i32 %26, i32* %4
br label %27
27: ; preds = %14
%28 = load i32, i32* %8
%29 = add nsw i32 %28, -1
store i32 %29, i32* %8
br label %11
30: ; preds = %11
%31 = load i32, i32* %7
ret i32 %31
}

LLVM IR (-O2):
define i32 @superPow(i32 %0, i32* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %9
7: ; preds = %9, %3
%8 = phi i32 [ 1, %3 ], [ %19, %9 ]
ret i32 %8
9: ; preds = %5, %9
%10 = phi i64 [ %6, %5 ], [ %13, %9 ]
%11 = phi i32 [ 1, %5 ], [ %19, %9 ]
%12 = phi i32 [ %0, %5 ], [ %20, %9 ]
%13 = add nsw i64 %10, -1
%14 = and i64 %13, 4294967295
%15 = getelementptr inbounds i32, i32* %1, i64 %14
%16 = load i32, i32* %15
%17 = tail call i32 @helper(i32 %12, i32 %16)
%18 = mul nsw i32 %17, %11
%19 = srem i32 %18, 1337
%20 = tail call i32 @helper(i32 %12, i32 10)
%21 = icmp ugt i64 %10, 1
br i1 %21, label %9, label %7
}