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

/* Variables and functions */
int PATH_MAX;
char *dirname(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ free(char *);
int options_parse_stream(struct option *, char const *, int /*<<< orphan*/ *);
char *realpath(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strerror(int /*<<< orphan*/);
int options_parse_file(struct option *ops, const char *pwd,
                       const char *filename) {
  char concat[PATH_MAX * 2 + 1];
  if (filename[0] != '/') {
    strcpy(concat, pwd);
    strcat(concat, "/");
    strcat(concat, filename);
  } else {
    strcpy(concat, filename);
  }
  char resolved_path[PATH_MAX];
  char *resolved;
  if (!(resolved = realpath(concat, resolved_path))) {
    fprintf(stderr, "Could not resolve '%s' ('%s').\n", concat, resolved);
    return 0;
  }
  const char *newdir = dirname(resolved);
  if (!newdir) {
    fprintf(stderr, "Could not get dirname for '%s'.\n", resolved);
    free(resolved);
    return 0;
  }
  FILE *file;
  file = fopen(resolved, "r");
  if (file == NULL) {
    fprintf(stderr, "Could not open '%s': %s.\n", resolved, strerror(errno));
    return 0;
  }
  return options_parse_stream(ops, newdir, file);
}


x86 assembly (clang, -O0):
<options_parse_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2e45(%rip),%rax
mov    (%rax),%ecx
mov    %ecx,%eax
lea    0x1(%rax,%rax,1),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1215 <options_parse_file+0x85>
mov    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x60(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10a0 <strcat@plt>
jmp    1222 <options_parse_file+0x92>
mov    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x60(%rbp),%rdi
mov    0x2dc3(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,%rsp
mov    %rax,-0x38(%rbp)
call   1070 <realpath@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    128c <options_parse_file+0xfc>
mov    -0x60(%rbp),%rdx
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rcx
lea    0xd90(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    1362 <options_parse_file+0x1d2>
mov    -0x40(%rbp),%rdi
call   1050 <dirname@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    12db <options_parse_file+0x14b>
mov    0x2d2d(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rdx
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    1362 <options_parse_file+0x1d2>
mov    -0x40(%rbp),%rdi
lea    0xd5d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1347 <options_parse_file+0x1b7>
mov    0x2cd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    0x2cbb(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rdx
mov    %rax,%rcx
lea    0xd18(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    1362 <options_parse_file+0x1d2>
mov    -0x10(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdx
call   1080 <options_parse_stream@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<options_parse_file>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rdi,%r14
mov    0x2e48(%rip),%r12
mov    (%r12),%eax
add    %eax,%eax
add    $0x1,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
cmpb   $0x2f,(%rdx)
jne    11d4 <options_parse_file+0x44>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
jmp    11f6 <options_parse_file+0x66>
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0xe1d(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <strcat@plt>
mov    (%r12),%eax
mov    %rsp,%rsi
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rsi
mov    %rsi,%rsp
mov    %rbx,%rdi
call   1070 <realpath@plt>
test   %rax,%rax
je     1252 <options_parse_file+0xc2>
mov    %rax,%r15
mov    %rax,%rdi
call   1050 <dirname@plt>
test   %rax,%rax
je     126c <options_parse_file+0xdc>
mov    %rax,%rbx
lea    0xe11(%rip),%rsi
mov    %r15,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1293 <options_parse_file+0x103>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1080 <options_parse_stream@plt>
mov    %eax,%r14d
jmp    12c3 <options_parse_file+0x133>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
lea    0xda0(%rip),%rsi
xor    %r14d,%r14d
mov    %rbx,%rdx
xor    %ecx,%ecx
jmp    12bc <options_parse_file+0x12c>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
lea    0xda6(%rip),%rsi
xor    %r14d,%r14d
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    12c3 <options_parse_file+0x133>
mov    0x2d3e(%rip),%rax
mov    (%rax),%ebx
mov    0x2d2d(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xd94(%rip),%rsi
xor    %r14d,%r14d
mov    %ebx,%edi
mov    %r15,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14d,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i32 }
@PATH_MAX = global i32 0
@.str = [2 x i8] c"/\00"
@stderr = global i32 0
@.str.1 = [32 x i8] c"Could not resolve '%s' ('%s').\0A\00"
@.str.2 = [33 x i8] c"Could not get dirname for '%s'.\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [26 x i8] c"Could not open '%s': %s.\0A\00"
@errno = global i32 0
define i32 @options_parse_file(%struct.option* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.option*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32*
store %struct.option* %0, %struct.option** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%15 = load i32, i32* @PATH_MAX
%16 = mul nsw i32 %15, 2
%17 = add nsw i32 %16, 1
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %8
%20 = alloca i8, i64 %18
store i64 %18, i64* %9
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 47
br i1 %25, label %26, label %32
26: ; preds = %3
%27 = load i8*, i8** %6
%28 = call i32 @strcpy(i8* %20, i8* %27)
%29 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%30 = load i8*, i8** %7
%31 = call i32 @strcat(i8* %20, i8* %30)
br label %35
32: ; preds = %3
%33 = load i8*, i8** %7
%34 = call i32 @strcpy(i8* %20, i8* %33)
br label %35
35: ; preds = %32, %26
%36 = load i32, i32* @PATH_MAX
%37 = zext i32 %36 to i64
%38 = alloca i8, i64 %37
store i64 %37, i64* %10
%39 = call i8* @realpath(i8* %20, i8* %38)
store i8* %39, i8** %11
%40 = icmp ne i8* %39, null
br i1 %40, label %45, label %41
41: ; preds = %35
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %11
%44 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* %43)
store i32 0, i32* %4
store i32 1, i32* %12
br label %72
45: ; preds = %35
%46 = load i8*, i8** %11
%47 = call i8* @dirname(i8* %46)
store i8* %47, i8** %13
%48 = load i8*, i8** %13
%49 = icmp ne i8* %48, null
br i1 %49, label %56, label %50
50: ; preds = %45
%51 = load i32, i32* @stderr
%52 = load i8*, i8** %11
%53 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %52)
%54 = load i8*, i8** %11
%55 = call i32 @free(i8* %54)
store i32 0, i32* %4
store i32 1, i32* %12
br label %72
56: ; preds = %45
%57 = load i8*, i8** %11
%58 = call i32* @fopen(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %58, i32** %14
%59 = load i32*, i32** %14
%60 = icmp eq i32* %59, null
br i1 %60, label %61, label %67
61: ; preds = %56
%62 = load i32, i32* @stderr
%63 = load i8*, i8** %11
%64 = load i32, i32* @errno
%65 = call i8* @strerror(i32 %64)
%66 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %63, i8* %65)
store i32 0, i32* %4
store i32 1, i32* %12
br label %72
67: ; preds = %56
%68 = load %struct.option*, %struct.option** %5
%69 = load i8*, i8** %13
%70 = load i32*, i32** %14
%71 = call i32 @options_parse_stream(%struct.option* %68, i8* %69, i32* %70)
store i32 %71, i32* %4
store i32 1, i32* %12
br label %72
72: ; preds = %67, %61, %50, %41
%73 = load i8*, i8** %8
%74 = load i32, i32* %4
ret i32 %74
}

LLVM IR (-O2):
%struct.option = type { i32 }
@PATH_MAX = global i32 0
@.str = [2 x i8] c"/\00"
@stderr = global i32 0
@.str.1 = [32 x i8] c"Could not resolve '%s' ('%s').\0A\00"
@.str.2 = [33 x i8] c"Could not get dirname for '%s'.\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [26 x i8] c"Could not open '%s': %s.\0A\00"
@errno = global i32 0
define i32 @options_parse_file(%struct.option* %0, i8* %1, i8* %2) {
%4 = load i32, i32* @PATH_MAX
%5 = shl nsw i32 %4, 1
%6 = or i32 %5, 1
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = load i8, i8* %2
%10 = icmp eq i8 %9, 47
br i1 %10, label %15, label %11
11: ; preds = %3
%12 = call i32 @strcpy(i8* %8, i8* %1)
%13 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @strcat(i8* %8, i8* %2)
br label %17
15: ; preds = %3
%16 = call i32 @strcpy(i8* %8, i8* %2)
br label %17
17: ; preds = %15, %11
%18 = load i32, i32* @PATH_MAX
%19 = zext i32 %18 to i64
%20 = alloca i8, i64 %19
%21 = call i8* @realpath(i8* %8, i8* %20)
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* null)
br label %43
26: ; preds = %17
%27 = call i8* @dirname(i8* %21)
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%32 = call i32 @free(i8* %21)
br label %43
33: ; preds = %26
%34 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %41
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %21, i8* %39)
br label %43
41: ; preds = %33
%42 = call i32 @options_parse_stream(%struct.option* %0, i8* %27, i32* %34)
br label %43
43: ; preds = %29, %41, %36, %23
%44 = phi i32 [ 0, %23 ], [ 0, %29 ], [ 0, %36 ], [ %42, %41 ]
ret i32 %44
}