#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 myPow(double, int);
double do_pow(double x, int n) {
  if (n == 0)
    return (1.0);
  if (n == 1)
    return (x);
  if (n % 2)
    return (x * myPow(x, n - 1));
  double t = myPow(x, n / 2);
  return (t * t);
}


x86 assembly (clang, -O0):
<do_pow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    113c <do_pow+0x2c>
movsd  0xece(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c4 <do_pow+0xb4>
cmpl   $0x1,-0x14(%rbp)
jne    1155 <do_pow+0x45>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c4 <do_pow+0xb4>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1199 <do_pow+0x89>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
call   1030 <myPow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c4 <do_pow+0xb4>
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <myPow@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_pow>:
push   %rax
test   %edi,%edi
je     111c <do_pow+0xc>
cmp    $0x1,%edi
jne    1126 <do_pow+0x16>
pop    %rax
ret
movsd  0xedc(%rip),%xmm0
pop    %rax
ret
test   $0x1,%dil
jne    1142 <do_pow+0x32>
mov    %edi,%eax
shr    $0x1f,%eax
add    %edi,%eax
sar    %eax
mov    %eax,%edi
call   1030 <myPow@plt>
mulsd  %xmm0,%xmm0
pop    %rax
ret
add    $0xffffffff,%edi
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
call   1030 <myPow@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
define double @do_pow(double %0, i32 %1) {
switch i32 %1, label %4 [
i32 0, label %15
i32 1, label %3
]
3: ; preds = %2
br label %15
4: ; preds = %2
%5 = and i32 %1, 1
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = add nsw i32 %1, -1
%9 = tail call double @myPow(double %0, i32 %8)
%10 = fmul double %9, %0
br label %15
11: ; preds = %4
%12 = sdiv i32 %1, 2
%13 = tail call double @myPow(double %0, i32 %12)
%14 = fmul double %13, %13
br label %15
15: ; preds = %2, %11, %7, %3
%16 = phi double [ %0, %3 ], [ %10, %7 ], [ %14, %11 ], [ 1.000000e+00, %2 ]
ret double %16
}