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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int find_parent(int /*<<< orphan*/ *, char *, char *, int);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int seek_config_path(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strrchr(char *, char);
int /*<<< orphan*/ trim_leading(char *, int);
int seek_definition(FILE *f, char *config_path) {
  int success;
  fseek(f, 16, SEEK_SET);
  success = seek_config_path(f, config_path);
  if (success >= 0)
    return success;
  int i;
  char containing[2048];
  char parent[2048];
  char value[2048];
  strncpy(containing, config_path, sizeof(containing));
  *(strrchr(containing, '>') - 1) = 0;
  for (i = strlen(containing) - 1; i >= 0 && containing[i] == ' '; i--)
    containing[i] = 0;
  fseek(f, 16, SEEK_SET);
  success = seek_config_path(f, containing);
  if (success < 0)
    return success;
  success = find_parent(f, containing, parent, sizeof(parent));
  if (success) {
    return success;
  }
  strncpy(value, strrchr(config_path, '>') + 1, sizeof(value));
  trim_leading(value, sizeof(value));
  strcat(parent, " >> ");
  strcat(parent, value);
  return seek_definition(f, parent);
}


x86 assembly (clang, -O0):
<seek_definition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1830,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e32(%rip),%rax
mov    (%rax),%edx
mov    $0x10,%esi
call   10a0 <fseek@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <seek_config_path@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11df <seek_definition+0x4f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1363 <seek_definition+0x1d3>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x800,%edx
call   1030 <strncpy@plt>
lea    -0x820(%rbp),%rdi
mov    $0x3e,%esi
call   1060 <strrchr@plt>
movb   $0x0,-0x1(%rax)
lea    -0x820(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x20(%rbp)
mov    %al,-0x1821(%rbp)
jl     1245 <seek_definition+0xb5>
movslq -0x20(%rbp),%rax
movsbl -0x820(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
sete   %al
mov    %al,-0x1821(%rbp)
mov    -0x1821(%rbp),%al
test   $0x1,%al
jne    1258 <seek_definition+0xc8>
jmp    1272 <seek_definition+0xe2>
movslq -0x20(%rbp),%rax
movb   $0x0,-0x820(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    121b <seek_definition+0x8b>
mov    -0x10(%rbp),%rdi
mov    0x2d63(%rip),%rax
mov    (%rax),%edx
mov    $0x10,%esi
call   10a0 <fseek@plt>
mov    -0x10(%rbp),%rdi
lea    -0x820(%rbp),%rsi
call   1090 <seek_config_path@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    12b1 <seek_definition+0x121>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1363 <seek_definition+0x1d3>
mov    -0x10(%rbp),%rdi
lea    -0x820(%rbp),%rsi
lea    -0x1020(%rbp),%rdx
mov    $0x800,%ecx
call   1070 <find_parent@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     12e5 <seek_definition+0x155>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1363 <seek_definition+0x1d3>
lea    -0x1820(%rbp),%rax
mov    %rax,-0x1830(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x3e,%esi
call   1060 <strrchr@plt>
mov    -0x1830(%rbp),%rdi
mov    %rax,%rsi
add    $0x1,%rsi
mov    $0x800,%edx
call   1030 <strncpy@plt>
lea    -0x1820(%rbp),%rdi
mov    $0x800,%esi
call   1040 <trim_leading@plt>
lea    -0x1020(%rbp),%rdi
lea    0xcc8(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0x1020(%rbp),%rdi
lea    -0x1820(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   1080 <seek_definition@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seek_definition>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1808,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e35(%rip),%r12
mov    (%r12),%edx
mov    $0x10,%esi
call   10a0 <fseek@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <seek_config_path@plt>
test   %eax,%eax
js     11d7 <seek_definition+0x47>
add    $0x1808,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x800,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
mov    $0x3e,%esi
call   1060 <strrchr@plt>
movb   $0x0,-0x1(%rax)
mov    %r15,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1227 <seek_definition+0x97>
mov    %eax,%eax
add    $0x1,%rax
nopl   (%rax)
lea    -0x2(%rax),%ecx
cmpb   $0x20,(%rsp,%rcx,1)
jne    1227 <seek_definition+0x97>
movb   $0x0,(%rsp,%rcx,1)
add    $0xffffffffffffffff,%rax
cmp    $0x1,%rax
ja     1210 <seek_definition+0x80>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x10,%esi
call   10a0 <fseek@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1090 <seek_config_path@plt>
test   %eax,%eax
js     11c8 <seek_definition+0x38>
mov    %rsp,%rsi
lea    0x800(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x800,%ecx
call   1070 <find_parent@plt>
test   %eax,%eax
jne    11c8 <seek_definition+0x38>
mov    %r14,%rdi
mov    $0x3e,%esi
call   1060 <strrchr@plt>
lea    0x1(%rax),%rsi
lea    0x1000(%rsp),%r14
mov    %r14,%rdi
mov    $0x800,%edx
call   1030 <strncpy@plt>
mov    %r14,%rdi
mov    $0x800,%esi
call   1040 <trim_leading@plt>
lea    0xd5f(%rip),%rsi
lea    0x800(%rsp),%r15
mov    %r15,%rdi
call   10b0 <strcat@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   10b0 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <seek_definition@plt>
jmp    11c8 <seek_definition+0x38>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [5 x i8] c" >> \00"
define i32 @seek_definition(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [2048 x i8]
%9 = alloca [2048 x i8]
%10 = alloca [2048 x i8]
store i32* %0, i32** %4
store i8* %1, i8** %5
%11 = load i32*, i32** %4
%12 = load i32, i32* @SEEK_SET
%13 = call i32 @fseek(i32* %11, i32 16, i32 %12)
%14 = load i32*, i32** %4
%15 = load i8*, i8** %5
%16 = call i32 @seek_config_path(i32* %14, i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = load i32, i32* %6
store i32 %20, i32* %3
br label %86
21: ; preds = %2
%22 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%23 = load i8*, i8** %5
%24 = call i32 @strncpy(i8* %22, i8* %23, i32 2048)
%25 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%26 = call i8* @strrchr(i8* %25, i8 signext 62)
%27 = getelementptr inbounds i8, i8* %26, i64 -1
store i8 0, i8* %27
%28 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%29 = call i32 @strlen(i8* %28)
%30 = sub nsw i32 %29, 1
store i32 %30, i32* %7
br label %31
31: ; preds = %47, %21
%32 = load i32, i32* %7
%33 = icmp sge i32 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %31
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 32
br label %41
41: ; preds = %34, %31
%42 = phi i1 [ false, %31 ], [ %40, %34 ]
br i1 %42, label %43, label %50
43: ; preds = %41
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 %45
store i8 0, i8* %46
br label %47
47: ; preds = %43
%48 = load i32, i32* %7
%49 = add nsw i32 %48, -1
store i32 %49, i32* %7
br label %31
50: ; preds = %41
%51 = load i32*, i32** %4
%52 = load i32, i32* @SEEK_SET
%53 = call i32 @fseek(i32* %51, i32 16, i32 %52)
%54 = load i32*, i32** %4
%55 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%56 = call i32 @seek_config_path(i32* %54, i8* %55)
store i32 %56, i32* %6
%57 = load i32, i32* %6
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %50
%60 = load i32, i32* %6
store i32 %60, i32* %3
br label %86
61: ; preds = %50
%62 = load i32*, i32** %4
%63 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%64 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%65 = call i32 @find_parent(i32* %62, i8* %63, i8* %64, i32 2048)
store i32 %65, i32* %6
%66 = load i32, i32* %6
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %61
%69 = load i32, i32* %6
store i32 %69, i32* %3
br label %86
70: ; preds = %61
%71 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%72 = load i8*, i8** %5
%73 = call i8* @strrchr(i8* %72, i8 signext 62)
%74 = getelementptr inbounds i8, i8* %73, i64 1
%75 = call i32 @strncpy(i8* %71, i8* %74, i32 2048)
%76 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%77 = call i32 @trim_leading(i8* %76, i32 2048)
%78 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%79 = call i32 @strcat(i8* %78, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%80 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%81 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%82 = call i32 @strcat(i8* %80, i8* %81)
%83 = load i32*, i32** %4
%84 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%85 = call i32 @seek_definition(i32* %83, i8* %84)
store i32 %85, i32* %3
br label %86
86: ; preds = %70, %68, %59, %19
%87 = load i32, i32* %3
ret i32 %87
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [5 x i8] c" >> \00"
define i32 @seek_definition(i32* %0, i8* %1) {
%3 = alloca [2048 x i8]
%4 = alloca [2048 x i8]
%5 = alloca [2048 x i8]
%6 = load i32, i32* @SEEK_SET
%7 = tail call i32 @fseek(i32* %0, i32 16, i32 %6)
%8 = tail call i32 @seek_config_path(i32* %0, i8* %1)
%9 = icmp sgt i32 %8, -1
br i1 %9, label %48, label %10
10: ; preds = %2
%11 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%14 = call i32 @strncpy(i8* %11, i8* %1, i32 2048)
%15 = call i8* @strrchr(i8* %11, i8 signext 62)
%16 = getelementptr inbounds i8, i8* %15, i64 -1
store i8 0, i8* %16
%17 = call i32 @strlen(i8* %11)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %10
%20 = zext i32 %17 to i64
br label %21
21: ; preds = %19, %28
%22 = phi i64 [ %20, %19 ], [ %23, %28 ]
%23 = add nsw i64 %22, -1
%24 = and i64 %23, 4294967295
%25 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 32
br i1 %27, label %28, label %30
28: ; preds = %21
store i8 0, i8* %25
%29 = icmp ugt i64 %22, 1
br i1 %29, label %21, label %30
30: ; preds = %21, %28, %10
%31 = load i32, i32* @SEEK_SET
%32 = call i32 @fseek(i32* %0, i32 16, i32 %31)
%33 = call i32 @seek_config_path(i32* %0, i8* %11)
%34 = icmp slt i32 %33, 0
br i1 %34, label %46, label %35
35: ; preds = %30
%36 = call i32 @find_parent(i32* %0, i8* %11, i8* %12, i32 2048)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %46
38: ; preds = %35
%39 = call i8* @strrchr(i8* dereferenceable(1) %1, i8 signext 62)
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = call i32 @strncpy(i8* %13, i8* %40, i32 2048)
%42 = call i32 @trim_leading(i8* %13, i32 2048)
%43 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%44 = call i32 @strcat(i8* %12, i8* %13)
%45 = call i32 @seek_definition(i32* %0, i8* %12)
br label %46
46: ; preds = %35, %30, %38
%47 = phi i32 [ %45, %38 ], [ %33, %30 ], [ %36, %35 ]
br label %48
48: ; preds = %2, %46
%49 = phi i32 [ %47, %46 ], [ %8, %2 ]
ret i32 %49
}