#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 */
uintptr_t syscall(int, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t,
                  uintptr_t);
uintptr_t syz_open_dev(uintptr_t, uintptr_t, uintptr_t);
uintptr_t execute_syscall(int nr, uintptr_t a0, uintptr_t a1, uintptr_t a2,
                          uintptr_t a3, uintptr_t a4, uintptr_t a5,
                          uintptr_t a6, uintptr_t a7, uintptr_t a8) {
  switch (nr) {
  default:
    return syscall(nr, a0, a1, a2, a3, a4, a5);
  case 1000002:
    return syz_open_dev(a0, a1, a2);
  }
}


x86 assembly (clang, -O0):
<execute_syscall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0xc(%rbp),%eax
sub    $0xf4242,%eax
je     118f <execute_syscall+0x6f>
jmp    1162 <execute_syscall+0x42>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    0x10(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <syscall@plt>
mov    %rax,-0x8(%rbp)
jmp    11a4 <execute_syscall+0x84>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <syz_open_dev@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_syscall>:
cmp    $0xf4242,%edi
jne    1136 <execute_syscall+0x16>
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
jmp    1030 <syz_open_dev@plt>
jmp    1040 <syscall@plt>

LLVM IR (-O0):
define i64 @execute_syscall(i32 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6, i64 %7, i64 %8, i64 %9) {
%11 = alloca i64
%12 = alloca i32
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca i64
%20 = alloca i64
%21 = alloca i64
store i32 %0, i32* %12
store i64 %1, i64* %13
store i64 %2, i64* %14
store i64 %3, i64* %15
store i64 %4, i64* %16
store i64 %5, i64* %17
store i64 %6, i64* %18
store i64 %7, i64* %19
store i64 %8, i64* %20
store i64 %9, i64* %21
%22 = load i32, i32* %12
switch i32 %22, label %23 [
i32 1000002, label %32
]
23: ; preds = %10
%24 = load i32, i32* %12
%25 = load i64, i64* %13
%26 = load i64, i64* %14
%27 = load i64, i64* %15
%28 = load i64, i64* %16
%29 = load i64, i64* %17
%30 = load i64, i64* %18
%31 = call i64 @syscall(i32 %24, i64 %25, i64 %26, i64 %27, i64 %28, i64 %29, i64 %30)
store i64 %31, i64* %11
br label %37
32: ; preds = %10
%33 = load i64, i64* %13
%34 = load i64, i64* %14
%35 = load i64, i64* %15
%36 = call i64 @syz_open_dev(i64 %33, i64 %34, i64 %35)
store i64 %36, i64* %11
br label %37
37: ; preds = %32, %23
%38 = load i64, i64* %11
ret i64 %38
}

LLVM IR (-O2):
define i64 @execute_syscall(i32 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6, i64 %7, i64 %8, i64 %9) {
%11 = icmp eq i32 %0, 1000002
br i1 %11, label %14, label %12
12: ; preds = %10
%13 = tail call i64 @syscall(i32 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6)
br label %16
14: ; preds = %10
%15 = tail call i64 @syz_open_dev(i64 %1, i64 %2, i64 %3)
br label %16
16: ; preds = %14, %12
%17 = phi i64 [ %15, %14 ], [ %13, %12 ]
ret i64 %17
}