#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 *calloc(int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, ...);
int check_unique_atring(char *given) {
  char *input = given;
  int *map = calloc(256, sizeof(int));
  int count = 0;
  while (*input != '\0') {
    printf("input[%d]='%c(%d)'\n", count, *input, (int)*input);
    if ((int)*input == 32) {
      count++;
      input++;
      continue;
    }
    if ((int)*input <= 90 && (int)*input >= 65) {
      printf("to lower\n");
      if (map[(int)*input + 32] == 0) {
        printf("map[%d]\n", (int)*input + 32);
        map[(int)*input + 32] = 1;
      } else {
        printf("Not Unique - 1!\n");
        return 0;
      }
      count++;
      input++;
      continue;
    }
    if (map[(int)*input] == 0) {
      printf("map[%d]\n", (int)*input);
      map[(int)*input] = 1;
    } else {
      printf("Not Unique - 2!\n");
      return 0;
    }
    count++;
    input++;
  }
  free(map);
  printf("Unique!\n");
  return 1;
}


x86 assembly (clang, -O0):
<check_unique_atring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x100,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12e4 <check_unique_atring+0x1b4>
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rax
movsbl (%rax),%edx
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11b7 <check_unique_atring+0x87>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115e <check_unique_atring+0x2e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5a,%eax
jg     1269 <check_unique_atring+0x139>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jl     1269 <check_unique_atring+0x139>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
add    $0x20,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1235 <check_unique_atring+0x105>
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
add    $0x20,%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
add    $0x20,%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    124f <check_unique_atring+0x11f>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1302 <check_unique_atring+0x1d2>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115e <check_unique_atring+0x2e>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    12b0 <check_unique_atring+0x180>
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    12ca <check_unique_atring+0x19a>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1302 <check_unique_atring+0x1d2>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115e <check_unique_atring+0x2e>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
lea    0xd55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_unique_atring>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x100,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,%r15
mov    (%rbx),%al
test   %al,%al
je     121b <check_unique_atring+0xdb>
lea    0xe8f(%rip),%r12
lea    0xec6(%rip),%r14
lea    0xe95(%rip),%rbp
xor    %r13d,%r13d
jmp    11a6 <check_unique_atring+0x66>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movl   $0x1,(%r15,%rax,4)
movzbl 0x1(%rbx,%r13,1),%eax
add    $0x1,%r13
test   %al,%al
je     121b <check_unique_atring+0xdb>
movsbl %al,%ecx
mov    %r12,%rdi
mov    %r13d,%esi
mov    %ecx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
movsbq (%rbx,%r13,1),%rsi
cmp    $0x20,%rsi
je     1198 <check_unique_atring+0x58>
lea    -0x41(%rsi),%eax
cmp    $0x19,%al
ja     1200 <check_unique_atring+0xc0>
lea    0xe64(%rip),%rdi
call   1040 <puts@plt>
movsbq (%rbx,%r13,1),%rsi
cmpl   $0x0,0x80(%r15,%rsi,4)
jne    1248 <check_unique_atring+0x108>
add    $0x20,%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbq (%rbx,%r13,1),%rax
add    $0x20,%rax
jmp    1190 <check_unique_atring+0x50>
nop
cmpl   $0x0,(%r15,%rsi,4)
jne    124c <check_unique_atring+0x10c>
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbq (%rbx,%r13,1),%rax
jmp    1190 <check_unique_atring+0x50>
mov    %r15,%rdi
call   1030 <free@plt>
mov    $0x1,%ebx
lea    0xdee(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
jmp    122f <check_unique_atring+0xef>
xor    %ebx,%ebx
lea    0xdd0(%rip),%r14
jmp    122f <check_unique_atring+0xef>

LLVM IR (-O0):
@.str = [20 x i8] c"input[%d]='%c(%d)'\0A\00"
@.str.1 = [10 x i8] c"to lower\0A\00"
@.str.2 = [9 x i8] c"map[%d]\0A\00"
@.str.3 = [17 x i8] c"Not Unique - 1!\0A\00"
@.str.4 = [17 x i8] c"Not Unique - 2!\0A\00"
@.str.5 = [9 x i8] c"Unique!\0A\00"
define i32 @check_unique_atring(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
store i8* %7, i8** %4
%8 = call i32* @calloc(i32 256, i32 4)
store i32* %8, i32** %5
store i32 0, i32* %6
br label %9
9: ; preds = %95, %68, %27, %1
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %100
14: ; preds = %9
%15 = load i32, i32* %6
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %18, i32 %21)
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 32
br i1 %26, label %27, label %32
27: ; preds = %14
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %4
br label %9
32: ; preds = %14
%33 = load i8*, i8** %4
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp sle i32 %35, 90
br i1 %36, label %37, label %73
37: ; preds = %32
%38 = load i8*, i8** %4
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp sge i32 %40, 65
br i1 %41, label %42, label %73
42: ; preds = %37
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%44 = load i32*, i32** %5
%45 = load i8*, i8** %4
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = add nsw i32 %47, 32
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %44, i64 %49
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %66
53: ; preds = %42
%54 = load i8*, i8** %4
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = add nsw i32 %56, 32
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %57)
%59 = load i32*, i32** %5
%60 = load i8*, i8** %4
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = add nsw i32 %62, 32
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i32, i32* %59, i64 %64
store i32 1, i32* %65
br label %68
66: ; preds = %42
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %104
68: ; preds = %53
%69 = load i32, i32* %6
%70 = add nsw i32 %69, 1
store i32 %70, i32* %6
%71 = load i8*, i8** %4
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %4
br label %9
73: ; preds = %37, %32
%74 = load i32*, i32** %5
%75 = load i8*, i8** %4
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i32, i32* %74, i64 %78
%80 = load i32, i32* %79
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %93
82: ; preds = %73
%83 = load i8*, i8** %4
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %85)
%87 = load i32*, i32** %5
%88 = load i8*, i8** %4
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i32, i32* %87, i64 %91
store i32 1, i32* %92
br label %95
93: ; preds = %73
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %2
br label %104
95: ; preds = %82
%96 = load i32, i32* %6
%97 = add nsw i32 %96, 1
store i32 %97, i32* %6
%98 = load i8*, i8** %4
%99 = getelementptr inbounds i8, i8* %98, i32 1
store i8* %99, i8** %4
br label %9
100: ; preds = %9
%101 = load i32*, i32** %5
%102 = call i32 @free(i32* %101)
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %2
br label %104
104: ; preds = %100, %93, %66
%105 = load i32, i32* %2
ret i32 %105
}

