#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*/ extract_paths(char const *, char **, char **, char **);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ query_tagfile(char *, int /*<<< orphan*/ *);
int query_file(const char *target) {
  char *path, *name, *tagfile;
  if (!extract_paths(target, &path, &name, &tagfile)) {
    return 0;
  }
  FILE *ftags;
  if ((ftags = fopen(tagfile, "rb")) == NULL) {
    return 0;
  }
  query_tagfile(name, ftags);
  fclose(ftags);
  free(name);
  name = NULL;
  free(path);
  path = NULL;
  free(tagfile);
  tagfile = NULL;
  return 1;
}


x86 assembly (clang, -O0):
<query_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1070 <extract_paths@plt>
cmp    $0x0,%eax
jne    1186 <query_file+0x36>
movl   $0x0,-0x4(%rbp)
jmp    1200 <query_file+0xb0>
mov    -0x28(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11b0 <query_file+0x60>
movl   $0x0,-0x4(%rbp)
jmp    1200 <query_file+0xb0>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <query_tagfile@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<query_file>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
lea    0x8(%rsp),%rcx
call   1070 <extract_paths@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     11ce <query_file+0x7e>
mov    0x8(%rsp),%rdi
lea    0xe86(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11ce <query_file+0x7e>
mov    %rax,%rbx
mov    (%rsp),%rdi
mov    %rax,%rsi
call   1050 <query_tagfile@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
movq   $0x0,(%rsp)
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
movq   $0x0,0x10(%rsp)
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
define i32 @query_file(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @extract_paths(i8* %8, i8** %4, i8** %5, i8** %6)
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %1
store i32 0, i32* %2
br label %29
12: ; preds = %1
%13 = load i8*, i8** %6
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %7
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 0, i32* %2
br label %29
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = load i32*, i32** %7
%20 = call i32 @query_tagfile(i8* %18, i32* %19)
%21 = load i32*, i32** %7
%22 = call i32 @fclose(i32* %21)
%23 = load i8*, i8** %5
%24 = call i32 @free(i8* %23)
store i8* null, i8** %5
%25 = load i8*, i8** %4
%26 = call i32 @free(i8* %25)
store i8* null, i8** %4
%27 = load i8*, i8** %6
%28 = call i32 @free(i8* %27)
store i8* null, i8** %6
store i32 1, i32* %2
br label %29
29: ; preds = %17, %16, %11
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
define i32 @query_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i8** %2 to i8*
%6 = bitcast i8** %3 to i8*
%7 = bitcast i8** %4 to i8*
%8 = call i32 @extract_paths(i8* %0, i8** %2, i8** %3, i8** %4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %24, label %10
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %24, label %14
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = call i32 @query_tagfile(i8* %15, i32* %12)
%17 = call i32 @fclose(i32* %12)
%18 = load i8*, i8** %3
%19 = call i32 @free(i8* %18)
store i8* null, i8** %3
%20 = load i8*, i8** %2
%21 = call i32 @free(i8* %20)
store i8* null, i8** %2
%22 = load i8*, i8** %4
%23 = call i32 @free(i8* %22)
br label %24
24: ; preds = %14, %10, %1
%25 = phi i32 [ 0, %1 ], [ 1, %14 ], [ 0, %10 ]
ret i32 %25
}