#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*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *getFileName() {
  char *fileName = (char *)malloc(sizeof(char) * 1024);
  printf("Please enter a path to a dictionary file [./dictionary.txt]: ");
  fgets(fileName, 1024, stdin);
  char *newline = strchr(fileName, '\n');
  if (newline != NULL)
    *newline = '\0';
  if (strcmp(fileName, "\0") == 0)
    strcpy(fileName, "dictionary.txt");
  return fileName;
}


x86 assembly (clang, -O0):
<getFileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x400,%edi
call   1080 <malloc@plt>
mov    %rax,-0x8(%rbp)
lea    0xe83(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1060 <fgets@plt>
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11bd <getFileName+0x5d>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11e7 <getFileName+0x87>
mov    -0x8(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFileName>:
push   %rbx
mov    $0x400,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0xe8b(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11a5 <getFileName+0x45>
movb   $0x0,(%rax)
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11c8 <getFileName+0x68>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [62 x i8] c"Please enter a path to a dictionary file [./dictionary.txt]: \00"
@stdin = global i32 0
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [15 x i8] c"dictionary.txt\00"
define i8* @getFileName() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i64 @malloc(i32 1024)
%4 = inttoptr i64 %3 to i8*
store i8* %4, i8** %1
%5 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %1
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 1024, i32 %7)
%9 = load i8*, i8** %1
%10 = call i8* @strchr(i8* %9, i8 signext 10)
store i8* %10, i8** %2
%11 = load i8*, i8** %2
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = load i8*, i8** %2
store i8 0, i8* %14
br label %15
15: ; preds = %13, %0
%16 = load i8*, i8** %1
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i8*, i8** %1
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %19, %15
%23 = load i8*, i8** %1
ret i8* %23
}

LLVM IR (-O2):
@.str = [62 x i8] c"Please enter a path to a dictionary file [./dictionary.txt]: \00"
@stdin = global i32 0
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [15 x i8] c"dictionary.txt\00"
define i8* @getFileName() {
%1 = tail call i64 @malloc(i32 1024)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = tail call i32 @fgets(i8* %2, i32 1024, i32 %4)
%6 = tail call i8* @strchr(i8* dereferenceable(1) %2, i8 signext 10)
%7 = icmp eq i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %0
store i8 0, i8* %6
br label %9
9: ; preds = %8, %0
%10 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
ret i8* %2
}