#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
void find_defn(char *defn, int ln) {
  FILE *f;
  int i = 0;
  f = fopen("./res/vcdefns.txt", "r");
  if (f == NULL) {
    printf("Wordlist definitions (path: %s) is missing!\n",
           "./res/vcdefns.txt");
    exit(EXIT_FAILURE);
  }
  while (fgets(defn, 128, f)) {
    ++i;
    if (i != ln) {
      continue;
    }
    for (i = 0; i < strlen(defn); i++) {
      if (defn[i] == '\n') {
        defn[i] = 0;
      }
    }
    if (0) {
      printf("Definition: %s.\n", defn);
    }
    break;
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<find_defn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe83(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b9 <find_defn+0x59>
lea    0xe75(%rip),%rdi
lea    0xe5a(%rip),%rsi
call   1050 <printf@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11be <find_defn+0x5e>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x80,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1250 <find_defn+0xf0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11f4 <find_defn+0x94>
jmp    11be <find_defn+0x5e>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    124b <find_defn+0xeb>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1238 <find_defn+0xd8>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    123d <find_defn+0xdd>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11fb <find_defn+0x9b>
jmp    1250 <find_defn+0xf0>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_defn>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xe90(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11eb <find_defn+0x8b>
mov    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11df <find_defn+0x7f>
add    $0xffffffff,%ebp
jne    1190 <find_defn+0x30>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11df <find_defn+0x7f>
xor    %ebp,%ebp
jmp    11d3 <find_defn+0x73>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    11df <find_defn+0x7f>
cmpb   $0xa,(%rbx,%rbp,1)
jne    11c0 <find_defn+0x60>
movb   $0x0,(%rbx,%rbp,1)
jmp    11c0 <find_defn+0x60>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fclose@plt>
lea    0xe22(%rip),%rdi
lea    0xe07(%rip),%rsi
call   1050 <printf@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"./res/vcdefns.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [45 x i8] c"Wordlist definitions (path: %s) is missing!\0A\00"
@EXIT_FAILURE = global i32 0
define void @find_defn(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %6
%7 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 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** %5
%8 = load i32*, i32** %5
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
br label %15
15: ; preds = %26, %14
%16 = load i8*, i8** %3
%17 = load i32*, i32** %5
%18 = call i64 @fgets(i8* %16, i32 128, i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %51
20: ; preds = %15
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = load i32, i32* %4
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %20
br label %15
27: ; preds = %20
store i32 0, i32* %6
br label %28
28: ; preds = %47, %27
%29 = load i32, i32* %6
%30 = load i8*, i8** %3
%31 = call i32 @strlen(i8* %30)
%32 = icmp slt i32 %29, %31
br i1 %32, label %33, label %50
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 10
br i1 %40, label %41, label %46
41: ; preds = %33
%42 = load i8*, i8** %3
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 0, i8* %45
br label %46
46: ; preds = %41, %33
br label %47
47: ; preds = %46
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %28
50: ; preds = %28
br label %51
51: ; preds = %50, %15
%52 = load i32*, i32** %5
%53 = call i32 @fclose(i32* %52)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"./res/vcdefns.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [45 x i8] c"Wordlist definitions (path: %s) is missing!\0A\00"
@EXIT_FAILURE = global i32 0
define void @find_defn(i8* %0, i32 %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2, %13
%10 = phi i32 [ %14, %13 ], [ 0, %2 ]
%11 = tail call i64 @fgets(i8* %0, i32 128, i32* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %30, label %13
13: ; preds = %9
%14 = add nuw nsw i32 %10, 1
%15 = icmp eq i32 %14, %1
br i1 %15, label %16, label %9
16: ; preds = %13
%17 = tail call i32 @strlen(i8* %0)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %16, %25
%20 = phi i64 [ %26, %25 ], [ 0, %16 ]
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 10
br i1 %23, label %24, label %25
24: ; preds = %19
store i8 0, i8* %21
br label %25
25: ; preds = %19, %24
%26 = add nuw nsw i64 %20, 1
%27 = tail call i32 @strlen(i8* %0)
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %26, %28
br i1 %29, label %19, label %30
30: ; preds = %9, %25, %16
%31 = tail call i32 @fclose(i32* %3)
ret void
}