#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*/ exit(int);
int /*<<< orphan*/ fillWithZeros(int, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int removeNthElem(int *, int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int num, temp, arr[10];
  printf("Enter array length: ");
  scanf("%d", &num);
  if (num > 10) {
    printf("Array length exceeded. Exiting.\n");
    exit(1);
  }
  for (int i = 0; i < num; i++) {
    printf("Array element %d: ", i + 1);
    scanf("%d", &arr[i]);
  }
  int removed = 0;
  int arrnew[10];
  removed = removeNthElem(arr, arrnew, num);
  fillWithZeros(removed, arrnew, num);
  printf("\nPerformed removal.\n\n");
  for (int i = 0; i < num; i++) {
    printf("Array element %d: %d \n", i + 1, arrnew[i]);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0xa,-0x14(%rbp)
jle    11a9 <main+0x59>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f9 <main+0xa9>
mov    -0x44(%rbp),%esi
add    $0x1,%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x44(%rbp),%rax
lea    -0x40(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2f(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11b0 <main+0x60>
movl   $0x0,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <removeNthElem@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <fillWithZeros@plt>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    126d <main+0x11d>
mov    -0x74(%rbp),%esi
add    $0x1,%esi
movslq -0x74(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%edx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1237 <main+0xe7>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe95(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edx
cmp    $0xa,%edx
jg     124c <main+0xec>
test   %edx,%edx
jle    11d9 <main+0x79>
lea    0x40(%rsp),%r12
lea    0xe71(%rip),%r14
lea    0xe67(%rip),%r15
xor    %ebx,%ebx
add    $0x1,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
movslq 0xc(%rsp),%rdx
add    $0x4,%r12
cmp    %rdx,%rbx
jl     11b0 <main+0x50>
lea    0x40(%rsp),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1040 <removeNthElem@plt>
mov    0xc(%rsp),%edx
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <fillWithZeros@plt>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    123e <main+0xde>
lea    0xe18(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x10(%rsp,%rbx,4),%edx
add    $0x1,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1220 <main+0xc0>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe04(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Enter array length: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"Array length exceeded. Exiting.\0A\00"
@.str.3 = [19 x i8] c"Array element %d: \00"
@.str.4 = [22 x i8] c"\0APerformed removal.\0A\0A\00"
@.str.5 = [23 x i8] c"Array element %d: %d \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [10 x i32]
%9 = alloca i32
%10 = alloca i32
%11 = alloca [10 x i32]
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%15 = load i32, i32* %6
%16 = icmp sgt i32 %15, 10
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
store i32 0, i32* %9
br label %21
21: ; preds = %33, %20
%22 = load i32, i32* %9
%23 = load i32, i32* %6
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %36
25: ; preds = %21
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 %30
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %31)
br label %33
33: ; preds = %25
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %21
36: ; preds = %21
store i32 0, i32* %10
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 0
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i64 0, i64 0
%39 = load i32, i32* %6
%40 = call i32 @removeNthElem(i32* %37, i32* %38, i32 %39)
store i32 %40, i32* %10
%41 = load i32, i32* %10
%42 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i64 0, i64 0
%43 = load i32, i32* %6
%44 = call i32 @fillWithZeros(i32 %41, i32* %42, i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %12
br label %46
46: ; preds = %58, %36
%47 = load i32, i32* %12
%48 = load i32, i32* %6
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %61
50: ; preds = %46
%51 = load i32, i32* %12
%52 = add nsw i32 %51, 1
%53 = load i32, i32* %12
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %52, i32 %56)
br label %58
58: ; preds = %50
%59 = load i32, i32* %12
%60 = add nsw i32 %59, 1
store i32 %60, i32* %12
br label %46
61: ; preds = %46
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Enter array length: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [19 x i8] c"Array element %d: \00"
@.str.5 = [23 x i8] c"Array element %d: %d \0A\00"
@str = [21 x i8] c"\0APerformed removal.\0A\00"
@str.6 = [32 x i8] c"Array length exceeded. Exiting.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [10 x i32]
%5 = alloca [10 x i32]
%6 = bitcast i32* %3 to i8*
%7 = bitcast [10 x i32]* %4 to i8*
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 10
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = icmp sgt i32 %10, 0
br i1 %13, label %28, label %17
14: ; preds = %2
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.6, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %28, %12
%18 = phi i32 [ %10, %12 ], [ %35, %28 ]
%19 = bitcast [10 x i32]* %5 to i8*
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%22 = call i32 @removeNthElem(i32* %20, i32* %21, i32 %18)
%23 = load i32, i32* %3
%24 = call i32 @fillWithZeros(i32 %22, i32* %21, i32 %23)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%26 = load i32, i32* %3
%27 = icmp sgt i32 %26, 0
br i1 %27, label %39, label %38
28: ; preds = %12, %28
%29 = phi i64 [ %30, %28 ], [ 0, %12 ]
%30 = add nuw nsw i64 %29, 1
%31 = trunc i64 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %29
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %33)
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %30, %36
br i1 %37, label %28, label %17
38: ; preds = %39, %17
ret i32 0
39: ; preds = %17, %39
%40 = phi i64 [ %41, %39 ], [ 0, %17 ]
%41 = add nuw nsw i64 %40, 1
%42 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %40
%43 = load i32, i32* %42
%44 = trunc i64 %41 to i32
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %44, i32 %43)
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = icmp slt i64 %41, %47
br i1 %48, label %39, label %38
}