#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*/ assert(int);
int has_all_symbols_once(int *sequence, int length) {
  int i;
  int symbol;
  char symbols_present[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  assert(length < 16);
  for (i = 0; i < length; ++i) {
    symbol = sequence[i];
    if (symbol < 0 || symbol >= length)
      return 0;
    else if (symbols_present[symbol])
      return 0;
    else
      symbols_present[symbol] = 1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<has_all_symbols_once>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
cmpl   $0x10,-0x14(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11cf <has_all_symbols_once+0xaf>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1187 <has_all_symbols_once+0x67>
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1193 <has_all_symbols_once+0x73>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <has_all_symbols_once+0xb6>
movslq -0x1c(%rbp),%rax
cmpb   $0x0,-0x30(%rbp,%rax,1)
je     11ae <has_all_symbols_once+0x8e>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <has_all_symbols_once+0xb6>
movslq -0x1c(%rbp),%rax
movb   $0x1,-0x30(%rbp,%rax,1)
jmp    11bc <has_all_symbols_once+0x9c>
jmp    11c1 <has_all_symbols_once+0xa1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1157 <has_all_symbols_once+0x37>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_all_symbols_once>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
xor    %edi,%edi
cmp    $0x10,%esi
setl   %dil
call   1030 <assert@plt>
mov    $0x1,%eax
test   %ebx,%ebx
jle    1163 <has_all_symbols_once+0x53>
mov    %ebx,%ecx
xor    %edx,%edx
xchg   %ax,%ax
mov    (%r14,%rdx,4),%esi
test   %esi,%esi
js     1161 <has_all_symbols_once+0x51>
cmp    %ebx,%esi
jge    1161 <has_all_symbols_once+0x51>
cmpb   $0x0,(%rsp,%rsi,1)
jne    1161 <has_all_symbols_once+0x51>
movb   $0x1,(%rsp,%rsi,1)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1140 <has_all_symbols_once+0x30>
jmp    1163 <has_all_symbols_once+0x53>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @has_all_symbols_once(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [16 x i8]
store i32* %0, i32** %4
store i32 %1, i32* %5
%9 = bitcast [16 x i8]* %8 to i8*
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 16
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
store i32 0, i32* %6
br label %14
14: ; preds = %44, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %47
18: ; preds = %14
%19 = load i32*, i32** %4
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = icmp slt i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %18
%27 = load i32, i32* %7
%28 = load i32, i32* %5
%29 = icmp sge i32 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %26, %18
store i32 0, i32* %3
br label %48
31: ; preds = %26
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = icmp ne i8 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 0, i32* %3
br label %48
38: ; preds = %31
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 %40
store i8 1, i8* %41
br label %42
42: ; preds = %38
br label %43
43: ; preds = %42
br label %44
44: ; preds = %43
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %14
47: ; preds = %14
store i32 1, i32* %3
br label %48
48: ; preds = %47, %37, %30
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
define i32 @has_all_symbols_once(i32* nocapture %0, i32 %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %1, 16
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %26
9: ; preds = %2
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %9, %23
%12 = phi i64 [ 0, %9 ], [ %24, %23 ]
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = icmp sgt i32 %14, -1
%16 = icmp slt i32 %14, %1
%17 = and i1 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %11
%19 = zext i32 %14 to i64
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %18
store i8 1, i8* %20
%24 = add nuw nsw i64 %12, 1
%25 = icmp eq i64 %24, %10
br i1 %25, label %26, label %11
26: ; preds = %11, %18, %23, %2
%27 = phi i32 [ 1, %2 ], [ 1, %23 ], [ 0, %18 ], [ 0, %11 ]
ret i32 %27
}