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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int is_unique(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strtok(char *, char *);
int main(void) {
  FILE *file;
  char *line = NULL;
  char file_name[128];
  size_t length = 0;
  ssize_t read;
  printf("Provide input file: ");
  fgets(file_name, 128, stdin);
  strtok(file_name, "\n");
  file = fopen(file_name, "r");
  if (file == NULL) {
    printf("Failed to open file at %s: ", file_name);
    exit(1);
  }
  while ((read = getline(&line, &length, file)) != -1) {
    strtok(line, "\n");
    if (is_unique(line) == 1) {
      printf("%s is unique\n", line);
    } else {
      printf("%s is not unique\n", line);
    }
  }
  free(line);
  fclose(file);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0xa8(%rbp)
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xa0(%rbp),%rdi
mov    0x2e17(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1070 <fgets@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1090 <strtok@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1231 <main+0xa1>
lea    -0xa0(%rbp),%rsi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    1236 <main+0xa6>
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0xa8(%rbp),%rsi
call   10a0 <getline@plt>
mov    %eax,-0xac(%rbp)
cmp    $0xffffffff,%eax
je     12a9 <main+0x119>
mov    -0x18(%rbp),%rdi
lea    0xddb(%rip),%rsi
call   1090 <strtok@plt>
mov    -0x18(%rbp),%rdi
call   1050 <is_unique@plt>
cmp    $0x1,%eax
jne    1292 <main+0x102>
mov    -0x18(%rbp),%rsi
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12a4 <main+0x114>
mov    -0x18(%rbp),%rsi
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1236 <main+0xa6>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xe47(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1070 <fgets@plt>
lea    0xe5d(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strtok@plt>
lea    0xe24(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
jne    121b <main+0x8b>
lea    0xe12(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %rax,%rdx
call   10a0 <getline@plt>
cmp    $0xffffffff,%eax
je     128d <main+0xfd>
lea    0xe05(%rip),%r14
lea    0xdf2(%rip),%r13
lea    0xdf9(%rip),%rbp
mov    %rsp,%r15
lea    0x8(%rsp),%r12
mov    (%rsp),%rdi
mov    %r14,%rsi
call   1090 <strtok@plt>
mov    (%rsp),%rdi
call   1050 <is_unique@plt>
cmp    $0x1,%eax
mov    (%rsp),%rsi
mov    %rbp,%rdi
cmove  %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   10a0 <getline@plt>
cmp    $0xffffffff,%eax
jne    1250 <main+0xc0>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Provide input file: \00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [28 x i8] c"Failed to open file at %s: \00"
@.str.4 = [14 x i8] c"%s is unique\0A\00"
@.str.5 = [18 x i8] c"%s is not unique\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca [128 x i8]
%5 = alloca i64
%6 = alloca i32
store i32 0, i32* %1
store i8* null, i8** %3
store i64 0, i64* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %8, i32 128, i32 %9)
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%12 = call i32 @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %14, i32** %2
%15 = load i32*, i32** %2
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %0
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %0
br label %22
22: ; preds = %38, %21
%23 = load i32*, i32** %2
%24 = call i32 @getline(i8** %3, i64* %5, i32* %23)
store i32 %24, i32* %6
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %39
26: ; preds = %22
%27 = load i8*, i8** %3
%28 = call i32 @strtok(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = load i8*, i8** %3
%30 = call i32 @is_unique(i8* %29)
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = load i8*, i8** %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %33)
br label %38
35: ; preds = %26
%36 = load i8*, i8** %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %35, %32
br label %22
39: ; preds = %22
%40 = load i8*, i8** %3
%41 = call i32 @free(i8* %40)
%42 = load i32*, i32** %2
%43 = call i32 @fclose(i32* %42)
%44 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [21 x i8] c"Provide input file: \00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [28 x i8] c"Failed to open file at %s: \00"
@.str.4 = [14 x i8] c"%s is unique\0A\00"
@.str.5 = [18 x i8] c"%s is not unique\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca [128 x i8]
%3 = alloca i64
%4 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %5, i32 128, i32 %8)
%10 = call i32 @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %0
%14 = call i32 @getline(i8** %1, i64* %3, i32* %11)
%15 = icmp eq i32 %14, -1
br i1 %15, label %30, label %19
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %13, %19
%20 = load i8*, i8** %1
%21 = call i32 @strtok(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = load i8*, i8** %1
%23 = call i32 @is_unique(i8* %22)
%24 = icmp eq i32 %23, 1
%25 = load i8*, i8** %1
%26 = select i1 %24, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %26, i8* %25)
%28 = call i32 @getline(i8** %1, i64* %3, i32* %11)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %19
30: ; preds = %19, %13
%31 = load i8*, i8** %1
%32 = call i32 @free(i8* %31)
%33 = call i32 @fclose(i32* %11)
%34 = call i32 @exit(i32 0)
unreachable
}