#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*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
void checkIfStrCharsAreUnique(char *str) {
  int ret = 0, i = 0, val = 0;
  int ascii[256];
  if (str == NULL) {
    printf("Input Error\n");
  }
  memset(ascii, 0, sizeof(int) * 256);
  while (str[i] != '\0') {
    val = (int)str[i];
    if (ascii[val] == 1) {
      ret = -1;
      break;
    } else {
      ascii[val] = 1;
    }
    if (ret == 0)
      i++;
  }
  if (ret == -1)
    printf("String %s is not having unique chars, dup char = %c\n", str,
           str[i]);
  else
    printf("String %s is having unique chars\n", str);
}


x86 assembly (clang, -O0):
<checkIfStrCharsAreUnique>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    115d <checkIfStrCharsAreUnique+0x3d>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11d9 <checkIfStrCharsAreUnique+0xb9>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmpl   $0x1,-0x420(%rbp,%rax,4)
01
jne    11b2 <checkIfStrCharsAreUnique+0x92>
movl   $0xffffffff,-0xc(%rbp)
jmp    11d9 <checkIfStrCharsAreUnique+0xb9>
movslq -0x14(%rbp),%rax
movl   $0x1,-0x420(%rbp,%rax,4)
cmpl   $0x0,-0xc(%rbp)
jne    11d4 <checkIfStrCharsAreUnique+0xb4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1170 <checkIfStrCharsAreUnique+0x50>
cmpl   $0xffffffff,-0xc(%rbp)
jne    1206 <checkIfStrCharsAreUnique+0xe6>
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1218 <checkIfStrCharsAreUnique+0xf8>
mov    -0x8(%rbp),%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkIfStrCharsAreUnique>:
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rbx
test   %rdi,%rdi
jne    114c <checkIfStrCharsAreUnique+0x1c>
lea    0xf10(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    (%rbx),%cl
test   %cl,%cl
je     118c <checkIfStrCharsAreUnique+0x5c>
lea    0x1(%rbx),%rax
cs nopw 0x0(%rax,%rax,1)
nop
movsbq %cl,%rdx
cmpl   $0x1,(%rsp,%rdx,4)
je     119f <checkIfStrCharsAreUnique+0x6f>
movl   $0x1,(%rsp,%rdx,4)
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1170 <checkIfStrCharsAreUnique+0x40>
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b0 <checkIfStrCharsAreUnique+0x80>
lea    0xe5a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Input Error\0A\00"
@.str.1 = [53 x i8] c"String %s is not having unique chars, dup char = %c\0A\00"
@.str.2 = [34 x i8] c"String %s is having unique chars\0A\00"
define void @checkIfStrCharsAreUnique(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [256 x i32]
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%7 = load i8*, i8** %2
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %1
%12 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 0
%13 = call i32 @memset(i32* %12, i32 0, i32 1024)
br label %14
14: ; preds = %45, %11
%15 = load i8*, i8** %2
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %46
22: ; preds = %14
%23 = load i8*, i8** %2
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %35
34: ; preds = %22
store i32 -1, i32* %3
br label %46
35: ; preds = %22
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %37
store i32 1, i32* %38
br label %39
39: ; preds = %35
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %45
45: ; preds = %42, %39
br label %14
46: ; preds = %34, %14
%47 = load i32, i32* %3
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %58
49: ; preds = %46
%50 = load i8*, i8** %2
%51 = load i8*, i8** %2
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %50, i32 %56)
br label %61
58: ; preds = %46
%59 = load i8*, i8** %2
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %58, %49
ret void
}

LLVM IR (-O2):
@.str.1 = [53 x i8] c"String %s is not having unique chars, dup char = %c\0A\00"
@.str.2 = [34 x i8] c"String %s is having unique chars\0A\00"
@str = [12 x i8] c"Input Error\00"
define void @checkIfStrCharsAreUnique(i8* %0) {
%2 = alloca [256 x i32]
%3 = bitcast [256 x i32]* %2 to i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %7
7: ; preds = %5, %1
%8 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 0
%9 = call i32 @memset(i32* %8, i32 0, i32 1024)
%10 = load i8, i8* %0
%11 = icmp eq i8 %10, 0
br i1 %11, label %27, label %12
12: ; preds = %7, %19
%13 = phi i64 [ %20, %19 ], [ 0, %7 ]
%14 = phi i8 [ %22, %19 ], [ %10, %7 ]
%15 = sext i8 %14 to i64
%16 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 1
br i1 %18, label %24, label %19
19: ; preds = %12
store i32 1, i32* %16
%20 = add nuw i64 %13, 1
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %27, label %12
24: ; preds = %12
%25 = sext i8 %14 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %25)
br label %29
27: ; preds = %19, %7
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %29
29: ; preds = %27, %24
ret void
}