#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 EOF;
int getchar();
int /*<<< orphan*/ power(double, int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *, int *);
int main() {
  printf("Enter base and power as 'base ** power':\n");
  while (1) {
    double base;
    int exp;
    printf("> ");
    int items_scanned = scanf(" %lf ** %d", &base, &exp);
    if (items_scanned == EOF) {
      break;
    }
    if (items_scanned != 2) {
      printf("Invalid input or something went wrong.\n");
      int c;
      while ((c = getchar()) != '\n' && c != EOF)
        ;
      continue;
    }
    printf("%lf ** %d = %lf\n", base, exp, power(base, exp));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <scanf@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e5c(%rip),%rcx
cmp    (%rcx),%eax
jne    1199 <main+0x59>
jmp    1231 <main+0xf1>
cmpl   $0x2,-0x18(%rbp)
je     11f7 <main+0xb7>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1d(%rbp)
je     11dd <main+0x9d>
mov    -0x1c(%rbp),%eax
mov    0x2e13(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11ed <main+0xad>
jmp    11f2 <main+0xb2>
jmp    11b1 <main+0x71>
jmp    115d <main+0x1d>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1030 <power@plt>
movsd  -0x30(%rbp),%xmm0
mov    -0x24(%rbp),%esi
mov    %eax,%edx
lea    0xe3b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    115d <main+0x1d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeba(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe84(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1070 <scanf@plt>
mov    0x2e53(%rip),%rbp
cmp    0x0(%rbp),%eax
jne    11ab <main+0x5b>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe4e(%rip),%r15
lea    0xe4a(%rip),%r12
lea    0x8(%rsp),%r13
lea    0x4(%rsp),%rbx
jmp    1223 <main+0xd3>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x4(%rsp),%r14d
mov    %r14d,%edi
call   1030 <power@plt>
lea    0xe1e(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    %r14d,%esi
mov    %eax,%edx
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <scanf@plt>
cmp    0x0(%rbp),%eax
je     119a <main+0x4a>
cmp    $0x2,%eax
je     11d0 <main+0x80>
lea    0xe19(%rip),%rdi
call   1040 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%eax
je     1202 <main+0xb2>
cmp    0x0(%rbp),%eax
jne    1240 <main+0xf0>
jmp    1202 <main+0xb2>

LLVM IR (-O0):
@.str = [42 x i8] c"Enter base and power as 'base ** power':\0A\00"
@.str.1 = [3 x i8] c"> \00"
@.str.2 = [11 x i8] c" %lf ** %d\00"
@EOF = global i32 0
@.str.3 = [40 x i8] c"Invalid input or something went wrong.\0A\00"
@.str.4 = [17 x i8] c"%lf ** %d = %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %0, %29, %30
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double* %2, i32* %3)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %7
br label %37
14: ; preds = %7
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %30
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %28, %17
%20 = call i32 (...) @getchar()
store i32 %20, i32* %5
%21 = icmp ne i32 %20, 10
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* %5
%24 = load i32, i32* @EOF
%25 = icmp ne i32 %23, %24
br label %26
26: ; preds = %22, %19
%27 = phi i1 [ false, %19 ], [ %25, %22 ]
br i1 %27, label %28, label %29
28: ; preds = %26
br label %19
29: ; preds = %26
br label %7
30: ; preds = %14
%31 = load double, double* %2
%32 = load i32, i32* %3
%33 = load double, double* %2
%34 = load i32, i32* %3
%35 = call i32 @power(double %33, i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %31, i32 %32, i32 %35)
br label %7
37: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"> \00"
@.str.2 = [11 x i8] c" %lf ** %d\00"
@EOF = global i32 0
@.str.4 = [17 x i8] c"%lf ** %d = %lf\0A\00"
@str = [41 x i8] c"Enter base and power as 'base ** power':\00"
@str.5 = [39 x i8] c"Invalid input or something went wrong.\00"
define i32 @main() {
%1 = alloca double
%2 = alloca i32
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%4 = bitcast double* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double* %1, i32* %2)
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %31, label %10
10: ; preds = %0, %26
%11 = phi i32 [ %28, %26 ], [ %7, %0 ]
%12 = icmp eq i32 %11, 2
br i1 %12, label %21, label %13
13: ; preds = %10
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.5, i64 0, i64 0))
br label %15
15: ; preds = %15, %13
%16 = call i32 (...) @getchar()
%17 = icmp ne i32 %16, 10
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %16, %18
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %15, label %26
21: ; preds = %10
%22 = load double, double* %1
%23 = load i32, i32* %2
%24 = call i32 @power(double %22, i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %22, i32 %23, i32 %24)
br label %26
26: ; preds = %15, %21
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double* %1, i32* %2)
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %10
31: ; preds = %26, %0
ret i32 0
}