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

/* Variables and functions */
int clock_gettime_syscall_wrapper(int /*<<< orphan*/, int /*<<< orphan*/ *);
int clock_gettime_vdso_wrapper(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ record_syscall_result(struct syscall_result *, int,
                                         int /*<<< orphan*/);
int /*<<< orphan*/ syscall_prepare();
void clock_gettime_bogus_id_null(void *arg, struct syscall_result *res) {
  int err;
  syscall_prepare();
  err = arg ? clock_gettime_syscall_wrapper((clockid_t)-1, NULL)
            : clock_gettime_vdso_wrapper((clockid_t)-1, NULL);
  record_syscall_result(res, err, errno);
}


x86 assembly (clang, -O0):
<clock_gettime_bogus_id_null>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <syscall_prepare@plt>
cmpq   $0x0,-0x8(%rbp)
je     1178 <clock_gettime_bogus_id_null+0x38>
mov    $0xffffffff,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <clock_gettime_syscall_wrapper@plt>
mov    %eax,-0x18(%rbp)
jmp    1189 <clock_gettime_bogus_id_null+0x49>
mov    $0xffffffff,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <clock_gettime_vdso_wrapper@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2e43(%rip),%rax
mov    (%rax),%edx
call   1040 <record_syscall_result@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clock_gettime_bogus_id_null>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <syscall_prepare@plt>
mov    $0xffffffff,%edi
xor    %esi,%esi
test   %rbx,%rbx
je     1164 <clock_gettime_bogus_id_null+0x24>
call   1060 <clock_gettime_syscall_wrapper@plt>
jmp    1169 <clock_gettime_bogus_id_null+0x29>
call   1050 <clock_gettime_vdso_wrapper@plt>
mov    0x2e70(%rip),%rcx
mov    (%rcx),%edx
mov    %r14,%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <record_syscall_result@plt>

LLVM IR (-O0):
%struct.syscall_result = type { i32 }
@errno = global i32 0
define void @clock_gettime_bogus_id_null(i8* %0, %struct.syscall_result* %1) {
%3 = alloca i8*
%4 = alloca %struct.syscall_result*
%5 = alloca i32
store i8* %0, i8** %3
store %struct.syscall_result* %1, %struct.syscall_result** %4
%6 = call i32 (...) @syscall_prepare()
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @clock_gettime_syscall_wrapper(i32 -1, i32* null)
br label %13
11: ; preds = %2
%12 = call i32 @clock_gettime_vdso_wrapper(i32 -1, i32* null)
br label %13
13: ; preds = %11, %9
%14 = phi i32 [ %10, %9 ], [ %12, %11 ]
store i32 %14, i32* %5
%15 = load %struct.syscall_result*, %struct.syscall_result** %4
%16 = load i32, i32* %5
%17 = load i32, i32* @errno
%18 = call i32 @record_syscall_result(%struct.syscall_result* %15, i32 %16, i32 %17)
ret void
}

LLVM IR (-O2):
%struct.syscall_result = type { i32 }
@errno = global i32 0
define void @clock_gettime_bogus_id_null(i8* readnone %0, %struct.syscall_result* %1) {
%3 = tail call i32 (...) @syscall_prepare()
%4 = icmp eq i8* %0, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @clock_gettime_syscall_wrapper(i32 -1, i32* null)
br label %9
7: ; preds = %2
%8 = tail call i32 @clock_gettime_vdso_wrapper(i32 -1, i32* null)
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ %6, %5 ], [ %8, %7 ]
%11 = load i32, i32* @errno
%12 = tail call i32 @record_syscall_result(%struct.syscall_result* %1, i32 %10, i32 %11)
ret void
}