#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strpbrk(char *, char *);
int is_unique(char *str) {
  char current_char;
  size_t size = strlen(str) + 1;
  char *working_string = malloc(size);
  char *temporal_string = NULL;
  char *search_chars = NULL;
  char *search_result = NULL;
  strcpy(working_string, str);
  for (int i = 0; i < strlen(str); i++) {
    current_char = working_string[0];
    search_chars = malloc(2);
    strcpy(search_chars, &current_char);
    temporal_string = malloc(strlen(working_string));
    memmove(&temporal_string[0], &working_string[1],
            strlen(working_string) - 1);
    free(working_string);
    working_string = malloc(strlen(temporal_string) + 1);
    strcpy(working_string, temporal_string);
    if (current_char != ' ') {
      search_result = strpbrk(working_string, search_chars);
      if (search_result != NULL) {
        return 0;
      }
    }
    free(temporal_string);
  }
  free(working_string);
  free(search_chars);
  return 1;
}


x86 assembly (clang, -O0):
<is_unique>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
cmp    %ecx,%eax
jge    12ba <is_unique+0x15a>
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    -0x11(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
sub    $0x1,%edx
call   1080 <memmove@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strcpy@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
je     12a3 <is_unique+0x143>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <strpbrk@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     129e <is_unique+0x13e>
movl   $0x0,-0x4(%rbp)
jmp    12d3 <is_unique+0x173>
jmp    12a3 <is_unique+0x143>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11b9 <is_unique+0x59>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_unique>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
xor    %r15d,%r15d
test   %eax,%eax
jg     11d9 <is_unique+0x79>
xor    %r12d,%r12d
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
jmp    126f <is_unique+0x10f>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x1,%r15d
mov    %r14,%rdi
call   1050 <strlen@plt>
cmp    %eax,%r15d
jge    119b <is_unique+0x3b>
movzbl 0x0(%r13),%eax
mov    %al,0x7(%rsp)
mov    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
lea    0x7(%rsp),%rsi
call   1040 <strcpy@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0x1(%r13),%rbp
mov    %r13,%rdi
call   1050 <strlen@plt>
lea    -0x1(%rax),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <memmove@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
cmpb   $0x20,0x7(%rsp)
je     11c0 <is_unique+0x60>
mov    %r13,%rdi
mov    %r12,%rsi
call   1070 <strpbrk@plt>
test   %rax,%rax
je     11c0 <is_unique+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_unique(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %3
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %12, 1
%14 = sext i32 %13 to i64
store i64 %14, i64* %5
%15 = load i64, i64* %5
%16 = trunc i64 %15 to i32
%17 = call i8* @malloc(i32 %16)
store i8* %17, i8** %6
store i8* null, i8** %7
store i8* null, i8** %8
store i8* null, i8** %9
%18 = load i8*, i8** %6
%19 = load i8*, i8** %3
%20 = call i32 @strcpy(i8* %18, i8* %19)
store i32 0, i32* %10
br label %21
21: ; preds = %67, %1
%22 = load i32, i32* %10
%23 = load i8*, i8** %3
%24 = call i32 @strlen(i8* %23)
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %70
26: ; preds = %21
%27 = load i8*, i8** %6
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
store i8 %29, i8* %4
%30 = call i8* @malloc(i32 2)
store i8* %30, i8** %8
%31 = load i8*, i8** %8
%32 = call i32 @strcpy(i8* %31, i8* %4)
%33 = load i8*, i8** %6
%34 = call i32 @strlen(i8* %33)
%35 = call i8* @malloc(i32 %34)
store i8* %35, i8** %7
%36 = load i8*, i8** %7
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8*, i8** %6
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = load i8*, i8** %6
%41 = call i32 @strlen(i8* %40)
%42 = sub nsw i32 %41, 1
%43 = call i32 @memmove(i8* %37, i8* %39, i32 %42)
%44 = load i8*, i8** %6
%45 = call i32 @free(i8* %44)
%46 = load i8*, i8** %7
%47 = call i32 @strlen(i8* %46)
%48 = add nsw i32 %47, 1
%49 = call i8* @malloc(i32 %48)
store i8* %49, i8** %6
%50 = load i8*, i8** %6
%51 = load i8*, i8** %7
%52 = call i32 @strcpy(i8* %50, i8* %51)
%53 = load i8, i8* %4
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %54, 32
br i1 %55, label %56, label %64
56: ; preds = %26
%57 = load i8*, i8** %6
%58 = load i8*, i8** %8
%59 = call i8* @strpbrk(i8* %57, i8* %58)
store i8* %59, i8** %9
%60 = load i8*, i8** %9
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %63
62: ; preds = %56
store i32 0, i32* %2
br label %75
63: ; preds = %56
br label %64
64: ; preds = %63, %26
%65 = load i8*, i8** %7
%66 = call i32 @free(i8* %65)
br label %67
67: ; preds = %64
%68 = load i32, i32* %10
%69 = add nsw i32 %68, 1
store i32 %69, i32* %10
br label %21
70: ; preds = %21
%71 = load i8*, i8** %6
%72 = call i32 @free(i8* %71)
%73 = load i8*, i8** %8
%74 = call i32 @free(i8* %73)
store i32 1, i32* %2
br label %75
75: ; preds = %70, %62
%76 = load i32, i32* %2
ret i32 %76
}

LLVM IR (-O2):
define i32 @is_unique(i8* %0) {
%2 = alloca i8
%3 = tail call i32 @strlen(i8* %0)
%4 = add nsw i32 %3, 1
%5 = tail call i8* @malloc(i32 %4)
%6 = tail call i32 @strcpy(i8* %5, i8* %0)
%7 = call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %36
9: ; preds = %1, %31
%10 = phi i32 [ %33, %31 ], [ 0, %1 ]
%11 = phi i8* [ %24, %31 ], [ %5, %1 ]
%12 = load i8, i8* %11
store i8 %12, i8* %2
%13 = call dereferenceable_or_null(2) i8* @malloc(i32 2)
%14 = call i32 @strcpy(i8* %13, i8* %2)
%15 = call i32 @strlen(i8* %11)
%16 = call i8* @malloc(i32 %15)
%17 = getelementptr inbounds i8, i8* %11, i64 1
%18 = call i32 @strlen(i8* %11)
%19 = add nsw i32 %18, -1
%20 = call i32 @memmove(i8* %16, i8* %17, i32 %19)
%21 = call i32 @free(i8* %11)
%22 = call i32 @strlen(i8* %16)
%23 = add nsw i32 %22, 1
%24 = call i8* @malloc(i32 %23)
%25 = call i32 @strcpy(i8* %24, i8* %16)
%26 = load i8, i8* %2
%27 = icmp eq i8 %26, 32
br i1 %27, label %31, label %28
28: ; preds = %9
%29 = call i8* @strpbrk(i8* %24, i8* %13)
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %41
31: ; preds = %28, %9
%32 = call i32 @free(i8* %16)
%33 = add nuw nsw i32 %10, 1
%34 = call i32 @strlen(i8* %0)
%35 = icmp slt i32 %33, %34
br i1 %35, label %9, label %36
36: ; preds = %31, %1
%37 = phi i8* [ %5, %1 ], [ %24, %31 ]
%38 = phi i8* [ null, %1 ], [ %13, %31 ]
%39 = call i32 @free(i8* %37)
%40 = call i32 @free(i8* %38)
br label %41
41: ; preds = %28, %36
%42 = phi i32 [ 1, %36 ], [ 0, %28 ]
ret i32 %42
}