#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 */
unsigned containsDuplicates(char *arr, size_t len) {
  static char hash[256];
  size_t i;
  for (i = 0; i < len; i++) {
    if (hash[(size_t)arr[i]] == 1)
      return 1;
    else
      hash[(size_t)arr[i]] = 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<containsDuplicates>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    117d <containsDuplicates+0x7d>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbq (%rax,%rcx,1),%rcx
lea    0x2efa(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x1,%eax
jne    114f <containsDuplicates+0x4f>
movl   $0x1,-0x4(%rbp)
jmp    1184 <containsDuplicates+0x84>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbq (%rax,%rcx,1),%rcx
lea    0x2ecd(%rip),%rax
movb   $0x1,(%rax,%rcx,1)
jmp    116c <containsDuplicates+0x6c>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1114 <containsDuplicates+0x14>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<containsDuplicates>:
test   %rsi,%rsi
je     1128 <containsDuplicates+0x28>
xor    %eax,%eax
lea    0x2f22(%rip),%rcx
xchg   %ax,%ax
movsbq (%rdi,%rax,1),%rdx
cmpb   $0x1,(%rdx,%rcx,1)
je     112b <containsDuplicates+0x2b>
movb   $0x1,(%rdx,%rcx,1)
add    $0x1,%rax
cmp    %rax,%rsi
jne    1110 <containsDuplicates+0x10>
xor    %eax,%eax
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
@containsDuplicates.hash = internal global [256 x i8] zeroinitializer
define i32 @containsDuplicates(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 0, i64* %6
br label %7
7: ; preds = %30, %2
%8 = load i64, i64* %6
%9 = load i64, i64* %5
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %33
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = load i64, i64* %6
%14 = getelementptr inbounds i8, i8* %12, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i64
%17 = getelementptr inbounds [256 x i8], [256 x i8]* @containsDuplicates.hash, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %11
store i32 1, i32* %3
br label %34
22: ; preds = %11
%23 = load i8*, i8** %4
%24 = load i64, i64* %6
%25 = getelementptr inbounds i8, i8* %23, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i64
%28 = getelementptr inbounds [256 x i8], [256 x i8]* @containsDuplicates.hash, i64 0, i64 %27
store i8 1, i8* %28
br label %29
29: ; preds = %22
br label %30
30: ; preds = %29
%31 = load i64, i64* %6
%32 = add i64 %31, 1
store i64 %32, i64* %6
br label %7
33: ; preds = %7
store i32 0, i32* %3
br label %34
34: ; preds = %33, %21
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@containsDuplicates.hash = internal unnamed_addr global [256 x i8] zeroinitializer
define i32 @containsDuplicates(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %15, label %4
4: ; preds = %2, %12
%5 = phi i64 [ %13, %12 ], [ 0, %2 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = sext i8 %7 to i64
%9 = getelementptr inbounds [256 x i8], [256 x i8]* @containsDuplicates.hash, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 1
br i1 %11, label %15, label %12
12: ; preds = %4
store i8 1, i8* %9
%13 = add nuw i64 %5, 1
%14 = icmp eq i64 %13, %1
br i1 %14, label %15, label %4
15: ; preds = %4, %12, %2
%16 = phi i32 [ 0, %2 ], [ 0, %12 ], [ 1, %4 ]
ret i32 %16
}