#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*/ scanf(char *, int *);
int getIntArray(int a[10], int nmax, int sentinel) {
  int n = 0;
  int temp;
  do {
    printf("Enter integer [%d to terminate] : ", sentinel);
    scanf("%d", &temp);
    if (temp == sentinel)
      break;
    if (n == nmax)
      printf("array is full\n");
    else
      a[n++] = temp;
  } while (1);
  return n;
}


x86 assembly (clang, -O0):
<getIntArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%esi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    116b <getIntArray+0x4b>
jmp    11b6 <getIntArray+0x96>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    118a <getIntArray+0x6a>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a2 <getIntArray+0x82>
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11a7 <getIntArray+0x87>
mov    $0x1,%al
test   $0x1,%al
jne    1139 <getIntArray+0x19>
jmp    11b6 <getIntArray+0x96>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getIntArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %esi,%r15d
mov    %rdi,0x10(%rsp)
lea    0xeb1(%rip),%rdi
xor    %ebp,%ebp
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    %ebx,%eax
jne    1184 <getIntArray+0x54>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe75(%rip),%r13
lea    0xe91(%rip),%r12
lea    0xc(%rsp),%r14
xor    %ebp,%ebp
jmp    11cd <getIntArray+0x9d>
nopl   0x0(%rax,%rax,1)
movslq %ebp,%rcx
add    $0x1,%ebp
mov    0x10(%rsp),%rdx
mov    %eax,(%rdx,%rcx,4)
mov    %r13,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    %ebx,%eax
je     1173 <getIntArray+0x43>
cmp    %r15d,%ebp
jne    11a0 <getIntArray+0x70>
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
mov    %r15d,%ebp
jmp    11ae <getIntArray+0x7e>

LLVM IR (-O0):
@.str = [35 x i8] c"Enter integer [%d to terminate] : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"array is full\0A\00"
define i32 @getIntArray(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %31, %3
%10 = load i32, i32* %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%13 = load i32, i32* %8
%14 = load i32, i32* %6
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %9
br label %32
17: ; preds = %9
%18 = load i32, i32* %7
%19 = load i32, i32* %5
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %30
23: ; preds = %17
%24 = load i32, i32* %8
%25 = load i32*, i32** %4
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds i32, i32* %25, i64 %28
store i32 %24, i32* %29
br label %30
30: ; preds = %23, %21
br label %31
31: ; preds = %30
br i1 true, label %9, label %32
32: ; preds = %31, %16
%33 = load i32, i32* %7
ret i32 %33
}

LLVM IR (-O2):
@.str = [35 x i8] c"Enter integer [%d to terminate] : \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [14 x i8] c"array is full\00"
define i32 @getIntArray(i32* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %2)
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, %2
br i1 %9, label %26, label %10
10: ; preds = %3, %20
%11 = phi i32 [ %24, %20 ], [ %8, %3 ]
%12 = phi i32 [ %21, %20 ], [ 0, %3 ]
%13 = icmp eq i32 %12, %1
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %20
16: ; preds = %10
%17 = add nsw i32 %12, 1
%18 = sext i32 %12 to i64
%19 = getelementptr inbounds i32, i32* %0, i64 %18
store i32 %11, i32* %19
br label %20
20: ; preds = %14, %16
%21 = phi i32 [ %1, %14 ], [ %17, %16 ]
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %2)
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, %2
br i1 %25, label %26, label %10
26: ; preds = %20, %3
%27 = phi i32 [ 0, %3 ], [ %21, %20 ]
ret i32 %27
}