#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 */

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ error(char *, char const *);
int /*<<< orphan*/ gensym(char *);
int /*<<< orphan*/ glob_evalfile(int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/);
int open_via_path(char const *, char const *, char *, char *, char **, int,
                  int /*<<< orphan*/);
void openit(const char *dirname, const char *filename) {
  char dirbuf[1000], *nameptr;
  int fd = open_via_path(dirname, filename, "", dirbuf, &nameptr, 1000, 0);
  if (fd >= 0) {
    close(fd);
    glob_evalfile(0, gensym(nameptr), gensym(dirbuf));
  } else
    error("%s: can't open", filename);
}


x86 assembly (clang, -O0):
<openit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x400(%rbp),%rcx
lea    0xe95(%rip),%rdx
lea    -0x408(%rbp),%r8
mov    $0x3e8,%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
call   1050 <open_via_path@plt>
mov    %eax,-0x40c(%rbp)
cmpl   $0x0,-0x40c(%rbp)
jl     11e4 <openit+0x94>
mov    -0x40c(%rbp),%edi
call   1040 <close@plt>
mov    -0x408(%rbp),%rdi
call   1030 <gensym@plt>
mov    %eax,-0x410(%rbp)
lea    -0x400(%rbp),%rdi
call   1030 <gensym@plt>
mov    -0x410(%rbp),%esi
mov    %eax,%edx
xor    %edi,%edi
call   1060 <glob_evalfile@plt>
jmp    11f4 <openit+0xa4>
mov    -0x10(%rbp),%rsi
lea    0xe11(%rip),%rdi
call   1070 <error@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openit>:
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%rbx
movl   $0x0,(%rsp)
lea    0xea5(%rip),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    $0x3e8,%r9d
call   1050 <open_via_path@plt>
test   %eax,%eax
js     11ac <openit+0x5c>
mov    %eax,%edi
call   1040 <close@plt>
mov    0x8(%rsp),%rdi
call   1030 <gensym@plt>
mov    %eax,%ebx
lea    0x10(%rsp),%rdi
call   1030 <gensym@plt>
xor    %edi,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   1060 <glob_evalfile@plt>
jmp    11bb <openit+0x6b>
lea    0xe4d(%rip),%rdi
mov    %rbx,%rsi
call   1070 <error@plt>
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [15 x i8] c"%s: can't open\00"
define void @openit(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [1000 x i8]
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%11 = call i32 @open_via_path(i8* %8, i8* %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %10, i8** %6, i32 1000, i32 0)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i32, i32* %7
%16 = call i32 @close(i32 %15)
%17 = load i8*, i8** %6
%18 = call i32 @gensym(i8* %17)
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%20 = call i32 @gensym(i8* %19)
%21 = call i32 @glob_evalfile(i32 0, i32 %18, i32 %20)
br label %25
22: ; preds = %2
%23 = load i8*, i8** %4
%24 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %22, %14
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [15 x i8] c"%s: can't open\00"
define void @openit(i8* %0, i8* %1) {
%3 = alloca [1000 x i8]
%4 = alloca i8*
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = bitcast i8** %4 to i8*
%7 = call i32 @open_via_path(i8* %0, i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %5, i8** %4, i32 1000, i32 0)
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = call i32 @close(i32 %7)
%11 = load i8*, i8** %4
%12 = call i32 @gensym(i8* %11)
%13 = call i32 @gensym(i8* %5)
%14 = call i32 @glob_evalfile(i32 0, i32 %12, i32 %13)
br label %17
15: ; preds = %2
%16 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %17
17: ; preds = %15, %9
ret void
}