#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*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  unsigned int integerPower(int base, int esponente);
  int valoreSentinella = -1;
  int base;
  int esponente;
  unsigned int risultato;
  do {
    printf("%s",
           "Inserire la base numerica ( -1 come esponente per uscire ): ");
    scanf("%d", &base);
    printf("%s", "Inserire l'esponente ( -1 per uscire ): ");
    scanf("%u", &esponente);
    if (base > 0 && esponente >= 0) {
      risultato = integerPower(base, esponente);
      printf("Il numero %d elevato a %d e' pari a: %u\n", base, esponente,
             risultato);
    } else {
      if (base != valoreSentinella && esponente != valoreSentinella &&
          base < 0 && esponente < 0) {
        puts("Attenzione e' stato inserito un valore non valido.\n");
      }
    }
  } while (base != valoreSentinella && esponente != valoreSentinella);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
lea    0xea3(%rip),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe7e(%rip),%rdi
lea    0xeba(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    11de <main+0x9e>
cmpl   $0x0,-0x10(%rbp)
jl     11de <main+0x9e>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <integerPower@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    121b <main+0xdb>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     1216 <main+0xd6>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     1216 <main+0xd6>
cmpl   $0x0,-0xc(%rbp)
jge    1216 <main+0xd6>
cmpl   $0x0,-0x10(%rbp)
jge    1216 <main+0xd6>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
jmp    121b <main+0xdb>
jmp    1220 <main+0xe0>
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x15(%rbp)
je     123d <main+0xfd>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1156 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rbx
lea    0xee7(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xede(%rip),%r13
lea    0xf00(%rip),%rbp
mov    %rsp,%r14
nop
mov    %rbx,%rdi
lea    0xe89(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
test   %edi,%edi
jle    11e0 <main+0xa0>
test   %esi,%esi
js     11e0 <main+0xa0>
call   1040 <integerPower@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xea9(%rip),%rdi
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1200 <main+0xc0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0xffffffff,%edi
je     1200 <main+0xc0>
test   %esi,%esi
jns    1200 <main+0xc0>
cmp    $0xffffffff,%esi
je     1200 <main+0xc0>
test   %edi,%edi
jns    1200 <main+0xc0>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
xchg   %ax,%ax
cmpl   $0xffffffff,0x4(%rsp)
je     1211 <main+0xd1>
cmpl   $0xffffffff,(%rsp)
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [61 x i8] c"Inserire la base numerica ( -1 come esponente per uscire ): \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [41 x i8] c"Inserire l'esponente ( -1 per uscire ): \00"
@.str.4 = [3 x i8] c"%u\00"
@.str.5 = [41 x i8] c"Il numero %d elevato a %d e' pari a: %u\0A\00"
@.str.6 = [52 x i8] c"Attenzione e' stato inserito un valore non valido.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
br label %6
6: ; preds = %50, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %6
%14 = load i32, i32* %4
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = call i32 @integerPower(i32 %17, i32 %18)
store i32 %19, i32* %5
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 %20, i32 %21, i32 %22)
br label %41
24: ; preds = %13, %6
%25 = load i32, i32* %3
%26 = load i32, i32* %2
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %40
28: ; preds = %24
%29 = load i32, i32* %4
%30 = load i32, i32* %2
%31 = icmp ne i32 %29, %30
br i1 %31, label %32, label %40
32: ; preds = %28
%33 = load i32, i32* %3
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @puts(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0))
br label %40
40: ; preds = %38, %35, %32, %28, %24
br label %41
41: ; preds = %40, %16
br label %42
42: ; preds = %41
%43 = load i32, i32* %3
%44 = load i32, i32* %2
%45 = icmp ne i32 %43, %44
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load i32, i32* %4
%48 = load i32, i32* %2
%49 = icmp ne i32 %47, %48
br label %50
50: ; preds = %46, %42
%51 = phi i1 [ false, %42 ], [ %49, %46 ]
br i1 %51, label %6, label %52
52: ; preds = %50
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [61 x i8] c"Inserire la base numerica ( -1 come esponente per uscire ): \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [41 x i8] c"Inserire l'esponente ( -1 per uscire ): \00"
@.str.4 = [3 x i8] c"%u\00"
@.str.5 = [41 x i8] c"Il numero %d elevato a %d e' pari a: %u\0A\00"
@.str.6 = [52 x i8] c"Attenzione e' stato inserito un valore non valido.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %30, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, -1
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %20
15: ; preds = %5
%16 = call i32 @integerPower(i32 %10, i32 %12)
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 %17, i32 %18, i32 %16)
br label %30
20: ; preds = %5
%21 = icmp eq i32 %10, -1
br i1 %21, label %30, label %22
22: ; preds = %20
%23 = icmp ne i32 %12, -1
%24 = icmp slt i32 %10, 0
%25 = select i1 %23, i1 %24, i1 false
%26 = icmp slt i32 %12, 0
%27 = and i1 %26, %25
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0))
br label %30
30: ; preds = %15, %28, %22, %20
%31 = load i32, i32* %1
%32 = icmp ne i32 %31, -1
%33 = load i32, i32* %2
%34 = icmp ne i32 %33, -1
%35 = select i1 %32, i1 %34, i1 false
br i1 %35, label %5, label %36
36: ; preds = %30
ret i32 0
}