#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(int argc, char const *argv[]) {
  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("%1f%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    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee4(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    11cd <main+0x9d>
movsd  -0x18(%rbp),%xmm0
mov    -0x24(%rbp),%edi
call   1030 <power@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x24(%rbp),%esi
movsd  -0x20(%rbp),%xmm1
lea    0xeae(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1170 <main+0x40>
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%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    0xf56(%rip),%rdi
call   1040 <puts@plt>
lea    0xedf(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    11f1 <main+0xb1>
lea    0xeca(%rip),%r14
lea    0xf09(%rip),%r15
lea    0xeb6(%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    0xe87(%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 = [45 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 = [6 x i8] c"%1f%d\00"
@.str.4 = [30 x i8] c"%.3g to the power %d is %.5g\0A\00"
@.str.5 = [42 x i8] c"Enter next pair of numbers or q to quit.\0A\00"
@.str.6 = [41 x i8] c"Hope you enjoyed this power trip --bye!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %15, %2
%13 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double* %6, i32* %8)
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load double, double* %6
%17 = load i32, i32* %8
%18 = call double @power(double %16, i32 %17)
store double %18, double* %7
%19 = load double, double* %6
%20 = load i32, i32* %8
%21 = load double, double* %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), double %19, i32 %20, double %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
br label %12
24: ; preds = %12
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 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 = [45 x i8] c" to which\0Athe number will be raised. Enter q\00"
@.str.3 = [6 x i8] c"%1f%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 = [40 x i8] c"Hope you enjoyed this power trip --bye!\00"
@str.8 = [41 x i8] c"Enter next pair of numbers or q to quit.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca double
%4 = alloca i32
%5 = bitcast double* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double* %3, i32* %4)
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %22
12: ; preds = %2, %12
%13 = load double, double* %3
%14 = load i32, i32* %4
%15 = call double @power(double %13, i32 %14)
%16 = load double, double* %3
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), double %16, i32 %17, double %15)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.8, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double* %3, i32* %4)
%21 = icmp eq i32 %20, 2
br i1 %21, label %12, label %22
22: ; preds = %12, %2
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}