#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 */
scalar_t__ calloc(int, int);
bool unique(char *str) {
  int *char_count = (int *)calloc(128, sizeof(int));
  for (char *c = str; *c != '\0'; c++) {
    if (char_count[*c] > 0) {
      return false;
    }
    char_count[*c]++;
  }
  return true;
}


x86 assembly (clang, -O0):
<unique>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x80,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118f <unique+0x7f>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbq (%rcx),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    1169 <unique+0x59>
movl   $0x0,-0x4(%rbp)
jmp    1196 <unique+0x86>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbq (%rcx),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1137 <unique+0x27>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unique>:
push   %rbx
mov    %rdi,%rbx
mov    $0x80,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    (%rbx),%cl
test   %cl,%cl
je     1155 <unique+0x45>
add    $0x1,%rbx
nopl   (%rax)
movsbq %cl,%rcx
mov    (%rax,%rcx,4),%edx
test   %edx,%edx
jg     114c <unique+0x3c>
lea    0x1(%rdx),%esi
mov    %esi,(%rax,%rcx,4)
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    1130 <unique+0x20>
xor    %eax,%eax
test   %edx,%edx
setle  %al
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @unique(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = call i64 @calloc(i32 128, i32 4)
%7 = inttoptr i64 %6 to i32*
store i32* %7, i32** %4
%8 = load i8*, i8** %3
store i8* %8, i8** %5
br label %9
9: ; preds = %31, %1
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %9
%15 = load i32*, i32** %4
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = sext i8 %17 to i64
%19 = getelementptr inbounds i32, i32* %15, i64 %18
%20 = load i32, i32* %19
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %14
store i32 0, i32* %2
br label %35
23: ; preds = %14
%24 = load i32*, i32** %4
%25 = load i8*, i8** %5
%26 = load i8, i8* %25
%27 = sext i8 %26 to i64
%28 = getelementptr inbounds i32, i32* %24, i64 %27
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
br label %31
31: ; preds = %23
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
br label %9
34: ; preds = %9
store i32 1, i32* %2
br label %35
35: ; preds = %34, %22
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
define i32 @unique(i8* nocapture %0) {
%2 = tail call i64 @calloc(i32 128, i32 4)
%3 = inttoptr i64 %2 to i32*
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %1, %13
%7 = phi i8 [ %16, %13 ], [ %4, %1 ]
%8 = phi i8* [ %15, %13 ], [ %0, %1 ]
%9 = sext i8 %7 to i64
%10 = getelementptr inbounds i32, i32* %3, i64 %9
%11 = load i32, i32* %10
%12 = icmp sgt i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %6
%14 = add nsw i32 %11, 1
store i32 %14, i32* %10
%15 = getelementptr inbounds i8, i8* %8, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %6
18: ; preds = %6, %13
%19 = xor i1 %12, true
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %18, %1
%22 = phi i32 [ 1, %1 ], [ %20, %18 ]
ret i32 %22
}