#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 */
struct ttrie__obj {
  int dummy;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int ttrie__get(struct ttrie__obj *, char *, int, unsigned long long *);
int check_missing(char *missing_path, struct ttrie__obj *ttp) {
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  int num_checks = 0;
  FILE *fp_missing = fopen(missing_path, "r");
  if (fp_missing == NULL)
    exit(EXIT_FAILURE);
  while ((read = getline(&line, &len, fp_missing)) != -1) {
    line[read - 1] = '\0';
    unsigned long long result;
    int rc = ttrie__get(ttp, line, read, &result);
    assert(rc != 0);
    num_checks += 1;
  }
  fclose(fp_missing);
  free(line);
  return num_checks;
}


x86 assembly (clang, -O0):
<check_missing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11c4 <check_missing+0x54>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    11c9 <check_missing+0x59>
mov    -0x30(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     122d <check_missing+0xbd>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    -0x38(%rbp),%rcx
call   1040 <ttrie__get@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c9 <check_missing+0x59>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_missing>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xe67(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1230 <check_missing+0xc0>
mov    %rax,%rbx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %rax,%rdx
call   1080 <getline@plt>
xor    %ebp,%ebp
cmp    $0xffffffff,%eax
je     120e <check_missing+0x9e>
lea    0x10(%rsp),%r15
mov    %rsp,%r12
lea    0x8(%rsp),%r13
xchg   %ax,%ax
mov    (%rsp),%rcx
movslq %eax,%rdx
movb   $0x0,-0x1(%rdx,%rcx,1)
mov    (%rsp),%rsi
mov    %r14,%rdi
mov    %r15,%rcx
call   1040 <ttrie__get@plt>
xor    %edi,%edi
test   %eax,%eax
setne  %dil
call   1060 <assert@plt>
add    $0x1,%ebp
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1080 <getline@plt>
cmp    $0xffffffff,%eax
jne    11d0 <check_missing+0x60>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.ttrie__obj = type { i32 }
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
define i32 @check_missing(i8* %0, %struct.ttrie__obj* %1) {
%3 = alloca i8*
%4 = alloca %struct.ttrie__obj*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i32
store i8* %0, i8** %3
store %struct.ttrie__obj* %1, %struct.ttrie__obj** %4
store i8* null, i8** %5
store i64 0, i64* %6
store i32 0, i32* %8
%12 = load i8*, i8** %3
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %9
%14 = load i32*, i32** %9
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
br label %20
20: ; preds = %24, %19
%21 = load i32*, i32** %9
%22 = call i32 @getline(i8** %5, i64* %6, i32* %21)
store i32 %22, i32* %7
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %40
24: ; preds = %20
%25 = load i8*, i8** %5
%26 = load i32, i32* %7
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
store i8 0, i8* %29
%30 = load %struct.ttrie__obj*, %struct.ttrie__obj** %4
%31 = load i8*, i8** %5
%32 = load i32, i32* %7
%33 = call i32 @ttrie__get(%struct.ttrie__obj* %30, i8* %31, i32 %32, i64* %10)
store i32 %33, i32* %11
%34 = load i32, i32* %11
%35 = icmp ne i32 %34, 0
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %20
40: ; preds = %20
%41 = load i32*, i32** %9
%42 = call i32 @fclose(i32* %41)
%43 = load i8*, i8** %5
%44 = call i32 @free(i8* %43)
%45 = load i32, i32* %8
ret i32 %45
}

LLVM IR (-O2):
%struct.ttrie__obj = type { i32 }
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
define i32 @check_missing(i8* nocapture %0, %struct.ttrie__obj* %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%7 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = call i32 @getline(i8** %3, i64* %4, i32* %8)
%12 = icmp eq i32 %11, -1
br i1 %12, label %33, label %13
13: ; preds = %10
%14 = bitcast i64* %5 to i8*
br label %18
15: ; preds = %2
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %13, %18
%19 = phi i32 [ %11, %13 ], [ %31, %18 ]
%20 = phi i32 [ 0, %13 ], [ %30, %18 ]
%21 = load i8*, i8** %3
%22 = add nsw i32 %19, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 0, i8* %24
%25 = load i8*, i8** %3
%26 = call i32 @ttrie__get(%struct.ttrie__obj* %1, i8* %25, i32 %19, i64* %5)
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = add nuw nsw i32 %20, 1
%31 = call i32 @getline(i8** %3, i64* %4, i32* %8)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %18
33: ; preds = %18, %10
%34 = phi i32 [ 0, %10 ], [ %30, %18 ]
%35 = call i32 @fclose(i32* %8)
%36 = load i8*, i8** %3
%37 = call i32 @free(i8* %36)
ret i32 %34
}