#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);
void extractunique(int a[], int n) {
  int i;
  for (i = 0; i <= n; i++) {
    while (a[i] == a[i + 1] && i < n - 1) {
      i++;
    }
    printf("%d\n", a[i]);
  }
}


x86 assembly (clang, -O0):
<extractunique>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11b1 <extractunique+0xa1>
jmp    1137 <extractunique+0x27>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rsi
xor    %eax,%eax
cmp    (%rdx,%rsi,4),%ecx
mov    %al,-0x11(%rbp)
jne    116e <extractunique+0x5e>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    117e <extractunique+0x6e>
jmp    118c <extractunique+0x7c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1137 <extractunique+0x27>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <extractunique+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractunique>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
js     1178 <extractunique+0x68>
mov    %esi,%r14d
mov    %rdi,%r12
lea    -0x1(%r14),%eax
movslq %eax,%r13
xor    %ebx,%ebx
lea    0xecb(%rip),%r15
jmp    114d <extractunique+0x3d>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <printf@plt>
cmp    %r14d,%ebp
jge    1178 <extractunique+0x68>
movslq %ebx,%rax
mov    (%r12,%rax,4),%esi
lea    -0x1(%rax),%ebp
nopw   0x0(%rax,%rax,1)
lea    0x1(%rax),%rbx
add    $0x1,%ebp
cmp    0x4(%r12,%rax,4),%esi
jne    1140 <extractunique+0x30>
cmp    %r13,%rax
mov    %rbx,%rax
jl     1160 <extractunique+0x50>
jmp    1140 <extractunique+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @extractunique(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %41, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %44
10: ; preds = %6
br label %11
11: ; preds = %31, %10
%12 = load i32*, i32** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = load i32*, i32** %3
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %17, i64 %20
%22 = load i32, i32* %21
%23 = icmp eq i32 %16, %22
br i1 %23, label %24, label %29
24: ; preds = %11
%25 = load i32, i32* %5
%26 = load i32, i32* %4
%27 = sub nsw i32 %26, 1
%28 = icmp slt i32 %25, %27
br label %29
29: ; preds = %24, %11
%30 = phi i1 [ false, %11 ], [ %28, %24 ]
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %11
34: ; preds = %29
%35 = load i32*, i32** %3
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %34
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %6
44: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @extractunique(i32* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 0
br i1 %3, label %25, label %4
4: ; preds = %2
%5 = add nsw i32 %1, -1
%6 = sext i32 %5 to i64
br label %7
7: ; preds = %4, %21
%8 = phi i64 [ 0, %4 ], [ %15, %21 ]
%9 = shl i64 %8, 32
%10 = ashr exact i64 %9, 32
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
br label %13
13: ; preds = %7, %13
%14 = phi i64 [ %10, %7 ], [ %15, %13 ]
%15 = add nsw i64 %14, 1
%16 = getelementptr inbounds i32, i32* %0, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %12, %17
%19 = icmp slt i64 %14, %6
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %13, label %21
21: ; preds = %13
%22 = trunc i64 %14 to i32
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%24 = icmp slt i32 %22, %1
br i1 %24, label %7, label %25
25: ; preds = %21, %2
ret void
}