#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 removeDuplicates(int *, int);
int main(int argc, char *argv[]) {
  int nums[] = {1, 1, 1, 2, 2, 4};
  if (!(removeDuplicates(nums, 0) == 0)) {
    printf("assert fail: %s\n", "boundary 0");
    return -1;
  };
  if (!(removeDuplicates(nums, 1) == 1)) {
    printf("assert fail: %s\n", "boundary 1");
    return -1;
  };
  if (!(removeDuplicates(nums, 2) == 2)) {
    printf("assert fail: %s\n", "test for length 2");
    return -1;
  };
  if (!(nums[0] == 1)) {
    printf("assert fail: %s\n", "nums[0]");
    return -1;
  };
  if (!(nums[1] == 1)) {
    printf("assert fail: %s\n", "nums[1] == 1");
    return -1;
  };
  if (!(removeDuplicates(nums, 3) == 2)) {
    printf("assert fail: %s\n", "test for length 3");
    return -1;
  };
  if (!(nums[0] == 1)) {
    printf("assert fail: %s\n", "nums[0] 2");
    return -1;
  };
  if (!(nums[1] == 1)) {
    printf("assert fail: %s\n", "nums[1] == 1");
    return -1;
  };
  if (!(removeDuplicates(nums, 6) == 5)) {
    printf("assert fail: %s\n", "test for length 5");
    return -1;
  };
  if (!(nums[2] == 2)) {
    printf("assert fail: %s\n", "nums[2] == 2");
    return -1;
  };
  printf("everything is fine!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1040 <removeDuplicates@plt>
cmp    $0x0,%eax
je     118c <main+0x6c>
lea    0xea6(%rip),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1358 <main+0x238>
lea    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   1040 <removeDuplicates@plt>
cmp    $0x1,%eax
je     11c4 <main+0xa4>
lea    0xe6e(%rip),%rdi
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1358 <main+0x238>
lea    -0x30(%rbp),%rdi
mov    $0x2,%esi
call   1040 <removeDuplicates@plt>
cmp    $0x2,%eax
je     11fc <main+0xdc>
lea    0xe36(%rip),%rdi
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1358 <main+0x238>
cmpl   $0x1,-0x30(%rbp)
je     1227 <main+0x107>
lea    0xe0b(%rip),%rdi
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1358 <main+0x238>
cmpl   $0x1,-0x2c(%rbp)
je     1252 <main+0x132>
lea    0xde0(%rip),%rdi
lea    0xe1a(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1358 <main+0x238>
lea    -0x30(%rbp),%rdi
mov    $0x3,%esi
call   1040 <removeDuplicates@plt>
cmp    $0x2,%eax
je     128a <main+0x16a>
lea    0xda8(%rip),%rdi
lea    0xdef(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1358 <main+0x238>
cmpl   $0x1,-0x30(%rbp)
je     12b5 <main+0x195>
lea    0xd7d(%rip),%rdi
lea    0xdd6(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1358 <main+0x238>
cmpl   $0x1,-0x2c(%rbp)
je     12e0 <main+0x1c0>
lea    0xd52(%rip),%rdi
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1358 <main+0x238>
lea    -0x30(%rbp),%rdi
mov    $0x6,%esi
call   1040 <removeDuplicates@plt>
cmp    $0x5,%eax
je     1318 <main+0x1f8>
lea    0xd1a(%rip),%rdi
lea    0xd7d(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1358 <main+0x238>
cmpl   $0x2,-0x28(%rbp)
je     1343 <main+0x223>
lea    0xcef(%rip),%rdi
lea    0xd64(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1358 <main+0x238>
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    0xed5(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <removeDuplicates@plt>
test   %eax,%eax
je     116c <main+0x3c>
lea    0xeb8(%rip),%rdi
lea    0xec2(%rip),%rsi
jmp    1266 <main+0x136>
mov    %rsp,%rdi
mov    $0x1,%esi
call   1050 <removeDuplicates@plt>
cmp    $0x1,%eax
jne    1208 <main+0xd8>
mov    %rsp,%rdi
mov    $0x2,%esi
call   1050 <removeDuplicates@plt>
cmp    $0x2,%eax
jne    1218 <main+0xe8>
cmpl   $0x1,(%rsp)
jne    1228 <main+0xf8>
cmpl   $0x1,0x4(%rsp)
jne    1238 <main+0x108>
mov    %rsp,%rdi
mov    $0x3,%esi
call   1050 <removeDuplicates@plt>
cmp    $0x2,%eax
jne    1248 <main+0x118>
cmpl   $0x1,(%rsp)
jne    1258 <main+0x128>
cmpl   $0x1,0x4(%rsp)
jne    1238 <main+0x108>
mov    %rsp,%rdi
mov    $0x6,%esi
call   1050 <removeDuplicates@plt>
cmp    $0x5,%eax
jne    1277 <main+0x147>
cmpl   $0x2,0x8(%rsp)
jne    1287 <main+0x157>
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
lea    0xe09(%rip),%rdi
lea    0xe1e(%rip),%rsi
jmp    1266 <main+0x136>
lea    0xdf9(%rip),%rdi
lea    0xe19(%rip),%rsi
jmp    1266 <main+0x136>
lea    0xde9(%rip),%rdi
lea    0xe1b(%rip),%rsi
jmp    1266 <main+0x136>
lea    0xdd9(%rip),%rdi
lea    0xe13(%rip),%rsi
jmp    1266 <main+0x136>
lea    0xdc9(%rip),%rdi
lea    0xe10(%rip),%rsi
jmp    1266 <main+0x136>
lea    0xdb9(%rip),%rdi
lea    0xe12(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
ret
lea    0xd9a(%rip),%rdi
lea    0xdfd(%rip),%rsi
jmp    1266 <main+0x136>
lea    0xd8a(%rip),%rdi
lea    0xdff(%rip),%rsi
jmp    1266 <main+0x136>

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

LLVM IR (-O2):
@__const.main.nums = [6 x i32] [i32 1, i32 1, i32 1, i32 2, i32 2, i32 4]
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [11 x i8] c"boundary 0\00"
@.str.2 = [11 x i8] c"boundary 1\00"
@.str.3 = [18 x i8] c"test for length 2\00"
@.str.4 = [8 x i8] c"nums[0]\00"
@.str.5 = [13 x i8] c"nums[1] == 1\00"
@.str.6 = [18 x i8] c"test for length 3\00"
@.str.7 = [10 x i8] c"nums[0] 2\00"
@.str.8 = [18 x i8] c"test for length 5\00"
@.str.9 = [13 x i8] c"nums[2] == 2\00"
@str = [20 x i8] c"everything is fine!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i32]
%4 = bitcast [6 x i32]* %3 to i8*
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%6 = call i32 @removeDuplicates(i32* %5, i32 0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %59
10: ; preds = %2
%11 = call i32 @removeDuplicates(i32* %5, i32 1)
%12 = icmp eq i32 %11, 1
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %59
15: ; preds = %10
%16 = call i32 @removeDuplicates(i32* %5, i32 2)
%17 = icmp eq i32 %16, 2
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %59
20: ; preds = %15
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 1
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %59
25: ; preds = %20
%26 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 1
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 1
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %59
31: ; preds = %25
%32 = call i32 @removeDuplicates(i32* %5, i32 3)
%33 = icmp eq i32 %32, 2
br i1 %33, label %36, label %34
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %59
36: ; preds = %31
%37 = load i32, i32* %5
%38 = icmp eq i32 %37, 1
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %59
41: ; preds = %36
%42 = load i32, i32* %26
%43 = icmp eq i32 %42, 1
br i1 %43, label %46, label %44
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %59
46: ; preds = %41
%47 = call i32 @removeDuplicates(i32* %5, i32 6)
%48 = icmp eq i32 %47, 5
br i1 %48, label %51, label %49
49: ; preds = %46
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %59
51: ; preds = %46
%52 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 2
%53 = load i32, i32* %52
%54 = icmp eq i32 %53, 2
br i1 %54, label %57, label %55
55: ; preds = %51
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br label %59
57: ; preds = %51
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %59
59: ; preds = %57, %55, %49, %44, %39, %34, %29, %23, %18, %13, %8
%60 = phi i32 [ 0, %57 ], [ -1, %55 ], [ -1, %49 ], [ -1, %44 ], [ -1, %39 ], [ -1, %34 ], [ -1, %29 ], [ -1, %23 ], [ -1, %18 ], [ -1, %13 ], [ -1, %8 ]
ret i32 %60
}