#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 *, unsigned int);
int /*<<< orphan*/ puts(char *);
int scanf(char *, ...);
void load(int *memoryPtr, unsigned int operand) {
  int esitoScanf;
  char *inputInserito = "*** Program loading completed ***";
  do {
    do {
      printf("%02d ? ", operand);
      if ((esitoScanf = scanf("%d", &memoryPtr[operand])) == 0 ||
          ((memoryPtr[operand] < 1000) && memoryPtr[operand] != -99999 &&
           memoryPtr[operand] != 0) ||
          (memoryPtr[operand] > 9999)) {
        scanf("%*[^\n]");
        puts("Sono accettati solo interi positivi di 4 cifre.");
      } else if (memoryPtr[operand] == -99999) {
        puts(inputInserito);
        operand = 100;
      } else {
        operand++;
      }
    } while (esitoScanf == 0);
  } while (operand <= 99);
  return;
}


x86 assembly (clang, -O0):
<load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    114f <load+0x1f>
mov    -0xc(%rbp),%esi
lea    0xec9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%eax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
je     11d3 <load+0xa3>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
cmpl   $0x3e8,(%rax,%rcx,4)
jge    11bf <load+0x8f>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
cmpl   $0xfffe7961,(%rax,%rcx,4)
je     11bf <load+0x8f>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
cmpl   $0x0,(%rax,%rcx,4)
jne    11d3 <load+0xa3>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
cmpl   $0x270f,(%rax,%rcx,4)
jle    11f2 <load+0xc2>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
jmp    1229 <load+0xf9>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
cmpl   $0xfffe7961,(%rax,%rcx,4)
jne    121b <load+0xeb>
mov    -0x18(%rbp),%rdi
call   1030 <puts@plt>
movl   $0x64,-0xc(%rbp)
jmp    1224 <load+0xf4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1229 <load+0xf9>
jmp    122e <load+0xfe>
cmpl   $0x0,-0x10(%rbp)
je     114f <load+0x1f>
jmp    123d <load+0x10d>
cmpl   $0x63,-0xc(%rbp)
jbe    114a <load+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,(%rsp)
lea    0xeda(%rip),%r15
lea    0xedb(%rip),%r12
lea    0xed7(%rip),%r13
lea    0xed7(%rip),%rbp
jmp    1182 <load+0x52>
nop
test   %eax,%eax
je     11d1 <load+0xa1>
cmp    $0xfffe7961,%eax
je     11e8 <load+0xb8>
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
cmp    $0x64,%ebx
jae    11d9 <load+0xa9>
mov    %ebx,%eax
mov    (%rsp),%rcx
lea    (%rcx,%rax,4),%r14
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %eax,%eax
jne    11c0 <load+0x90>
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
jmp    1190 <load+0x60>
nop
mov    (%r14),%eax
cmp    $0x3e7,%eax
jle    1160 <load+0x30>
cmp    $0x270f,%eax
ja     116b <load+0x3b>
add    $0x1,%ebx
cmp    $0x64,%ebx
jb     1182 <load+0x52>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe11(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"*** Program loading completed ***\00"
@.str.1 = [8 x i8] c"%02d ? \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [7 x i8] c"%*[^\0A]\00"
@.str.4 = [48 x i8] c"Sono accettati solo interi positivi di 4 cifre.\00"
define void @load(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32* %0, i32** %3
store i32 %1, i32* %4
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8** %6
br label %7
7: ; preds = %67, %2
br label %8
8: ; preds = %63, %7
%9 = load i32, i32* %4
%10 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32*, i32** %3
%12 = load i32, i32* %4
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %14)
store i32 %15, i32* %5
%16 = icmp eq i32 %15, 0
br i1 %16, label %45, label %17
17: ; preds = %8
%18 = load i32*, i32** %3
%19 = load i32, i32* %4
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load i32, i32* %21
%23 = icmp slt i32 %22, 1000
br i1 %23, label %24, label %38
24: ; preds = %17
%25 = load i32*, i32** %3
%26 = load i32, i32* %4
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = icmp ne i32 %29, -99999
br i1 %30, label %31, label %38
31: ; preds = %24
%32 = load i32*, i32** %3
%33 = load i32, i32* %4
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = icmp ne i32 %36, 0
br i1 %37, label %45, label %38
38: ; preds = %31, %24, %17
%39 = load i32*, i32** %3
%40 = load i32, i32* %4
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = icmp sgt i32 %43, 9999
br i1 %44, label %45, label %48
45: ; preds = %38, %31, %8
%46 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%47 = call i32 @puts(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %62
48: ; preds = %38
%49 = load i32*, i32** %3
%50 = load i32, i32* %4
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
%54 = icmp eq i32 %53, -99999
br i1 %54, label %55, label %58
55: ; preds = %48
%56 = load i8*, i8** %6
%57 = call i32 @puts(i8* %56)
store i32 100, i32* %4
br label %61
58: ; preds = %48
%59 = load i32, i32* %4
%60 = add i32 %59, 1
store i32 %60, i32* %4
br label %61
61: ; preds = %58, %55
br label %62
62: ; preds = %61, %45
br label %63
63: ; preds = %62
%64 = load i32, i32* %5
%65 = icmp eq i32 %64, 0
br i1 %65, label %8, label %66
66: ; preds = %63
br label %67
67: ; preds = %66
%68 = load i32, i32* %4
%69 = icmp ule i32 %68, 99
br i1 %69, label %7, label %70
70: ; preds = %67
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"*** Program loading completed ***\00"
@.str.1 = [8 x i8] c"%02d ? \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [7 x i8] c"%*[^\0A]\00"
@.str.4 = [48 x i8] c"Sono accettati solo interi positivi di 4 cifre.\00"
define void @load(i32* %0, i32 %1) {
br label %3
3: ; preds = %30, %2
%4 = phi i32 [ %1, %2 ], [ %31, %30 ]
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds i32, i32* %0, i64 %5
%7 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%8 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%9 = icmp eq i32 %8, 0
br i1 %9, label %21, label %10
10: ; preds = %21, %3
%11 = load i32, i32* %6
%12 = freeze i32 %11
%13 = icmp sgt i32 %12, 999
br i1 %13, label %15, label %14
14: ; preds = %10
switch i32 %12, label %27 [
i32 -99999, label %17
i32 0, label %19
]
15: ; preds = %10
%16 = icmp ugt i32 %12, 9999
br i1 %16, label %27, label %19
17: ; preds = %14
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %33
19: ; preds = %14, %15
%20 = add i32 %4, 1
br label %30
21: ; preds = %3, %21
%22 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
%24 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%25 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%26 = icmp eq i32 %25, 0
br i1 %26, label %21, label %10
27: ; preds = %15, %14
%28 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %27, %19
%31 = phi i32 [ %20, %19 ], [ %4, %27 ]
%32 = icmp ult i32 %31, 100
br i1 %32, label %3, label %33
33: ; preds = %30, %17
ret void
}