#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, 2};
  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) == 1)) {
    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] == 2)) {
    printf("assert fail: %s\n", "nums[1] == 2");
    return -1;
  };
  printf("everything is fine!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xec1(%rip),%eax
mov    %eax,-0x14(%rbp)
lea    -0x1c(%rbp),%rdi
xor    %esi,%esi
call   1040 <removeDuplicates@plt>
cmp    $0x0,%eax
je     117f <main+0x5f>
lea    0xea7(%rip),%rdi
lea    0xeb1(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e8 <main+0x1c8>
lea    -0x1c(%rbp),%rdi
mov    $0x1,%esi
call   1040 <removeDuplicates@plt>
cmp    $0x1,%eax
je     11b7 <main+0x97>
lea    0xe6f(%rip),%rdi
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e8 <main+0x1c8>
lea    -0x1c(%rbp),%rdi
mov    $0x2,%esi
call   1040 <removeDuplicates@plt>
cmp    $0x1,%eax
je     11ef <main+0xcf>
lea    0xe37(%rip),%rdi
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e8 <main+0x1c8>
cmpl   $0x1,-0x1c(%rbp)
je     121a <main+0xfa>
lea    0xe0c(%rip),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e8 <main+0x1c8>
cmpl   $0x1,-0x18(%rbp)
je     1245 <main+0x125>
lea    0xde1(%rip),%rdi
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e8 <main+0x1c8>
lea    -0x1c(%rbp),%rdi
mov    $0x3,%esi
call   1040 <removeDuplicates@plt>
cmp    $0x2,%eax
je     127d <main+0x15d>
lea    0xda9(%rip),%rdi
lea    0xdf0(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e8 <main+0x1c8>
cmpl   $0x1,-0x1c(%rbp)
je     12a8 <main+0x188>
lea    0xd7e(%rip),%rdi
lea    0xdd7(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e8 <main+0x1c8>
cmpl   $0x2,-0x18(%rbp)
je     12d3 <main+0x1b3>
lea    0xd53(%rip),%rdi
lea    0xdb6(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e8 <main+0x1c8>
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    0xece(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xebb(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1050 <removeDuplicates@plt>
test   %eax,%eax
je     116d <main+0x3d>
lea    0xeab(%rip),%rdi
lea    0xeb5(%rip),%rsi
jmp    1246 <main+0x116>
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
call   1050 <removeDuplicates@plt>
cmp    $0x1,%eax
jne    11d8 <main+0xa8>
lea    0x8(%rsp),%rdi
mov    $0x2,%esi
call   1050 <removeDuplicates@plt>
cmp    $0x1,%eax
jne    11e8 <main+0xb8>
cmpl   $0x1,0x8(%rsp)
jne    11f8 <main+0xc8>
cmpl   $0x1,0xc(%rsp)
jne    1208 <main+0xd8>
lea    0x8(%rsp),%rdi
mov    $0x3,%esi
call   1050 <removeDuplicates@plt>
cmp    $0x2,%eax
jne    1218 <main+0xe8>
cmpl   $0x1,0x8(%rsp)
jne    1228 <main+0xf8>
cmpl   $0x2,0xc(%rsp)
jne    1238 <main+0x108>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
lea    0xe2d(%rip),%rdi
lea    0xe42(%rip),%rsi
jmp    1246 <main+0x116>
lea    0xe1d(%rip),%rdi
lea    0xe3d(%rip),%rsi
jmp    1246 <main+0x116>
lea    0xe0d(%rip),%rdi
lea    0xe3f(%rip),%rsi
jmp    1246 <main+0x116>
lea    0xdfd(%rip),%rdi
lea    0xe37(%rip),%rsi
jmp    1246 <main+0x116>
lea    0xded(%rip),%rdi
lea    0xe34(%rip),%rsi
jmp    1246 <main+0x116>
lea    0xddd(%rip),%rdi
lea    0xe36(%rip),%rsi
jmp    1246 <main+0x116>
lea    0xdcd(%rip),%rdi
lea    0xe30(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.nums = [3 x i32] [i32 1, i32 1, i32 2]
@.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 = [13 x i8] c"nums[1] == 2\00"
@.str.9 = [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 [3 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = bitcast [3 x i32]* %6 to i8*
%8 = getelementptr inbounds [3 x i32], [3 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 %57
13: ; preds = %2
%14 = getelementptr inbounds [3 x i32], [3 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 %57
19: ; preds = %13
%20 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%21 = call i32 @removeDuplicates(i32* %20, i32 2)
%22 = icmp eq i32 %21, 1
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 %57
25: ; preds = %19
%26 = getelementptr inbounds [3 x i32], [3 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 %57
31: ; preds = %25
%32 = getelementptr inbounds [3 x i32], [3 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 %57
37: ; preds = %31
%38 = getelementptr inbounds [3 x i32], [3 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 %57
43: ; preds = %37
%44 = getelementptr inbounds [3 x i32], [3 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 %57
49: ; preds = %43
%50 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 2
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.8, i64 0, i64 0))
store i32 -1, i32* %3
br label %57
55: ; preds = %49
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %57
57: ; preds = %55, %53, %47, %41, %35, %29, %23, %17, %11
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@__const.main.nums = [3 x i32] [i32 1, i32 1, i32 2]
@.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 = [13 x i8] c"nums[1] == 2\00"
@str = [20 x i8] c"everything is fine!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x i32]
%4 = bitcast [3 x i32]* %3 to i8*
%5 = getelementptr inbounds [3 x i32], [3 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 %48
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 %48
15: ; preds = %10
%16 = call i32 @removeDuplicates(i32* %5, i32 2)
%17 = icmp eq i32 %16, 1
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 %48
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 %48
25: ; preds = %20
%26 = getelementptr inbounds [3 x i32], [3 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 %48
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 %48
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 %48
41: ; preds = %36
%42 = load i32, i32* %26
%43 = icmp eq i32 %42, 2
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.8, i64 0, i64 0))
br label %48
46: ; preds = %41
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %48
48: ; preds = %46, %44, %39, %34, %29, %23, %18, %13, %8
%49 = phi i32 [ 0, %46 ], [ -1, %44 ], [ -1, %39 ], [ -1, %34 ], [ -1, %29 ], [ -1, %23 ], [ -1, %18 ], [ -1, %13 ], [ -1, %8 ]
ret i32 %49
}