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

/* Variables and functions */
int PATH_MAX;
long get_syscall_params(int, long *);
int /*<<< orphan*/ get_syscall_str(long, char *, int);
int /*<<< orphan*/ handle_open_common(long, char *);
void handle_open() {
  long params[3];
  long rc = get_syscall_params(3, params);
  char path[PATH_MAX];
  get_syscall_str(params[0], path, sizeof(path));
  handle_open_common(rc, path);
}


x86 assembly (clang, -O0):
<handle_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x3,%edi
lea    -0x20(%rbp),%rsi
call   1050 <get_syscall_params@plt>
mov    %rax,-0x28(%rbp)
mov    0x2e9f(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x40(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
call   1040 <get_syscall_str@plt>
mov    -0x40(%rbp),%rsi
mov    -0x28(%rbp),%rdi
call   1030 <handle_open_common@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_open>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    -0x30(%rbp),%rsi
mov    $0x3,%edi
call   1050 <get_syscall_params@plt>
mov    %rax,%r14
mov    %rsp,%r15
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rdx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    -0x30(%rbp),%rdi
mov    %rbx,%rsi
call   1040 <get_syscall_str@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <handle_open_common@plt>
mov    %r15,%rsp
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
define void @handle_open() {
%1 = alloca [3 x i64]
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 0, i64 0
%6 = call i64 @get_syscall_params(i32 3, i64* %5)
store i64 %6, i64* %2
%7 = load i32, i32* @PATH_MAX
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %3
%10 = alloca i8, i64 %8
store i64 %8, i64* %4
%11 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 0, i64 0
%12 = load i64, i64* %11
%13 = trunc i64 %8 to i32
%14 = call i32 @get_syscall_str(i64 %12, i8* %10, i32 %13)
%15 = load i64, i64* %2
%16 = call i32 @handle_open_common(i64 %15, i8* %10)
%17 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
define void @handle_open() {
%1 = alloca [3 x i64]
%2 = bitcast [3 x i64]* %1 to i8*
%3 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 0, i64 0
%4 = call i64 @get_syscall_params(i32 3, i64* %3)
%5 = load i32, i32* @PATH_MAX
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i8, i64 %6
%9 = load i64, i64* %3
%10 = call i32 @get_syscall_str(i64 %9, i8* %8, i32 %5)
%11 = call i32 @handle_open_common(i64 %4, i8* %8)
ret void
}