#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 */
char getchar();
int my_power(float, int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, float *, int *);
int main(void) {
  float num;
  int pow;
  printf("Pls input the base and power number(e.g. 3.14, 2):");
  while (scanf("%f,%d", &num, &pow) != 2 || getchar() != '\n') {
    while (getchar() != '\n')
      ;
    printf("input invalid!\n");
    printf("Pls input the base and power number(e.g. 3.14, 2):");
  }
  if (num > -1e-38 && num < 1e-38) {
    if (pow == 0)
      printf("forbiden!\n");
    else
      printf("answer: 0\n");
  } else {
    if (pow > 0)
      printf("answer: %.6f\n", my_power(num, pow));
    else if (pow == 0)
      printf("answer: 1\n");
    else {
      pow *= -1;
      printf("answer: %.6f\n", 1 / my_power(num, pow));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x2,%ecx
mov    %al,-0xd(%rbp)
jne    1194 <main+0x54>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11a4 <main+0x64>
jmp    11e2 <main+0xa2>
jmp    11a9 <main+0x69>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11c1 <main+0x81>
jmp    11a9 <main+0x69>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115d <main+0x1d>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe0d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1248 <main+0x108>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdfa(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1248 <main+0x108>
cmpl   $0x0,-0xc(%rbp)
jne    1235 <main+0xf5>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1243 <main+0x103>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c9 <main+0x189>
cmpl   $0x0,-0xc(%rbp)
jle    1274 <main+0x134>
movss  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1060 <my_power@plt>
mov    %eax,%esi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c4 <main+0x184>
cmpl   $0x0,-0xc(%rbp)
jne    1291 <main+0x151>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12bf <main+0x17f>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1060 <my_power@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c4 <main+0x184>
jmp    12c9 <main+0x189>
xor    %eax,%eax
add    $0x10,%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),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xece(%rip),%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%rbx
lea    0xeef(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    11b0 <main+0x60>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11cf <main+0x7f>
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11b0 <main+0x60>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1190 <main+0x40>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm1
ucomisd 0xe1f(%rip),%xmm1
mov    0x8(%rsp),%edi
jbe    1207 <main+0xb7>
movsd  0xe19(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    1207 <main+0xb7>
test   %edi,%edi
je     121b <main+0xcb>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
jmp    1251 <main+0x101>
test   %edi,%edi
jle    1229 <main+0xd9>
call   1070 <my_power@plt>
lea    0xe32(%rip),%rdi
mov    %eax,%esi
jmp    124a <main+0xfa>
lea    0xe49(%rip),%rdi
call   1030 <puts@plt>
jmp    1251 <main+0x101>
je     1261 <main+0x111>
neg    %edi
mov    %edi,0x8(%rsp)
call   1070 <my_power@plt>
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x3,%ecx
cmovae %edx,%eax
lea    0xe01(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xdef(%rip),%rdi
call   1030 <puts@plt>
jmp    1251 <main+0x101>

LLVM IR (-O0):
@.str = [51 x i8] c"Pls input the base and power number(e.g. 3.14, 2):\00"
@.str.1 = [6 x i8] c"%f,%d\00"
@.str.2 = [16 x i8] c"input invalid!\0A\00"
@.str.3 = [11 x i8] c"forbiden!\0A\00"
@.str.4 = [11 x i8] c"answer: 0\0A\00"
@.str.5 = [14 x i8] c"answer: %.6f\0A\00"
@.str.6 = [11 x i8] c"answer: 1\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %20, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %2, i32* %3)
%7 = icmp ne i32 %6, 2
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = call signext i8 (...) @getchar()
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br label %12
12: ; preds = %8, %5
%13 = phi i1 [ true, %5 ], [ %11, %8 ]
br i1 %13, label %14, label %23
14: ; preds = %12
br label %15
15: ; preds = %19, %14
%16 = call signext i8 (...) @getchar()
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 10
br i1 %18, label %19, label %20
19: ; preds = %15
br label %15
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %5
23: ; preds = %12
%24 = load float, float* %2
%25 = fpext float %24 to double
%26 = fcmp ogt double %25, 0xB80B38FB9DAA78E4
br i1 %26, label %27, label %39
27: ; preds = %23
%28 = load float, float* %2
%29 = fpext float %28 to double
%30 = fcmp olt double %29, 0x380B38FB9DAA78E4
br i1 %30, label %31, label %39
31: ; preds = %27
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %38
36: ; preds = %31
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %38
38: ; preds = %36, %34
br label %62
39: ; preds = %27, %23
%40 = load i32, i32* %3
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %39
%43 = load float, float* %2
%44 = load i32, i32* %3
%45 = call i32 @my_power(float %43, i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %45)
br label %61
47: ; preds = %39
%48 = load i32, i32* %3
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %60
52: ; preds = %47
%53 = load i32, i32* %3
%54 = mul nsw i32 %53, -1
store i32 %54, i32* %3
%55 = load float, float* %2
%56 = load i32, i32* %3
%57 = call i32 @my_power(float %55, i32 %56)
%58 = sdiv i32 1, %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %52, %50
br label %61
61: ; preds = %60, %42
br label %62
62: ; preds = %61, %38
ret i32 0
}

LLVM IR (-O2):
@.str = [51 x i8] c"Pls input the base and power number(e.g. 3.14, 2):\00"
@.str.1 = [6 x i8] c"%f,%d\00"
@.str.5 = [14 x i8] c"answer: %.6f\0A\00"
@str = [10 x i8] c"answer: 1\00"
@str.7 = [10 x i8] c"answer: 0\00"
@str.8 = [10 x i8] c"forbiden!\00"
@str.9 = [15 x i8] c"input invalid!\00"
define i32 @main() {
%1 = alloca float
%2 = alloca i32
%3 = bitcast float* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %16, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %1, i32* %2)
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = call signext i8 (...) @getchar()
%11 = icmp eq i8 %10, 10
br i1 %11, label %19, label %12
12: ; preds = %6, %9
br label %13
13: ; preds = %12, %13
%14 = call signext i8 (...) @getchar()
%15 = icmp eq i8 %14, 10
br i1 %15, label %16, label %13
16: ; preds = %13
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.9, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %6
19: ; preds = %9
%20 = load float, float* %1
%21 = fpext float %20 to double
%22 = fcmp ogt double %21, 0xB80B38FB9DAA78E4
%23 = fcmp olt double %21, 0x380B38FB9DAA78E4
%24 = and i1 %22, %23
%25 = load i32, i32* %2
br i1 %24, label %26, label %32
26: ; preds = %19
%27 = icmp eq i32 %25, 0
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.8, i64 0, i64 0))
br label %48
30: ; preds = %26
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.7, i64 0, i64 0))
br label %48
32: ; preds = %19
%33 = icmp sgt i32 %25, 0
br i1 %33, label %34, label %37
34: ; preds = %32
%35 = call i32 @my_power(float %20, i32 %25)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %35)
br label %48
37: ; preds = %32
%38 = icmp eq i32 %25, 0
br i1 %38, label %39, label %41
39: ; preds = %37
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %48
41: ; preds = %37
%42 = sub nsw i32 0, %25
store i32 %42, i32* %2
%43 = call i32 @my_power(float %20, i32 %42)
%44 = add i32 %43, 1
%45 = icmp ult i32 %44, 3
%46 = select i1 %45, i32 %43, i32 0
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %34, %41, %39, %28, %30
ret i32 0
}