#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__ find(char *, char);
char *malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
bool checkUnique(char *myString) {
  bool result = true;
  int size = strlen(myString);
  char temp[size];
  strcat(temp, "");
  for (int i = 0; i < size; i = i + 1) {
    char currChar = myString[i];
    if (find(temp, currChar)) {
      result = false;
      break;
    } else {
      size_t currSize = 1;
      char *newCharString = malloc(1 + 1);
      newCharString[0] = currChar;
      newCharString[1] = '\0';
      strcat(temp, newCharString);
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<checkUnique>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe74(%rip),%rsi
call   1060 <strcat@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    121c <checkUnique+0xdc>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x25(%rbp)
movsbl -0x25(%rbp),%esi
call   1040 <find@plt>
cmp    $0x0,%rax
je     11d5 <checkUnique+0x95>
movl   $0x0,-0xc(%rbp)
jmp    121c <checkUnique+0xdc>
movq   $0x1,-0x30(%rbp)
mov    $0x2,%edi
call   1050 <malloc@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,-0x38(%rbp)
mov    -0x25(%rbp),%cl
mov    -0x38(%rbp),%rax
mov    %cl,(%rax)
mov    -0x38(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x38(%rbp),%rsi
call   1060 <strcat@plt>
jmp    120e <checkUnique+0xce>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1198 <checkUnique+0x58>
mov    -0xc(%rbp),%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkUnique>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%r12d
mov    %eax,%r13d
mov    %rsp,%r15
lea    0xf(%r13),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    0xe8c(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcat@plt>
mov    $0x1,%eax
test   %r12d,%r12d
jle    11d4 <checkUnique+0x94>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%r12d
movsbl %r12b,%esi
mov    %r15,%rdi
call   1040 <find@plt>
test   %rax,%rax
jne    11d2 <checkUnique+0x92>
mov    $0x2,%edi
call   1050 <malloc@plt>
mov    %r12b,(%rax)
movb   $0x0,0x1(%rax)
mov    %r15,%rdi
mov    %rax,%rsi
call   1060 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1190 <checkUnique+0x50>
mov    $0x1,%eax
jmp    11d4 <checkUnique+0x94>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i32 @checkUnique(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %19
7: ; preds = %1, %13
%8 = phi i64 [ %17, %13 ], [ 0, %1 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = call i64 @find(i8* %4, i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %7
%14 = call dereferenceable_or_null(2) i8* @malloc(i32 2)
store i8 %10, i8* %14
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8 0, i8* %15
%16 = call i32 @strcat(i8* %4, i8* %14)
%17 = add nuw nsw i64 %8, 1
%18 = icmp eq i64 %17, %3
br i1 %18, label %19, label %7
19: ; preds = %13, %7, %1
%20 = phi i32 [ 1, %1 ], [ 0, %7 ], [ 1, %13 ]
ret i32 %20
}