LLVM IR (-O2):
@.str = [20 x i8] c"input[%d]='%c(%d)'\0A\00"
@.str.2 = [9 x i8] c"map[%d]\0A\00"
@str = [8 x i8] c"Unique!\00"
@str.6 = [16 x i8] c"Not Unique - 2!\00"
@str.7 = [9 x i8] c"to lower\00"
@str.8 = [16 x i8] c"Not Unique - 1!\00"
define i32 @check_unique_atring(i8* nocapture %0) {
%2 = tail call i32* @calloc(i32 256, i32 4)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %48, label %5
5: ; preds = %1, %16
%6 = phi i8 [ %19, %16 ], [ %3, %1 ]
%7 = phi i32 [ %17, %16 ], [ 0, %1 ]
%8 = phi i8* [ %18, %16 ], [ %0, %1 ]
%9 = sext i8 %6 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9, i32 %9)
%11 = load i8, i8* %8
%12 = icmp eq i8 %11, 32
br i1 %12, label %16, label %21
13: ; preds = %43, %33
%14 = phi i64 [ %37, %33 ], [ %47, %43 ]
%15 = getelementptr inbounds i32, i32* %2, i64 %14
store i32 1, i32* %15
br label %16
16: ; preds = %13, %5
%17 = add nuw nsw i32 %7, 1
%18 = getelementptr inbounds i8, i8* %8, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %48, label %5
21: ; preds = %5
%22 = add i8 %11, -65
%23 = icmp ult i8 %22, 26
br i1 %23, label %24, label %38
24: ; preds = %21
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0))
%26 = load i8, i8* %8
%27 = sext i8 %26 to i32
%28 = add nsw i32 %27, 32
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %2, i64 %29
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %50
33: ; preds = %24
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%35 = load i8, i8* %8
%36 = sext i8 %35 to i64
%37 = add nsw i64 %36, 32
br label %13
38: ; preds = %21
%39 = sext i8 %11 to i64
%40 = getelementptr inbounds i32, i32* %2, i64 %39
%41 = load i32, i32* %40
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %38
%44 = sext i8 %11 to i32
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = load i8, i8* %8
%47 = sext i8 %46 to i64
br label %13
48: ; preds = %16, %1
%49 = tail call i32 @free(i32* %2)
br label %50
50: ; preds = %38, %24, %48
%51 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0), %48 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.8, i64 0, i64 0), %24 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0), %38 ]
%52 = phi i32 [ 1, %48 ], [ 0, %24 ], [ 0, %38 ]
%53 = tail call i32 @puts(i8* dereferenceable(1) %51)
ret i32 %52
}