#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 getValue(char *);
int /*<<< orphan*/ insertElement(int *, int, int);
int length(int *);
int /*<<< orphan*/ printf(char *);
void create(int arr[]) {
  int len, value;
  len = length(arr);
  do {
    if (len < 10) {
      value = getValue("the element value(-999 to stop): ");
      insertElement(arr, len, value);
    } else {
      printf("\tArray Bounds Reached.\n");
    }
    len++;
  } while (value != -999 && len <= 10);
}


x86 assembly (clang, -O0):
<create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <length@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1185 <create+0x45>
lea    0xe97(%rip),%rdi
call   1050 <getValue@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <insertElement@plt>
jmp    1191 <create+0x51>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0xfffffc19,-0x10(%rbp)
mov    %al,-0x11(%rbp)
je     11b6 <create+0x76>
cmpl   $0xa,-0xc(%rbp)
setle  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1158 <create+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
call   1030 <length@plt>
mov    %eax,%ebx
cmp    $0xb,%eax
mov    $0xa,%r12d
cmovge %eax,%r12d
lea    0xe9a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
cmp    %ebx,%r12d
je     11a6 <create+0x66>
mov    %r15,%rdi
call   1050 <getValue@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1060 <insertElement@plt>
cmp    $0xfffffc19,%ebp
je     119d <create+0x5d>
lea    0x1(%rbx),%eax
cmp    $0xa,%ebx
mov    %eax,%ebx
jl     1170 <create+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe75(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"the element value(-999 to stop): \00"
@.str.1 = [24 x i8] c"\09Array Bounds Reached.\0A\00"
define void @create(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @length(i32* %5)
store i32 %6, i32* %3
br label %7
7: ; preds = %27, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = call i32 @getValue(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %4
%12 = load i32*, i32** %2
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i32 @insertElement(i32* %12, i32 %13, i32 %14)
br label %18
16: ; preds = %7
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %10
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %21
21: ; preds = %18
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, -999
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* %3
%26 = icmp sle i32 %25, 10
br label %27
27: ; preds = %24, %21
%28 = phi i1 [ false, %21 ], [ %26, %24 ]
br i1 %28, label %7, label %29
29: ; preds = %27
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"the element value(-999 to stop): \00"
@str = [23 x i8] c"\09Array Bounds Reached.\00"
define void @create(i32* %0) {
%2 = tail call i32 @length(i32* %0)
%3 = call i32 @llvm.smax.i32(i32 %2, i32 10)
br label %4
4: ; preds = %9, %1
%5 = phi i32 [ %2, %1 ], [ %13, %9 ]
%6 = icmp eq i32 %5, %3
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %16
9: ; preds = %4
%10 = icmp slt i32 %5, 10
%11 = tail call i32 @getValue(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @insertElement(i32* %0, i32 %5, i32 %11)
%13 = add i32 %5, 1
%14 = icmp ne i32 %11, -999
%15 = select i1 %14, i1 %10, i1 false
br i1 %15, label %4, label %16
16: ; preds = %9, %7
ret void
}