#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 int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ multiply(int /*<<< orphan*/ **, int /*<<< orphan*/ **);
void power(mpz_t F[2][2], int n) {
  if (n == 0 || n == 1) {
    return;
  }
  mpz_t M[2][2];
  mpz_init_set_ui(M[0][0], 1);
  mpz_init_set_ui(M[0][1], 1);
  mpz_init_set_ui(M[1][0], 1);
  mpz_init_set_ui(M[1][1], 0);
  power(F, n / 2);
  multiply(F, F);
  if (n % 2 != 0) {
    multiply(F, M);
  }
  mpz_clear(M[0][0]);
  mpz_clear(M[0][1]);
  mpz_clear(M[1][0]);
  mpz_clear(M[1][1]);
}


x86 assembly (clang, -O0):
<power>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1163 <power+0x23>
cmpl   $0x1,-0xc(%rbp)
jne    1168 <power+0x28>
jmp    11fd <power+0xbd>
mov    -0x20(%rbp),%edi
mov    $0x1,%esi
call   1050 <mpz_init_set_ui@plt>
mov    -0x1c(%rbp),%edi
mov    $0x1,%esi
call   1050 <mpz_init_set_ui@plt>
mov    -0x18(%rbp),%edi
mov    $0x1,%esi
call   1050 <mpz_init_set_ui@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <mpz_init_set_ui@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1030 <power@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <multiply@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11dd <power+0x9d>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <multiply@plt>
mov    -0x20(%rbp),%edi
call   1060 <mpz_clear@plt>
mov    -0x1c(%rbp),%edi
call   1060 <mpz_clear@plt>
mov    -0x18(%rbp),%edi
call   1060 <mpz_clear@plt>
mov    -0x14(%rbp),%edi
call   1060 <mpz_clear@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<power>:
cmp    $0x2,%esi
jb     11c9 <power+0x89>
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0x1,%esi
call   1050 <mpz_init_set_ui@plt>
mov    $0x1,%esi
call   1050 <mpz_init_set_ui@plt>
mov    $0x1,%esi
call   1050 <mpz_init_set_ui@plt>
xor    %esi,%esi
call   1050 <mpz_init_set_ui@plt>
mov    %ebp,%esi
shr    $0x1f,%esi
add    %ebp,%esi
sar    %esi
mov    %rbx,%rdi
call   1030 <power@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1040 <multiply@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <multiply@plt>
mov    (%rsp),%edi
call   1060 <mpz_clear@plt>
mov    0x4(%rsp),%edi
call   1060 <mpz_clear@plt>
mov    0x8(%rsp),%edi
call   1060 <mpz_clear@plt>
mov    0xc(%rsp),%edi
call   1060 <mpz_clear@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @power([2 x i32]* %0, i32 %1) {
%3 = alloca [2 x i32]*
%4 = alloca i32
%5 = alloca [2 x [2 x i32]]
store [2 x i32]* %0, [2 x i32]** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %8, %2
br label %63
12: ; preds = %8
%13 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %5, i64 0, i64 0
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%15 = load i32, i32* %14
%16 = call i32 @mpz_init_set_ui(i32 %15, i32 1)
%17 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %5, i64 0, i64 0
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 1
%19 = load i32, i32* %18
%20 = call i32 @mpz_init_set_ui(i32 %19, i32 1)
%21 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %5, i64 0, i64 1
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %21, i64 0, i64 0
%23 = load i32, i32* %22
%24 = call i32 @mpz_init_set_ui(i32 %23, i32 1)
%25 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %5, i64 0, i64 1
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %25, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32 @mpz_init_set_ui(i32 %27, i32 0)
%29 = load [2 x i32]*, [2 x i32]** %3
%30 = load i32, i32* %4
%31 = sdiv i32 %30, 2
%32 = load [2 x i32]*, [2 x i32]** %3
%33 = bitcast [2 x i32]* %32 to i32**
%34 = load [2 x i32]*, [2 x i32]** %3
%35 = bitcast [2 x i32]* %34 to i32**
%36 = call i32 @multiply(i32** %33, i32** %35)
%37 = load i32, i32* %4
%38 = srem i32 %37, 2
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %12
%41 = load [2 x i32]*, [2 x i32]** %3
%42 = bitcast [2 x i32]* %41 to i32**
%43 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %5, i64 0, i64 0
%44 = bitcast [2 x i32]* %43 to i32**
%45 = call i32 @multiply(i32** %42, i32** %44)
br label %46
46: ; preds = %40, %12
%47 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %5, i64 0, i64 0
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %47, i64 0, i64 0
%49 = load i32, i32* %48
%50 = call i32 @mpz_clear(i32 %49)
%51 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %5, i64 0, i64 0
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %51, i64 0, i64 1
%53 = load i32, i32* %52
%54 = call i32 @mpz_clear(i32 %53)
%55 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %5, i64 0, i64 1
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %55, i64 0, i64 0
%57 = load i32, i32* %56
%58 = call i32 @mpz_clear(i32 %57)
%59 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %5, i64 0, i64 1
%60 = getelementptr inbounds [2 x i32], [2 x i32]* %59, i64 0, i64 1
%61 = load i32, i32* %60
%62 = call i32 @mpz_clear(i32 %61)
br label %63
63: ; preds = %46, %11
ret void
}

LLVM IR (-O2):
define void @power([2 x i32]* %0, i32 %1) {
%3 = alloca [2 x [2 x i32]]
%4 = icmp ult i32 %1, 2
br i1 %4, label %30, label %5
5: ; preds = %2
%6 = bitcast [2 x [2 x i32]]* %3 to i8*
%7 = tail call i32 @mpz_init_set_ui(i32 undef, i32 1)
%8 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %3, i64 0, i64 0, i64 1
%9 = tail call i32 @mpz_init_set_ui(i32 undef, i32 1)
%10 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %3, i64 0, i64 1, i64 0
%11 = tail call i32 @mpz_init_set_ui(i32 undef, i32 1)
%12 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %3, i64 0, i64 1, i64 1
%13 = tail call i32 @mpz_init_set_ui(i32 undef, i32 0)
%14 = sdiv i32 %1, 2
tail call void @power([2 x i32]* %0, i32 %14)
%15 = bitcast [2 x i32]* %0 to i32**
%16 = tail call i32 @multiply(i32** %15, i32** %15)
%17 = and i32 %1, 1
%18 = icmp ne i32 %17, 0
%19 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %3, i64 0, i64 0, i64 0
%20 = bitcast [2 x [2 x i32]]* %3 to i32**
%21 = call i32 @multiply(i32** %15, i32** %20)
%22 = load i32, i32* %19
%23 = call i32 @mpz_clear(i32 %22)
%24 = load i32, i32* %8
%25 = call i32 @mpz_clear(i32 %24)
%26 = load i32, i32* %10
%27 = call i32 @mpz_clear(i32 %26)
%28 = load i32, i32* %12
%29 = call i32 @mpz_clear(i32 %28)
br label %30
30: ; preds = %2, %5
ret void
}