#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 iterative_power(int, int);
int /*<<< orphan*/ printf(char *, int, double, double);
double recursive_power(int, int);
int main() {
  int i;
  for (i = -5; i < 10; ++i)
    if (i % 2 == 0)
      printf("%d: 2^x= %.2f   -3^x= %.2f\n", i, recursive_power(2, i),
             recursive_power(-3, i));
    else
      printf("%d: 2^x= %.2f   -3^x= %.2f\n", i, iterative_power(2, i),
             iterative_power(-3, i));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xfffffffb,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11f4 <main+0xc4>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a5 <main+0x75>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    $0x2,%edi
call   1040 <recursive_power@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    $0xfffffffd,%edi
call   1040 <recursive_power@plt>
mov    -0x14(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
jmp    11e1 <main+0xb1>
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%esi
mov    $0x2,%edi
call   1050 <iterative_power@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%esi
mov    $0xfffffffd,%edi
call   1050 <iterative_power@plt>
mov    -0x24(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
jmp    11e6 <main+0xb6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xfffffffb,%ebx
lea    0xec0(%rip),%r14
jmp    1180 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1050 <iterative_power@plt>
movsd  %xmm0,(%rsp)
mov    $0xfffffffd,%edi
mov    %ebx,%esi
call   1050 <iterative_power@plt>
movaps %xmm0,%xmm1
mov    %r14,%rdi
mov    %ebx,%esi
movsd  (%rsp),%xmm0
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    $0xa,%ebx
je     11a4 <main+0x74>
mov    $0x2,%edi
mov    %ebx,%esi
test   $0x1,%bl
jne    1150 <main+0x20>
call   1040 <recursive_power@plt>
movsd  %xmm0,(%rsp)
mov    $0xfffffffd,%edi
mov    %ebx,%esi
call   1040 <recursive_power@plt>
jmp    1166 <main+0x36>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [28 x i8] c"%d: 2^x= %.2f -3^x= %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 -5, i32* %2
br label %3
3: ; preds = %25, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 10
br i1 %5, label %6, label %28
6: ; preds = %3
%7 = load i32, i32* %2
%8 = srem i32 %7, 2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %6
%11 = load i32, i32* %2
%12 = load i32, i32* %2
%13 = call double @recursive_power(i32 2, i32 %12)
%14 = load i32, i32* %2
%15 = call double @recursive_power(i32 -3, i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %11, double %13, double %15)
br label %24
17: ; preds = %6
%18 = load i32, i32* %2
%19 = load i32, i32* %2
%20 = call double @iterative_power(i32 2, i32 %19)
%21 = load i32, i32* %2
%22 = call double @iterative_power(i32 -3, i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %18, double %20, double %22)
br label %24
24: ; preds = %17, %10
br label %25
25: ; preds = %24
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %3
28: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"%d: 2^x= %.2f -3^x= %.2f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %13
%2 = phi i32 [ -5, %0 ], [ %14, %13 ]
%3 = and i32 %2, 1
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call double @recursive_power(i32 2, i32 %2)
%7 = tail call double @recursive_power(i32 -3, i32 %2)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %2, double %6, double %7)
br label %13
9: ; preds = %1
%10 = tail call double @iterative_power(i32 2, i32 %2)
%11 = tail call double @iterative_power(i32 -3, i32 %2)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %2, double %10, double %11)
br label %13
13: ; preds = %5, %9
%14 = add nsw i32 %2, 1
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %1
16: ; preds = %13
ret i32 0
}