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


x86 assembly (clang, -O0):
<ipow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     113c <ipow+0x2c>
movsd  0xece(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1194 <ipow+0x84>
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <ipow@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1180 <ipow+0x70>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1194 <ipow+0x84>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipow>:
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
jle    1133 <ipow+0x23>
mov    %edi,%ebx
shr    %edi
movsd  %xmm0,0x8(%rsp)
call   1030 <ipow@plt>
test   $0x1,%bl
jne    113d <ipow+0x2d>
mulsd  %xmm0,%xmm0
jmp    114b <ipow+0x3b>
movsd  0xec5(%rip),%xmm0
jmp    114b <ipow+0x3b>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @ipow(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 sle i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store double 1.000000e+00, double* %3
br label %28
10: ; preds = %2
%11 = load double, double* %4
%12 = load i32, i32* %5
%13 = sdiv i32 %12, 2
%14 = call double @ipow(double %11, i32 %13)
store double %14, double* %6
%15 = load i32, i32* %5
%16 = srem i32 %15, 2
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %10
%19 = load double, double* %6
%20 = load double, double* %6
%21 = fmul double %19, %20
store double %21, double* %3
br label %28
22: ; preds = %10
%23 = load double, double* %4
%24 = load double, double* %6
%25 = fmul double %23, %24
%26 = load double, double* %6
%27 = fmul double %25, %26
store double %27, double* %3
br label %28
28: ; preds = %22, %18, %9
%29 = load double, double* %3
ret double %29
}

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