#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 */
scalar_t__ check_presence(int, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char **argv) {
  int size;
  int i;
  static int buffer = 0;
  printf("Enter the size of the array: ");
  scanf("%d", &size);
  int array[size];
  int array_new[size];
  printf("Enter the array elements: \n");
  for (i = 0; i < size; i++) {
    printf("\t");
    scanf("%d", &array[i]);
  }
  for (i = 0; i < size; i++) {
    if (check_presence(array[i], array_new, size))
      continue;
    else {
      array_new[buffer] = array[i];
      buffer++;
    }
  }
  printf("The new array with removed duplicates is: ");
  for (i = 0; i < buffer; i++)
    printf("%d ", array_new[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1203 <main+0xd3>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2e(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c0 <main+0x90>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1277 <main+0x147>
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x14(%rbp),%edx
call   1050 <check_presence@plt>
cmp    $0x0,%rax
je     123c <main+0x10c>
jmp    1269 <main+0x139>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
movslq -0x18(%rbp),%rdx
mov    (%rcx,%rdx,4),%edx
movslq 0x2dea(%rip),%rcx
mov    %edx,(%rax,%rcx,4)
mov    0x2de1(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2dd8(%rip)
jmp    1269 <main+0x139>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    120a <main+0xda>
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    0x2da7(%rip),%eax
jge    12c2 <main+0x192>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    128c <main+0x15c>
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea8(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1060 <scanf@plt>
mov    %rsp,%r12
mov    -0x2c(%rbp),%eax
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    -0x2c(%rbp),%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    0xe97(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    125a <main+0x10a>
mov    %r12,-0x38(%rbp)
xor    %r12d,%r12d
lea    0xe48(%rip),%r14
mov    %r13,%rbx
nopl   0x0(%rax)
mov    $0x9,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%r12
movslq -0x2c(%rbp),%rdx
add    $0x4,%rbx
cmp    %rdx,%r12
jl     11e0 <main+0x90>
test   %edx,%edx
mov    -0x38(%rbp),%r12
jle    125a <main+0x10a>
xor    %ebx,%ebx
jmp    122d <main+0xdd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
movslq -0x2c(%rbp),%rdx
cmp    %rdx,%rbx
jge    125a <main+0x10a>
mov    0x0(%r13,%rbx,4),%edi
mov    %r15,%rsi
call   1070 <check_presence@plt>
test   %rax,%rax
jne    1220 <main+0xd0>
mov    0x0(%r13,%rbx,4),%eax
movslq 0x2e01(%rip),%rcx
mov    %eax,(%r15,%rcx,4)
lea    0x1(%rcx),%eax
mov    %eax,0x2df4(%rip)
jmp    1220 <main+0xd0>
lea    0xdc0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x2ddd(%rip)
jle    129e <main+0x14e>
lea    0xdd4(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0x2db3(%rip),%rax
cmp    %rax,%rbx
jl     1280 <main+0x130>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.buffer = internal global i32 0
@.str = [30 x i8] c"Enter the size of the array: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"Enter the array elements: \0A\00"
@.str.3 = [2 x i8] c"\09\00"
@.str.4 = [43 x i8] c"The new array with removed duplicates is: \00"
@.str.5 = [4 x i8] c"%d \00"
@.str.6 = [2 x i8] c"\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 i8*
%9 = alloca i64
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%13 = load i32, i32* %6
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %8
%16 = alloca i32, i64 %14
store i64 %14, i64* %9
%17 = load i32, i32* %6
%18 = zext i32 %17 to i64
%19 = alloca i32, i64 %18
store i64 %18, i64* %10
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %21
21: ; preds = %31, %2
%22 = load i32, i32* %7
%23 = load i32, i32* %6
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %34
25: ; preds = %21
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %16, i64 %28
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %29)
br label %31
31: ; preds = %25
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %21
34: ; preds = %21
store i32 0, i32* %7
br label %35
35: ; preds = %59, %34
%36 = load i32, i32* %7
%37 = load i32, i32* %6
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %62
39: ; preds = %35
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %16, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* %6
%45 = call i64 @check_presence(i32 %43, i32* %19, i32 %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %39
br label %59
48: ; preds = %39
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %16, i64 %50
%52 = load i32, i32* %51
%53 = load i32, i32* @main.buffer
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %19, i64 %54
store i32 %52, i32* %55
%56 = load i32, i32* @main.buffer
%57 = add nsw i32 %56, 1
store i32 %57, i32* @main.buffer
br label %58
58: ; preds = %48
br label %59
59: ; preds = %58, %47
%60 = load i32, i32* %7
%61 = add nsw i32 %60, 1
store i32 %61, i32* %7
br label %35
62: ; preds = %35
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %7
br label %64
64: ; preds = %74, %62
%65 = load i32, i32* %7
%66 = load i32, i32* @main.buffer
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %77
68: ; preds = %64
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %19, i64 %70
%72 = load i32, i32* %71
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %72)
br label %74
74: ; preds = %68
%75 = load i32, i32* %7
%76 = add nsw i32 %75, 1
store i32 %76, i32* %7
br label %64
77: ; preds = %64
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %3
%79 = load i8*, i8** %8
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
@main.buffer = internal unnamed_addr global i32 0
@.str = [30 x i8] c"Enter the size of the array: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [43 x i8] c"The new array with removed duplicates is: \00"
@.str.5 = [4 x i8] c"%d \00"
@str = [27 x i8] c"Enter the array elements: \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = alloca i32, i64 %8
%11 = load i32, i32* %3
%12 = zext i32 %11 to i64
%13 = alloca i32, i64 %12
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* %3
%16 = icmp sgt i32 %15, 0
br i1 %16, label %19, label %46
17: ; preds = %19
%18 = icmp sgt i32 %25, 0
br i1 %18, label %28, label %46
19: ; preds = %2, %19
%20 = phi i64 [ %24, %19 ], [ 0, %2 ]
%21 = call i32 @putchar(i32 9)
%22 = getelementptr inbounds i32, i32* %10, i64 %20
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = add nuw nsw i64 %20, 1
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %19, label %17
28: ; preds = %17, %41
%29 = phi i64 [ %42, %41 ], [ 0, %17 ]
%30 = phi i32 [ %43, %41 ], [ %25, %17 ]
%31 = getelementptr inbounds i32, i32* %10, i64 %29
%32 = load i32, i32* %31
%33 = call i64 @check_presence(i32 %32, i32* %13, i32 %30)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %28
%36 = load i32, i32* %31
%37 = load i32, i32* @main.buffer
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %13, i64 %38
store i32 %36, i32* %39
%40 = add nsw i32 %37, 1
store i32 %40, i32* @main.buffer
br label %41
41: ; preds = %28, %35
%42 = add nuw nsw i64 %29, 1
%43 = load i32, i32* %3
%44 = sext i32 %43 to i64
%45 = icmp slt i64 %42, %44
br i1 %45, label %28, label %46
46: ; preds = %41, %2, %17
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%48 = load i32, i32* @main.buffer
%49 = icmp sgt i32 %48, 0
br i1 %49, label %50, label %59
50: ; preds = %46, %50
%51 = phi i64 [ %55, %50 ], [ 0, %46 ]
%52 = getelementptr inbounds i32, i32* %13, i64 %51
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %53)
%55 = add nuw nsw i64 %51, 1
%56 = load i32, i32* @main.buffer
%57 = sext i32 %56 to i64
%58 = icmp slt i64 %55, %57
br i1 %58, label %50, label %59
59: ; preds = %50, %46
%60 = call i32 @putchar(i32 10)
ret i32 0
}