#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 removeElement(int *, int, int);
int main(void) {
  int arr1[10] = {1, 1, 3, 1, 2, 1, 5, 6, 7, 8};
  int arr2[10] = {1, 1, 3, 1, 2, 1, 5, 6, 7, 8};
  int arr3[10] = {1, 1, 3, 1, 2, 1, 5, 6, 7, 8};
  int len1 = removeElement(arr1, 10, 3);
  int len2 = removeElement(arr2, 10, 1);
  int len3 = removeElement(arr3, 10, 0);
  printf("len1 = %d\n", len1);
  for (int i = 0; i < len1; i++) {
    printf("%d ", arr1[i]);
  }
  printf("\n");
  printf("len2 = %d\n", len2);
  for (int i = 0; i < len2; i++) {
    printf("%d ", arr2[i]);
  }
  printf("\n");
  printf("len3 = %d\n", len3);
  for (int i = 0; i < len3; i++) {
    printf("%d ", arr3[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    -0x60(%rbp),%rdi
lea    0xece(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0xee6(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
mov    $0x3,%edx
call   1030 <removeElement@plt>
mov    %eax,-0x94(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
call   1030 <removeElement@plt>
mov    %eax,-0x98(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0xa,%esi
xor    %edx,%edx
call   1030 <removeElement@plt>
mov    %eax,-0x9c(%rbp)
mov    -0x94(%rbp),%esi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xa0(%rbp)
mov    -0xa0(%rbp),%eax
cmp    -0x94(%rbp),%eax
jge    122c <main+0xfc>
movslq -0xa0(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
jmp    11ed <main+0xbd>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x98(%rbp),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
cmp    -0x98(%rbp),%eax
jge    1297 <main+0x167>
movslq -0xa4(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1258 <main+0x128>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x9c(%rbp),%esi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xa8(%rbp)
mov    -0xa8(%rbp),%eax
cmp    -0x9c(%rbp),%eax
jge    1305 <main+0x1d5>
movslq -0xa8(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%esi
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    12c3 <main+0x193>
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
mov    0xeda(%rip),%rax
mov    %rax,0x80(%rsp)
movaps 0xebb(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe9f(%rip),%xmm1
movaps %xmm1,0x60(%rsp)
mov    %rax,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm1,0x30(%rsp)
mov    %rax,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm1,(%rsp)
lea    0x60(%rsp),%rdi
mov    $0xa,%esi
mov    $0x3,%edx
call   1040 <removeElement@plt>
mov    %eax,%ebx
lea    0x30(%rsp),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
call   1040 <removeElement@plt>
mov    %eax,%r15d
mov    %rsp,%rdi
mov    $0xa,%esi
xor    %edx,%edx
call   1040 <removeElement@plt>
mov    %eax,%r14d
lea    0xe5f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
jle    1207 <main+0xd7>
mov    %ebx,%ebp
lea    0xe54(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x60(%rsp,%rbx,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11f0 <main+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe1f(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15d,%r15d
jle    1257 <main+0x127>
mov    %r15d,%ebp
lea    0xe02(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x30(%rsp,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1240 <main+0x110>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdda(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r14d,%r14d
jle    12a6 <main+0x176>
mov    %r14d,%ebp
lea    0xdb2(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1290 <main+0x160>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.arr1 = [10 x i32] [i32 1, i32 1, i32 3, i32 1, i32 2, i32 1, i32 5, i32 6, i32 7, i32 8]
@__const.main.arr2 = [10 x i32] [i32 1, i32 1, i32 3, i32 1, i32 2, i32 1, i32 5, i32 6, i32 7, i32 8]
@__const.main.arr3 = [10 x i32] [i32 1, i32 1, i32 3, i32 1, i32 2, i32 1, i32 5, i32 6, i32 7, i32 8]
@.str = [11 x i8] c"len1 = %d\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [11 x i8] c"len2 = %d\0A\00"
@.str.4 = [11 x i8] c"len3 = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca [10 x i32]
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = bitcast [10 x i32]* %2 to i8*
%12 = bitcast [10 x i32]* %3 to i8*
%13 = bitcast [10 x i32]* %4 to i8*
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%15 = call i32 @removeElement(i32* %14, i32 10, i32 3)
store i32 %15, i32* %5
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%17 = call i32 @removeElement(i32* %16, i32 10, i32 1)
store i32 %17, i32* %6
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%19 = call i32 @removeElement(i32* %18, i32 10, i32 0)
store i32 %19, i32* %7
%20 = load i32, i32* %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %20)
store i32 0, i32* %8
br label %22
22: ; preds = %32, %0
%23 = load i32, i32* %8
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %26
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %22
35: ; preds = %22
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32, i32* %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %37)
store i32 0, i32* %9
br label %39
39: ; preds = %49, %35
%40 = load i32, i32* %9
%41 = load i32, i32* %6
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %52
43: ; preds = %39
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %43
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %39
52: ; preds = %39
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%54 = load i32, i32* %7
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %54)
store i32 0, i32* %10
br label %56
56: ; preds = %66, %52
%57 = load i32, i32* %10
%58 = load i32, i32* %7
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %69
60: ; preds = %56
%61 = load i32, i32* %10
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %62
%64 = load i32, i32* %63
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %60
%67 = load i32, i32* %10
%68 = add nsw i32 %67, 1
store i32 %68, i32* %10
br label %56
69: ; preds = %56
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr3 = [10 x i32] [i32 1, i32 1, i32 3, i32 1, i32 2, i32 1, i32 5, i32 6, i32 7, i32 8]
@.str = [11 x i8] c"len1 = %d\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.3 = [11 x i8] c"len2 = %d\0A\00"
@.str.4 = [11 x i8] c"len3 = %d\0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca [10 x i32]
%3 = alloca [10 x i32]
%4 = bitcast [10 x i32]* %1 to i8*
%5 = bitcast [10 x i32]* %2 to i8*
%6 = bitcast [10 x i32]* %3 to i8*
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%8 = call i32 @removeElement(i32* %7, i32 10, i32 3)
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%10 = call i32 @removeElement(i32* %9, i32 10, i32 1)
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%12 = call i32 @removeElement(i32* %11, i32 10, i32 0)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %8)
%14 = icmp sgt i32 %8, 0
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = zext i32 %8 to i64
br label %23
17: ; preds = %23, %0
%18 = call i32 @putchar(i32 10)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%20 = icmp sgt i32 %10, 0
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = zext i32 %10 to i64
br label %36
23: ; preds = %15, %23
%24 = phi i64 [ 0, %15 ], [ %28, %23 ]
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = add nuw nsw i64 %24, 1
%29 = icmp eq i64 %28, %16
br i1 %29, label %17, label %23
30: ; preds = %36, %17
%31 = call i32 @putchar(i32 10)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%33 = icmp sgt i32 %12, 0
br i1 %33, label %34, label %43
34: ; preds = %30
%35 = zext i32 %12 to i64
br label %45
36: ; preds = %21, %36
%37 = phi i64 [ 0, %21 ], [ %41, %36 ]
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = add nuw nsw i64 %37, 1
%42 = icmp eq i64 %41, %22
br i1 %42, label %30, label %36
43: ; preds = %45, %30
%44 = call i32 @putchar(i32 10)
ret i32 0
45: ; preds = %34, %45
%46 = phi i64 [ 0, %34 ], [ %50, %45 ]
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %48)
%50 = add nuw nsw i64 %46, 1
%51 = icmp eq i64 %50, %35
br i1 %51, label %43, label %45
}