#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 */
int /*<<< orphan*/ exponentation_by_squaring(long double, int);
int /*<<< orphan*/ printf(char *, long double, int, int /*<<< orphan*/);
int main() {
  long double base = 2;
  int power = 31;
  printf("%LG raised to %d is %LG\n", base, power,
         exponentation_by_squaring(base, power));
  base = 2;
  power = -2;
  printf("%LG raised to %d is %LG\n", base, power,
         exponentation_by_squaring(base, power));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
flds   0xecb(%rip)
fld    %st(0)
fstpt  -0x40(%rbp)
fstpt  -0x20(%rbp)
movl   $0x1f,-0x24(%rbp)
fldt   -0x20(%rbp)
fld    %st(0)
fstpt  -0x50(%rbp)
mov    -0x24(%rbp),%edi
mov    %edi,-0x44(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <exponentation_by_squaring@plt>
fldt   -0x50(%rbp)
mov    -0x44(%rbp),%esi
mov    %eax,%edx
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
fldt   -0x40(%rbp)
fstpt  -0x20(%rbp)
movl   $0xfffffffe,-0x24(%rbp)
fldt   -0x20(%rbp)
fld    %st(0)
fstpt  -0x34(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <exponentation_by_squaring@plt>
fldt   -0x34(%rbp)
mov    -0x28(%rbp),%esi
mov    %eax,%edx
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
flds   0xed5(%rip)
fld    %st(0)
fstpt  0x14(%rsp)
fstpt  (%rsp)
mov    $0x1f,%edi
call   1030 <exponentation_by_squaring@plt>
fldt   0x14(%rsp)
fstpt  (%rsp)
lea    0xeb8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1f,%esi
mov    %eax,%edx
call   1040 <printf@plt>
fldt   0x14(%rsp)
fstpt  (%rsp)
mov    $0xfffffffe,%edi
call   1030 <exponentation_by_squaring@plt>
fldt   0x14(%rsp)
fstpt  (%rsp)
mov    %rbx,%rdi
mov    $0xfffffffe,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"%LG raised to %d is %LG\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca x86_fp80
%3 = alloca i32
store i32 0, i32* %1
store x86_fp80 0xK40008000000000000000, x86_fp80* %2
store i32 31, i32* %3
%4 = load x86_fp80, x86_fp80* %2
%5 = load i32, i32* %3
%6 = load x86_fp80, x86_fp80* %2
%7 = load i32, i32* %3
%8 = call i32 @exponentation_by_squaring(x86_fp80 %6, i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), x86_fp80 %4, i32 %5, i32 %8)
store x86_fp80 0xK40008000000000000000, x86_fp80* %2
store i32 -2, i32* %3
%10 = load x86_fp80, x86_fp80* %2
%11 = load i32, i32* %3
%12 = load x86_fp80, x86_fp80* %2
%13 = load i32, i32* %3
%14 = call i32 @exponentation_by_squaring(x86_fp80 %12, i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), x86_fp80 %10, i32 %11, i32 %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"%LG raised to %d is %LG\0A\00"
define i32 @main() {
%1 = tail call i32 @exponentation_by_squaring(x86_fp80 0xK40008000000000000000, i32 31)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), x86_fp80 0xK40008000000000000000, i32 31, i32 %1)
%3 = tail call i32 @exponentation_by_squaring(x86_fp80 0xK40008000000000000000, i32 -2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), x86_fp80 0xK40008000000000000000, i32 -2, i32 %3)
ret i32 0
}