#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 findMinValueWithFrequency(int *, int, int);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int lonelyinteger(void) {
  int arraySize;
  scanf("%d", &arraySize);
  int *array = malloc(sizeof(int) * arraySize);
  for (int i = 0; i < arraySize; i++) {
    scanf("%d", array + i);
  }
  printf("%d", findMinValueWithFrequency(array, arraySize, 1));
  free(array);
  return 0;
}


x86 assembly (clang, -O0):
<lonelyinteger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b7 <lonelyinteger+0x67>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe5c(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1182 <lonelyinteger+0x32>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
call   1040 <findMinValueWithFrequency@plt>
mov    %eax,%esi
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lonelyinteger>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%r12d
lea    0x0(,%r12,4),%edi
call   1060 <malloc@plt>
mov    %rax,%r14
test   %r12d,%r12d
jle    11bd <lonelyinteger+0x6d>
xor    %r13d,%r13d
lea    0xe6e(%rip),%r15
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%r13
movslq 0xc(%rsp),%r12
add    $0x4,%rbx
cmp    %r12,%r13
jl     11a0 <lonelyinteger+0x50>
mov    %r14,%rdi
mov    %r12d,%esi
mov    $0x1,%edx
call   1040 <findMinValueWithFrequency@plt>
lea    0xe2c(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @lonelyinteger() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = sext i32 %5 to i64
%7 = mul i64 4, %6
%8 = trunc i64 %7 to i32
%9 = call i32* @malloc(i32 %8)
store i32* %9, i32** %2
store i32 0, i32* %3
br label %10
10: ; preds = %20, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %1
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = load i32*, i32** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %18)
br label %20
20: ; preds = %14
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %10
23: ; preds = %10
%24 = load i32*, i32** %2
%25 = load i32, i32* %1
%26 = call i32 @findMinValueWithFrequency(i32* %24, i32 %25, i32 1)
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i32*, i32** %2
%29 = call i32 @free(i32* %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @lonelyinteger() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = shl i32 %4, 2
%6 = call i32* @malloc(i32 %5)
%7 = icmp sgt i32 %4, 0
br i1 %7, label %13, label %8
8: ; preds = %13, %0
%9 = phi i32 [ %4, %0 ], [ %18, %13 ]
%10 = call i32 @findMinValueWithFrequency(i32* %6, i32 %9, i32 1)
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @free(i32* %6)
ret i32 0
13: ; preds = %0, %13
%14 = phi i64 [ %17, %13 ], [ 0, %0 ]
%15 = getelementptr inbounds i32, i32* %6, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = add nuw nsw i64 %14, 1
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %13, label %8
}