#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
void inputProgram(int memory[], int size) {
  int input;
  size_t i = 0;
  while (1) {
    scanf("%d", &input);
    if (input == -99999 || i == (size - 1))
      break;
    memory[i] = input;
    ++i;
  }
  puts("*** Program loading completed ***");
}


x86 assembly (clang, -O0):
<inputProgram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0xfffe7961,-0x10(%rbp)
je     116a <inputProgram+0x4a>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jne    116f <inputProgram+0x4f>
jmp    118e <inputProgram+0x6e>
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1137 <inputProgram+0x17>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inputProgram>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %rdi,%r12
lea    0xec8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0xfffe7961,%eax
je     1196 <inputProgram+0x76>
add    $0xffffffff,%ebp
je     1196 <inputProgram+0x76>
movslq %ebp,%rbp
add    $0xffffffffffffffff,%rbp
xor    %ebx,%ebx
lea    0xe9e(%rip),%r14
lea    0xc(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    %eax,(%r12,%rbx,4)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0xfffe7961,%eax
je     1196 <inputProgram+0x76>
lea    0x1(%rbx),%rcx
cmp    %rbx,%rbp
mov    %rcx,%rbx
jne    1170 <inputProgram+0x50>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [34 x i8] c"*** Program loading completed ***\00"
define void @inputProgram(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
store i32* %0, i32** %3
store i32 %1, i32* %4
store i64 0, i64* %6
br label %7
7: ; preds = %2, %18
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, -99999
br i1 %10, label %17, label %11
11: ; preds = %7
%12 = load i64, i64* %6
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = icmp eq i64 %12, %15
br i1 %16, label %17, label %18
17: ; preds = %11, %7
br label %25
18: ; preds = %11
%19 = load i32, i32* %5
%20 = load i32*, i32** %3
%21 = load i64, i64* %6
%22 = getelementptr inbounds i32, i32* %20, i64 %21
store i32 %19, i32* %22
%23 = load i64, i64* %6
%24 = add i64 %23, 1
store i64 %24, i64* %6
br label %7
25: ; preds = %17
%26 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [34 x i8] c"*** Program loading completed ***\00"
define void @inputProgram(i32* nocapture writeonly %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = add nsw i32 %1, -1
%6 = sext i32 %5 to i64
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, -99999
%10 = icmp eq i32 %5, 0
%11 = select i1 %9, i1 true, i1 %10
br i1 %11, label %22, label %12
12: ; preds = %2, %12
%13 = phi i32 [ %18, %12 ], [ %8, %2 ]
%14 = phi i64 [ %16, %12 ], [ 0, %2 ]
%15 = getelementptr inbounds i32, i32* %0, i64 %14
store i32 %13, i32* %15
%16 = add i64 %14, 1
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, -99999
%20 = icmp eq i64 %16, %6
%21 = select i1 %19, i1 true, i1 %20
br i1 %21, label %22, label %12
22: ; preds = %12, %2
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
ret void
}