#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__ checkNum(unsigned char *, int);
unsigned char *createBitVector(int);
int /*<<< orphan*/ markNum(unsigned char *, int);
int /*<<< orphan*/ printf(char *, int);
void findDuplicates(int arr[], int arraySize) {
  unsigned char *bitVector = createBitVector(arraySize);
  for (int i = 0; i < arraySize; i++) {
    int num = arr[i];
    int num0 = num - 1;
    if (checkNum(bitVector, num0)) {
      printf("%i ", num);
    } else {
      markNum(bitVector, num0);
    }
  }
}


x86 assembly (clang, -O0):
<findDuplicates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <createBitVector@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ce <findDuplicates+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <checkNum@plt>
cmp    $0x0,%rax
je     11af <findDuplicates+0x6f>
mov    -0x20(%rbp),%esi
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
jmp    11bb <findDuplicates+0x7b>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1060 <markNum@plt>
jmp    11c0 <findDuplicates+0x80>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1162 <findDuplicates+0x22>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findDuplicates>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
mov    %esi,%edi
call   1030 <createBitVector@plt>
test   %ebx,%ebx
jle    11a9 <findDuplicates+0x69>
mov    %rax,%r12
mov    %ebx,%r13d
xor    %r15d,%r15d
jmp    1183 <findDuplicates+0x43>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebp,%esi
call   1060 <markNum@plt>
add    $0x1,%r15
cmp    %r15,%r13
je     11a9 <findDuplicates+0x69>
mov    (%r14,%r15,4),%ebx
lea    -0x1(%rbx),%ebp
mov    %r12,%rdi
mov    %ebp,%esi
call   1050 <checkNum@plt>
test   %rax,%rax
je     1170 <findDuplicates+0x30>
lea    0xe60(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
jmp    117a <findDuplicates+0x3a>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%i \00"
define void @findDuplicates(i32* nocapture %0, i32 %1) {
%3 = tail call i8* @createBitVector(i32 %1)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %8
7: ; preds = %19, %2
ret void
8: ; preds = %5, %19
%9 = phi i64 [ 0, %5 ], [ %20, %19 ]
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = add nsw i32 %11, -1
%13 = tail call i64 @checkNum(i8* %3, i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %8
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %19
17: ; preds = %8
%18 = tail call i32 @markNum(i8* %3, i32 %12)
br label %19
19: ; preds = %17, %15
%20 = add nuw nsw i64 %9, 1
%21 = icmp eq i64 %20, %6
br i1 %21, label %7, label %8
}