#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 HUGE_VAL;
double pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int sqrt(int);
int main() {
  int i = 4;
  int rooted = sqrt(i);
  printf("%.2f\n", pow(i, 3));
  printf("%.2f\n", pow(i, .5));
  printf("%.2f\n", rooted);
  double ans = pow(i, 1000);
  if (ans == HUGE_VAL) {
    printf("The value calculated was too large to fit in a double.\n");
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x3,%esi
call   1040 <pow@plt>
lea    0xe9b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1040 <pow@plt>
lea    0xe83(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0x3e8,%esi
call   1040 <pow@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    0x2e35(%rip),%rax
ucomisd (%rax),%xmm0
jne    11dd <main+0xad>
jp     11dd <main+0xad>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e4 <main+0xb4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x4,%edi
call   1060 <sqrt@plt>
mov    %eax,%ebp
mov    $0x4,%edi
mov    $0x3,%esi
call   1050 <pow@plt>
lea    0xe9b(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1050 <pow@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x4,%edi
mov    $0x3e8,%esi
call   1050 <pow@plt>
mov    0x2e41(%rip),%rax
ucomisd (%rax),%xmm0
jne    11bb <main+0x7b>
jp     11bb <main+0x7b>
lea    0xe50(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%.2f\0A\00"
@HUGE_VAL = global double 0.000000e+00
@.str.1 = [56 x i8] c"The value calculated was too large to fit in a double.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
store i32 0, i32* %1
store i32 4, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @sqrt(i32 %5)
store i32 %6, i32* %3
%7 = load i32, i32* %2
%8 = call double @pow(i32 %7, i32 3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %8)
%10 = load i32, i32* %2
%11 = call double @pow(i32 %10, i32 0)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %11)
%13 = load i32, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %2
%16 = call double @pow(i32 %15, i32 1000)
store double %16, double* %4
%17 = load double, double* %4
%18 = load double, double* @HUGE_VAL
%19 = fcmp oeq double %17, %18
br i1 %19, label %20, label %22
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %23
22: ; preds = %0
store i32 0, i32* %1
br label %23
23: ; preds = %22, %20
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@.str = [6 x i8] c"%.2f\0A\00"
@HUGE_VAL = global double 0.000000e+00
@str = [55 x i8] c"The value calculated was too large to fit in a double.\00"
define i32 @main() {
%1 = tail call i32 @sqrt(i32 4)
%2 = tail call double @pow(i32 4, i32 3)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %2)
%4 = tail call double @pow(i32 4, i32 0)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %1)
%7 = tail call double @pow(i32 4, i32 1000)
%8 = load double, double* @HUGE_VAL
%9 = fcmp oeq double %7, %8
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %0, %10
ret i32 0
}