#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 */
double randlc(double *, double);
double power(double a, int n) {
  double aj;
  int nj;
  double rdummy;
  double power;
  power = 1.0;
  nj = n;
  aj = a;
  while (nj != 0) {
    if ((nj % 2) == 1)
      rdummy = randlc(&power, aj);
    rdummy = randlc(&aj, aj);
    nj = nj / 2;
  }
  return (power);
}


x86 assembly (clang, -O0):
<power>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movsd  0xed8(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1194 <power+0x84>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    116e <power+0x5e>
movsd  -0x18(%rbp),%xmm0
lea    -0x30(%rbp),%rdi
call   1030 <randlc@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    -0x18(%rbp),%rdi
call   1030 <randlc@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
jmp    113d <power+0x2d>
movsd  -0x30(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<power>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0x3ff0000000000000,%rax
mov    %rax,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
test   %edi,%edi
je     1195 <power+0x85>
mov    %edi,%ebx
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r15
mov    %edi,%ebp
jmp    116a <power+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
sar    %ebp
movsd  0x8(%rsp),%xmm0
mov    %r15,%rdi
call   1030 <randlc@plt>
add    $0x1,%ebx
cmp    $0x2,%ebx
mov    %ebp,%ebx
jbe    118d <power+0x7d>
shr    $0x1f,%ebp
add    %ebx,%ebp
mov    %ebp,%eax
and    $0xfffffffe,%eax
mov    %ebx,%ecx
sub    %eax,%ecx
cmp    $0x1,%ecx
jne    1150 <power+0x40>
movsd  0x8(%rsp),%xmm0
mov    %r14,%rdi
call   1030 <randlc@plt>
jmp    1150 <power+0x40>
movsd  0x10(%rsp),%xmm0
jmp    119d <power+0x8d>
movsd  0xe63(%rip),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @power(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
store double 1.000000e+00, double* %8
%9 = load i32, i32* %4
store i32 %9, i32* %6
%10 = load double, double* %3
store double %10, double* %5
br label %11
11: ; preds = %21, %2
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %11
%15 = load i32, i32* %6
%16 = srem i32 %15, 2
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load double, double* %5
%20 = call double @randlc(double* %8, double %19)
store double %20, double* %7
br label %21
21: ; preds = %18, %14
%22 = load double, double* %5
%23 = call double @randlc(double* %5, double %22)
store double %23, double* %7
%24 = load i32, i32* %6
%25 = sdiv i32 %24, 2
store i32 %25, i32* %6
br label %11
26: ; preds = %11
%27 = load double, double* %8
ret double %27
}

LLVM IR (-O2):
define double @power(double %0, i32 %1) {
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
store double 1.000000e+00, double* %4
store double %0, double* %3
%7 = icmp eq i32 %1, 0
br i1 %7, label %23, label %8
8: ; preds = %2, %16
%9 = phi i32 [ %11, %16 ], [ %1, %2 ]
%10 = srem i32 %9, 2
%11 = sdiv i32 %9, 2
%12 = icmp eq i32 %10, 1
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load double, double* %3
%15 = call double @randlc(double* %4, double %14)
br label %16
16: ; preds = %13, %8
%17 = load double, double* %3
%18 = call double @randlc(double* %3, double %17)
%19 = add i32 %9, 1
%20 = icmp ult i32 %19, 3
br i1 %20, label %21, label %8
21: ; preds = %16
%22 = load double, double* %4
br label %23
23: ; preds = %21, %2
%24 = phi double [ %22, %21 ], [ 1.000000e+00, %2 ]
ret double %24
}