#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 power(double, int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *, int *);
int main() {
  double x, xpow;
  int exp;
  printf("Enter a number and the positive integer power");
  printf(" to which \nthe number will be raised. Enter q");
  printf(" to quit.\n");
  while (scanf("%lf %d", &x, &exp) == 2) {
    xpow = power(x, exp);
    printf("%.3g to the power %d is %.5g\n", x, exp, xpow);
    printf("Enter next pair of numbers or q to quit. \n");
  }
  printf("Hope you enjoyed this power trip -- bye!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef7(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    11c6 <main+0x96>
movsd  -0x10(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
call   1030 <power@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x1c(%rbp),%esi
movsd  -0x18(%rbp),%xmm1
lea    0xec2(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1169 <main+0x39>
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf11(%rip),%rdi
call   1040 <puts@plt>
lea    0xee0(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    11f1 <main+0xb1>
lea    0xecc(%rip),%r14
lea    0xf16(%rip),%r15
lea    0xeb7(%rip),%r12
lea    0x8(%rsp),%r13
lea    0x4(%rsp),%rbx
nop
movsd  0x8(%rsp),%xmm0
mov    0x4(%rsp),%edi
call   1030 <power@plt>
movaps %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mov    0x4(%rsp),%esi
mov    %r14,%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
je     11b0 <main+0x70>
lea    0xe93(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Enter a number and the positive integer power\00"
@.str.1 = [46 x i8] c" to which \0Athe number will be raised. Enter q\00"
@.str.2 = [11 x i8] c" to quit.\0A\00"
@.str.3 = [7 x i8] c"%lf %d\00"
@.str.4 = [30 x i8] c"%.3g to the power %d is %.5g\0A\00"
@.str.5 = [43 x i8] c"Enter next pair of numbers or q to quit. \0A\00"
@.str.6 = [42 x i8] c"Hope you enjoyed this power trip -- bye!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %11, %0
%9 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double* %2, i32* %4)
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load double, double* %2
%13 = load i32, i32* %4
%14 = call double @power(double %12, i32 %13)
store double %14, double* %3
%15 = load double, double* %2
%16 = load i32, i32* %4
%17 = load double, double* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), double %15, i32 %16, double %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %8
20: ; preds = %8
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"Enter a number and the positive integer power\00"
@.str.1 = [46 x i8] c" to which \0Athe number will be raised. Enter q\00"
@.str.3 = [7 x i8] c"%lf %d\00"
@.str.4 = [30 x i8] c"%.3g to the power %d is %.5g\0A\00"
@str = [10 x i8] c" to quit.\00"
@str.7 = [41 x i8] c"Hope you enjoyed this power trip -- bye!\00"
@str.8 = [42 x i8] c"Enter next pair of numbers or q to quit. \00"
define i32 @main() {
%1 = alloca double
%2 = alloca i32
%3 = bitcast double* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double* %1, i32* %2)
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %20
10: ; preds = %0, %10
%11 = load double, double* %1
%12 = load i32, i32* %2
%13 = call double @power(double %11, i32 %12)
%14 = load double, double* %1
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), double %14, i32 %15, double %13)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.8, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double* %1, i32* %2)
%19 = icmp eq i32 %18, 2
br i1 %19, label %10, label %20
20: ; preds = %10, %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}