#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 find_duplicates(int vec[], int size) {
  for (int i = 0; i < size; i++) {
    for (int j = i + 1; j < size; j++) {
      if (vec[i] == vec[j]) {
        printf("%d\n", vec[i]);
      }
    }
  }
}


x86 assembly (clang, -O0):
<find_duplicates>:
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
jge    11a0 <find_duplicates+0x90>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118d <find_duplicates+0x7d>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    117a <find_duplicates+0x6a>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
jmp    117f <find_duplicates+0x6f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <find_duplicates+0x2b>
jmp    1192 <find_duplicates+0x82>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <find_duplicates+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_duplicates>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1192 <find_duplicates+0x82>
mov    %rdi,%r12
mov    %esi,%eax
xor    %r15d,%r15d
mov    %rax,%rbx
mov    %rdi,%rbp
mov    %rax,(%rsp)
jmp    1151 <find_duplicates+0x41>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x4,%rbp
add    $0xffffffffffffffff,%rbx
mov    (%rsp),%rax
cmp    %rax,%r15
je     1192 <find_duplicates+0x82>
mov    %r15,%r13
add    $0x1,%r15
cmp    %rax,%r15
jae    1140 <find_duplicates+0x30>
mov    $0x1,%r14d
jmp    1179 <find_duplicates+0x69>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r14
cmp    %r14,%rbx
je     1140 <find_duplicates+0x30>
mov    (%r12,%r13,4),%esi
cmp    0x0(%rbp,%r14,4),%esi
jne    1170 <find_duplicates+0x60>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
jmp    1170 <find_duplicates+0x60>
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 @find_duplicates(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %42, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %45
11: ; preds = %7
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 1
store i32 %13, i32* %6
br label %14
14: ; preds = %38, %11
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %41
18: ; preds = %14
%19 = load i32*, i32** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = load i32*, i32** %3
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = icmp eq i32 %23, %28
br i1 %29, label %30, label %37
30: ; preds = %18
%31 = load i32*, i32** %3
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %30, %18
br label %38
38: ; preds = %37
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %14
41: ; preds = %14
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %7
45: ; preds = %7
ret void
}

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