#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SEEK_SET;
int areDistinct(int *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(int *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int *malloc(int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  if (argc != 2) {
    return EXIT_FAILURE;
  }
  FILE *fptr = fopen(argv[1], "r");
  if (fptr == NULL) {
    return EXIT_FAILURE;
  }
  int length = 0;
  int value;
  while (fscanf(fptr, "%d", &value) == 1) {
    length++;
  }
  fseek(fptr, 0, SEEK_SET);
  int *arr = malloc(length * sizeof(int));
  length = 0;
  while (fscanf(fptr, "%d", &(arr[length])) == 1) {
    length++;
  }
  fclose(fptr);
  int dist = areDistinct(arr, length);
  printf("The elements are");
  if (dist == 0) {
    printf(" not");
  }
  printf(" distinct.\n");
  free(arr);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b1 <main+0x31>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d6 <main+0x156>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe40(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e5 <main+0x65>
mov    0x2dfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d6 <main+0x156>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe0b(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1070 <fscanf@plt>
cmp    $0x1,%eax
jne    1217 <main+0x97>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ec <main+0x6c>
mov    -0x18(%rbp),%rdi
mov    0x2dbe(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xda3(%rip),%rsi
call   1070 <fscanf@plt>
cmp    $0x1,%eax
jne    127b <main+0xfb>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1245 <main+0xc5>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <areDistinct@plt>
mov    %eax,-0x2c(%rbp)
lea    0xd6b(%rip),%rdi
call   1060 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    12b5 <main+0x135>
lea    0xd66(%rip),%rdi
call   1060 <printf@plt>
lea    0xd5f(%rip),%rdi
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    0x2cff(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    1297 <main+0x107>
mov    0x8(%rsi),%rdi
lea    0xe50(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1297 <main+0x107>
mov    %rax,%r12
mov    $0xfffffffc,%ebp
lea    0xe35(%rip),%r14
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1080 <fscanf@plt>
add    $0x4,%ebp
cmp    $0x1,%eax
je     11e0 <main+0x50>
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    $0xffffffff,%ebp
lea    0xde3(%rip),%r15
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1080 <fscanf@plt>
add    $0x1,%ebp
add    $0x4,%rbx
cmp    $0x1,%eax
je     1230 <main+0xa0>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1060 <areDistinct@plt>
mov    %eax,%ebx
lea    0xda0(%rip),%rdi
call   1070 <printf@plt>
test   %ebx,%ebx
jne    127a <main+0xea>
lea    0xda1(%rip),%rdi
call   1070 <printf@plt>
lea    0xd9a(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2d3b(%rip),%rax
jmp    129e <main+0x10e>
mov    0x2d3a(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%d\00"
@SEEK_SET = global i32 0
@.str.2 = [17 x i8] c"The elements are\00"
@.str.3 = [5 x i8] c" not\00"
@.str.4 = [12 x i8] c" distinct.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = load i32, i32* @EXIT_FAILURE
store i32 %14, i32* %3
br label %68
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %6
%20 = load i32*, i32** %6
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %68
24: ; preds = %15
store i32 0, i32* %7
br label %25
25: ; preds = %29, %24
%26 = load i32*, i32** %6
%27 = call i32 @fscanf(i32* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %25
32: ; preds = %25
%33 = load i32*, i32** %6
%34 = load i32, i32* @SEEK_SET
%35 = call i32 @fseek(i32* %33, i32 0, i32 %34)
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = mul i64 %37, 4
%39 = trunc i64 %38 to i32
%40 = call i32* @malloc(i32 %39)
store i32* %40, i32** %9
store i32 0, i32* %7
br label %41
41: ; preds = %49, %32
%42 = load i32*, i32** %6
%43 = load i32*, i32** %9
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = call i32 @fscanf(i32* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %46)
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %52
49: ; preds = %41
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %41
52: ; preds = %41
%53 = load i32*, i32** %6
%54 = call i32 @fclose(i32* %53)
%55 = load i32*, i32** %9
%56 = load i32, i32* %7
%57 = call i32 @areDistinct(i32* %55, i32 %56)
store i32 %57, i32* %10
%58 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%59 = load i32, i32* %10
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %52
%62 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %63
63: ; preds = %61, %52
%64 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%65 = load i32*, i32** %9
%66 = call i32 @free(i32* %65)
%67 = load i32, i32* @EXIT_SUCCESS
store i32 %67, i32* %3
br label %68
68: ; preds = %63, %22, %13
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%d\00"
@SEEK_SET = global i32 0
@.str.2 = [17 x i8] c"The elements are\00"
@.str.3 = [5 x i8] c" not\00"
@EXIT_SUCCESS = global i32 0
@str = [11 x i8] c" distinct.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp eq i32 %0, 2
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = load i32, i32* @EXIT_FAILURE
br label %44
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = load i32, i32* @EXIT_FAILURE
br label %44
14: ; preds = %7
%15 = bitcast i32* %3 to i8*
br label %16
16: ; preds = %16, %14
%17 = phi i32 [ 0, %14 ], [ %20, %16 ]
%18 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%19 = icmp eq i32 %18, 1
%20 = add nuw nsw i32 %17, 1
br i1 %19, label %16, label %21
21: ; preds = %16
%22 = load i32, i32* @SEEK_SET
%23 = call i32 @fseek(i32* %10, i32 0, i32 %22)
%24 = shl i32 %17, 2
%25 = call i32* @malloc(i32 %24)
br label %26
26: ; preds = %26, %21
%27 = phi i64 [ %31, %26 ], [ 0, %21 ]
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
%30 = icmp eq i32 %29, 1
%31 = add nuw i64 %27, 1
br i1 %30, label %26, label %32
32: ; preds = %26
%33 = trunc i64 %27 to i32
%34 = call i32 @fclose(i32* %10)
%35 = call i32 @areDistinct(i32* %25, i32 %33)
%36 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp eq i32 %35, 0
br i1 %37, label %38, label %40
38: ; preds = %32
%39 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38, %32
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%42 = call i32 @free(i32* %25)
%43 = load i32, i32* @EXIT_SUCCESS
br label %44
44: ; preds = %12, %40, %5
%45 = phi i32 [ %6, %5 ], [ %13, %12 ], [ %43, %40 ]
ret i32 %45
}