int __open64_2(const char *path, int flags) {
  int res;
  res = p___open64_2(path, flags);
  dprint(4, check_name(path), "%s(%s, %d) => %d", __FUNCTION__, path, flags,
         res);
  if (check_name(path) && add_fd(res)) {
    dprint(2, check_name(path), "%s(error line %d)", __FUNCTION__, 293);
    exit(1);
  }
  return res;
}


x86 assembly (clang, -O0):
<__open64_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1030 <p___open64_2@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1070 <check_name@plt>
mov    %eax,%esi
mov    -0x8(%rbp),%r8
mov    -0xc(%rbp),%r9d
mov    -0x10(%rbp),%eax
mov    $0x4,%edi
lea    0xe6c(%rip),%rdx
lea    0xe76(%rip),%rcx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1060 <dprint@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1070 <check_name@plt>
cmp    $0x0,%eax
je     1203 <__open64_2+0xb3>
mov    -0x10(%rbp),%edi
mov    $0x0,%al
call   1050 <add_fd@plt>
cmp    $0x0,%eax
je     1203 <__open64_2+0xb3>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1070 <check_name@plt>
mov    %eax,%esi
mov    $0x2,%edi
lea    0xe37(%rip),%rdx
lea    0xe25(%rip),%rcx
mov    $0x125,%r8d
mov    $0x0,%al
call   1060 <dprint@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__open64_2>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <p___open64_2@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <check_name@plt>
mov    %r14d,(%rsp)
lea    0xe84(%rip),%rdx
lea    0xe8e(%rip),%rcx
mov    $0x4,%edi
mov    %eax,%esi
mov    %rbx,%r8
mov    %ebp,%r9d
xor    %eax,%eax
call   1060 <dprint@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <check_name@plt>
test   %eax,%eax
je     11b3 <__open64_2+0x63>
mov    %r14d,%edi
xor    %eax,%eax
call   1050 <add_fd@plt>
test   %eax,%eax
jne    11bf <__open64_2+0x6f>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <check_name@plt>
lea    0xe4c(%rip),%rdx
lea    0xe3a(%rip),%rcx
mov    $0x2,%edi
mov    %eax,%esi
mov    $0x125,%r8d
xor    %eax,%eax
call   1060 <dprint@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"%s(%s, %d) => %d\00"
@__FUNCTION__.__open64_2 = [11 x i8] c"__open64_2\00"
@.str.1 = [18 x i8] c"%s(error line %d)\00"
define i32 @__open64_2(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @p___open64_2 to i32 (i8*, i32, ...)*)(i8* %6, i32 %7)
store i32 %8, i32* %5
%9 = load i8*, i8** %3
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @check_name to i32 (i8*, ...)*)(i8* %9)
%11 = load i8*, i8** %3
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = call i32 (i32, i32, i8*, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @dprint to i32 (i32, i32, i8*, i8*, i8*, i32, i32, ...)*)(i32 4, i32 %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.__open64_2, i64 0, i64 0), i8* %11, i32 %12, i32 %13)
%15 = load i8*, i8** %3
%16 = call i32 (i8*, ...) bitcast (i32 (...)* @check_name to i32 (i8*, ...)*)(i8* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %2
%19 = load i32, i32* %5
%20 = call i32 (i32, ...) bitcast (i32 (...)* @add_fd to i32 (i32, ...)*)(i32 %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i8*, i8** %3
%24 = call i32 (i8*, ...) bitcast (i32 (...)* @check_name to i32 (i8*, ...)*)(i8* %23)
%25 = call i32 (i32, i32, i8*, i8*, i32, ...) bitcast (i32 (...)* @dprint to i32 (i32, i32, i8*, i8*, i32, ...)*)(i32 2, i32 %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.__open64_2, i64 0, i64 0), i32 293)
unreachable
26: ; preds = %18, %2
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
@.str = [17 x i8] c"%s(%s, %d) => %d\00"
@__FUNCTION__.__open64_2 = [11 x i8] c"__open64_2\00"
@.str.1 = [18 x i8] c"%s(error line %d)\00"
define i32 @__open64_2(i8* %0, i32 %1) {
%3 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @p___open64_2 to i32 (i8*, i32, ...)*)(i8* %0, i32 %1)
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @check_name to i32 (i8*, ...)*)(i8* %0)
%5 = tail call i32 (i32, i32, i8*, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @dprint to i32 (i32, i32, i8*, i8*, i8*, i32, i32, ...)*)(i32 4, i32 %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.__open64_2, i64 0, i64 0), i8* %0, i32 %1, i32 %3)
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @check_name to i32 (i8*, ...)*)(i8* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %2
%9 = tail call i32 (i32, ...) bitcast (i32 (...)* @add_fd to i32 (i32, ...)*)(i32 %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 (i8*, ...) bitcast (i32 (...)* @check_name to i32 (i8*, ...)*)(i8* %0)
%13 = tail call i32 (i32, i32, i8*, i8*, i32, ...) bitcast (i32 (...)* @dprint to i32 (i32, i32, i8*, i8*, i32, ...)*)(i32 2, i32 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.__open64_2, i64 0, i64 0), i32 293)
tail call void @exit(i32 1)
unreachable
14: ; preds = %8, %2
ret i32 %3
}