#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  FILE *file_ptr = fopen("test.txt", "r");
  if (file_ptr == NULL)
    return 1;
  char *string = (char *)malloc(256);
  fscanf(file_ptr, "%s", string);
  int ascii_table[256];
  char *iter = string;
  while (*iter) {
    int value = (int)*iter;
    if (ascii_table[value] == 1) {
      printf("String %s doesn't have unique characters\n", string);
      return 1;
    } else {
      ascii_table[value] = 1;
    }
    ++iter;
  }
  printf("String %s has unique characters\n", string);
  free(string);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1190 <main+0x40>
movl   $0x1,-0x4(%rbp)
jmp    1257 <main+0x107>
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe5e(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rax
cmpb   $0x0,(%rax)
je     1237 <main+0xe7>
mov    -0x428(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x42c(%rbp)
movslq -0x42c(%rbp),%rax
cmpl   $0x1,-0x420(%rbp,%rax,4)
01
jne    120e <main+0xbe>
mov    -0x18(%rbp),%rsi
lea    0xe11(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1257 <main+0x107>
movslq -0x42c(%rbp),%rax
movl   $0x1,-0x420(%rbp,%rax,4)
mov    -0x428(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x428(%rbp)
jmp    11bd <main+0x6d>
mov    -0x18(%rbp),%rsi
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
lea    0xe9f(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11f6 <main+0xa6>
mov    %rax,%rbx
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1050 <fscanf@plt>
mov    (%r14),%cl
test   %cl,%cl
je     11cc <main+0x7c>
mov    %r14,%rax
add    $0x1,%rax
cs nopw 0x0(%rax,%rax,1)
movsbq %cl,%rcx
cmpl   $0x1,(%rsp,%rcx,4)
je     11e7 <main+0x97>
movl   $0x1,(%rsp,%rcx,4)
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    11b0 <main+0x60>
lea    0xe65(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    11fb <main+0xab>
lea    0xe20(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [42 x i8] c"String %s doesn't have unique characters\0A\00"
@.str.4 = [33 x i8] c"String %s has unique characters\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca [256 x i32]
%5 = alloca i8*
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 1, i32* %1
br label %46
11: ; preds = %0
%12 = call i64 @malloc(i32 256)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %3
%14 = load i32*, i32** %2
%15 = load i8*, i8** %3
%16 = call i32 @fscanf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %3
store i8* %17, i8** %5
br label %18
18: ; preds = %38, %11
%19 = load i8*, i8** %5
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %22, label %41
22: ; preds = %18
%23 = load i8*, i8** %5
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %34
31: ; preds = %22
%32 = load i8*, i8** %3
%33 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %32)
store i32 1, i32* %1
br label %46
34: ; preds = %22
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %36
store i32 1, i32* %37
br label %38
38: ; preds = %34
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %5
br label %18
41: ; preds = %18
%42 = load i8*, i8** %3
%43 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %42)
%44 = load i8*, i8** %3
%45 = call i32 @free(i8* %44)
store i32 0, i32* %1
br label %46
46: ; preds = %41, %31, %10
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [42 x i8] c"String %s doesn't have unique characters\0A\00"
@.str.4 = [33 x i8] c"String %s has unique characters\0A\00"
define i32 @main() {
%1 = alloca [256 x i32]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %29, label %4
4: ; preds = %0
%5 = tail call i64 @malloc(i32 256)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%8 = bitcast [256 x i32]* %1 to i8*
%9 = load i8, i8* %6
%10 = icmp eq i8 %9, 0
br i1 %10, label %24, label %11
11: ; preds = %4, %20
%12 = phi i8 [ %22, %20 ], [ %9, %4 ]
%13 = phi i8* [ %21, %20 ], [ %6, %4 ]
%14 = sext i8 %12 to i64
%15 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br label %27
20: ; preds = %11
store i32 1, i32* %15
%21 = getelementptr inbounds i8, i8* %13, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %11
24: ; preds = %20, %4
%25 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%26 = tail call i32 @free(i8* %6)
br label %27
27: ; preds = %18, %24
%28 = phi i32 [ 0, %24 ], [ 1, %18 ]
br label %29
29: ; preds = %0, %27
%30 = phi i32 [ %28, %27 ], [ 1, %0 ]
ret i32 %30
}