#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*/ mulArray(long long *, long long *, long long *, int);
long long int *mypow(long long int *A, long long int *B, int pow, int dim) {
  long long int *temp = NULL;
  if (pow == 1) {
    B = A;
  } else {
    temp = mypow(A, B, pow / 2, dim);
    if (pow % 2 == 0) {
      mulArray(temp, temp, B, dim);
    } else {
      mulArray(temp, temp, B, dim);
      mulArray(A, B, B, dim);
    }
  }
  return B;
}


x86 assembly (clang, -O0):
<mypow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1155 <mypow+0x35>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    11d0 <mypow+0xb0>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0x18(%rbp),%ecx
call   1030 <mypow@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a3 <mypow+0x83>
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%ecx
call   1040 <mulArray@plt>
jmp    11cb <mypow+0xab>
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%ecx
call   1040 <mulArray@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%ecx
call   1040 <mulArray@plt>
jmp    11d0 <mypow+0xb0>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mypow>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
cmp    $0x1,%edx
jne    1134 <mypow+0x14>
mov    %r15,%rbx
jmp    1173 <mypow+0x53>
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%rbx
shr    $0x1f,%edx
add    %ebp,%edx
sar    %edx
mov    %r15,%rdi
call   1030 <mypow@plt>
mov    %rax,%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1040 <mulArray@plt>
test   $0x1,%bpl
je     1173 <mypow+0x53>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1040 <mulArray@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64* @mypow(i64* %0, i64* %1, i32 %2, i32 %3) {
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64*
store i64* %0, i64** %5
store i64* %1, i64** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i64* null, i64** %9
%10 = load i32, i32* %7
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = load i64*, i64** %5
store i64* %13, i64** %6
br label %42
14: ; preds = %4
%15 = load i64*, i64** %5
%16 = load i64*, i64** %6
%17 = load i32, i32* %7
%18 = sdiv i32 %17, 2
%19 = load i32, i32* %8
%20 = call i64* @mypow(i64* %15, i64* %16, i32 %18, i32 %19)
store i64* %20, i64** %9
%21 = load i32, i32* %7
%22 = srem i32 %21, 2
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %14
%25 = load i64*, i64** %9
%26 = load i64*, i64** %9
%27 = load i64*, i64** %6
%28 = load i32, i32* %8
%29 = call i32 @mulArray(i64* %25, i64* %26, i64* %27, i32 %28)
br label %41
30: ; preds = %14
%31 = load i64*, i64** %9
%32 = load i64*, i64** %9
%33 = load i64*, i64** %6
%34 = load i32, i32* %8
%35 = call i32 @mulArray(i64* %31, i64* %32, i64* %33, i32 %34)
%36 = load i64*, i64** %5
%37 = load i64*, i64** %6
%38 = load i64*, i64** %6
%39 = load i32, i32* %8
%40 = call i32 @mulArray(i64* %36, i64* %37, i64* %38, i32 %39)
br label %41
41: ; preds = %30, %24
br label %42
42: ; preds = %41, %12
%43 = load i64*, i64** %6
ret i64* %43
}

LLVM IR (-O2):
define i64* @mypow(i64* %0, i64* %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %2, 1
br i1 %5, label %14, label %6
6: ; preds = %4
%7 = sdiv i32 %2, 2
%8 = tail call i64* @mypow(i64* %0, i64* %1, i32 %7, i32 %3)
%9 = and i32 %2, 1
%10 = icmp eq i32 %9, 0
%11 = tail call i32 @mulArray(i64* %8, i64* %8, i64* %1, i32 %3)
br i1 %10, label %14, label %12
12: ; preds = %6
%13 = tail call i32 @mulArray(i64* %0, i64* %1, i64* %1, i32 %3)
br label %14
14: ; preds = %6, %4, %12
%15 = phi i64* [ %1, %12 ], [ %0, %4 ], [ %1, %6 ]
ret i64* %15
}