#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ my_putstr2(char *);
int power(int nb, int pow) {
  int a;
  a = nb;
  if (pow == 0)
    nb = 1;
  while (pow-- > 1) {
    nb = nb * a;
    if (nb > 2147483647 || nb < -2147483647) {
      my_putstr2("The size of the power your number is too");
      my_putstr2("high to be store in an int\n");
      exit(-1);
    }
  }
  if (pow < 0) {
    my_putstr2("The type int can't manage the negative power\n");
    exit(-1);
  }
  return (nb);
}


x86 assembly (clang, -O0):
<power>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1145 <power+0x25>
movl   $0x1,-0x4(%rbp)
jmp    114a <power+0x2a>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x1,%eax
jle    11a9 <power+0x89>
mov    -0x4(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x7fffffff,-0x4(%rbp)
jg     1182 <power+0x62>
cmpl   $0x80000001,-0x4(%rbp)
jge    11a4 <power+0x84>
lea    0xe77(%rip),%rdi
call   1030 <my_putstr2@plt>
lea    0xe94(%rip),%rdi
call   1030 <my_putstr2@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
jmp    114a <power+0x2a>
cmpl   $0x0,-0x8(%rbp)
jge    11c9 <power+0xa9>
lea    0xe8b(%rip),%rdi
call   1030 <my_putstr2@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<power>:
push   %rax
test   %esi,%esi
mov    $0x1,%eax
cmovne %edi,%eax
lea    0x1(%rsi),%ecx
xchg   %ax,%ax
add    $0xffffffff,%ecx
cmp    $0x2,%ecx
jl     1164 <power+0x44>
imul   %edi,%eax
cmp    $0x80000000,%eax
jne    1130 <power+0x10>
lea    0xeb7(%rip),%rdi
call   1030 <my_putstr2@plt>
lea    0xed4(%rip),%rdi
call   1030 <my_putstr2@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
test   %esi,%esi
jle    116a <power+0x4a>
pop    %rcx
ret
lea    0xed4(%rip),%rdi
jmp    1155 <power+0x35>

LLVM IR (-O0):
@.str = [41 x i8] c"The size of the power your number is too\00"
@.str.1 = [28 x i8] c"high to be store in an int\0A\00"
@.str.2 = [46 x i8] c"The type int can't manage the negative power\0A\00"
define i32 @power(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
store i32 %6, i32* %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 1, i32* %3
br label %10
10: ; preds = %9, %2
br label %11
11: ; preds = %28, %10
%12 = load i32, i32* %4
%13 = add nsw i32 %12, -1
store i32 %13, i32* %4
%14 = icmp sgt i32 %12, 1
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load i32, i32* %3
%17 = load i32, i32* %5
%18 = mul nsw i32 %16, %17
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = icmp sgt i32 %19, 2147483647
br i1 %20, label %24, label %21
21: ; preds = %15
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, -2147483647
br i1 %23, label %24, label %28
24: ; preds = %21, %15
%25 = call i32 @my_putstr2(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @my_putstr2(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @exit(i32 -1)
unreachable
28: ; preds = %21
br label %11
29: ; preds = %11
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = call i32 @my_putstr2(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %29
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [41 x i8] c"The size of the power your number is too\00"
@.str.1 = [28 x i8] c"high to be store in an int\0A\00"
@.str.2 = [46 x i8] c"The type int can't manage the negative power\0A\00"
define i32 @power(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
%4 = select i1 %3, i32 1, i32 %0
br label %5
5: ; preds = %9, %2
%6 = phi i32 [ %1, %2 ], [ %10, %9 ]
%7 = phi i32 [ %4, %2 ], [ %11, %9 ]
%8 = icmp sgt i32 %6, 1
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = add nsw i32 %6, -1
%11 = mul nsw i32 %7, %0
%12 = icmp eq i32 %11, -2147483648
br i1 %12, label %13, label %5
13: ; preds = %9
%14 = tail call i32 @my_putstr2(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @my_putstr2(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @exit(i32 -1)
unreachable
17: ; preds = %5
%18 = icmp sgt i32 %1, 0
br i1 %18, label %22, label %19
19: ; preds = %17
%20 = tail call i32 @my_putstr2(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @exit(i32 -1)
unreachable
22: ; preds = %17
ret i32 %7
}