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

/* Variables and functions */
int /*<<< orphan*/ PTRACE_POKEUSER;
int /*<<< orphan*/ __NR_getpid;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int ptrace(int /*<<< orphan*/, int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
void syscall_cancel(pid_t pid) {
  int err;
  err = ptrace(PTRACE_POKEUSER, pid, (8 * 10), __NR_getpid);
  if (err == -1) {
    fprintf(stderr, "ptproxy: couldn't cancel syscall: %s\n", strerror(errno));
    exit(1);
  }
}


x86 assembly (clang, -O0):
<syscall_cancel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
mov    0x2e8a(%rip),%rax
mov    (%rax),%ecx
mov    $0x50,%edx
call   1040 <ptrace@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11ad <syscall_cancel+0x6d>
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0xc(%rbp),%edi
mov    %rax,%rdx
lea    0xe62(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<syscall_cancel>:
push   %rbx
mov    %edi,%esi
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
mov    0x2e95(%rip),%rax
mov    (%rax),%ecx
mov    $0x50,%edx
call   1040 <ptrace@plt>
cmp    $0xffffffff,%eax
je     1166 <syscall_cancel+0x26>
pop    %rbx
ret
mov    0x2e63(%rip),%rax
mov    (%rax),%ebx
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe7c(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@PTRACE_POKEUSER = global i32 0
@__NR_getpid = global i32 0
@stderr = global i32 0
@.str = [38 x i8] c"ptproxy: couldn't cancel syscall: %s\0A\00"
@errno = global i32 0
define void @syscall_cancel(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* @PTRACE_POKEUSER
%5 = load i32, i32* %2
%6 = load i32, i32* @__NR_getpid
%7 = call i32 @ptrace(i32 %4, i32 %5, i32 80, i32 %6)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %1
ret void
}

LLVM IR (-O2):
@PTRACE_POKEUSER = global i32 0
@__NR_getpid = global i32 0
@stderr = global i32 0
@.str = [38 x i8] c"ptproxy: couldn't cancel syscall: %s\0A\00"
@errno = global i32 0
define void @syscall_cancel(i32 %0) {
%2 = load i32, i32* @PTRACE_POKEUSER
%3 = load i32, i32* @__NR_getpid
%4 = tail call i32 @ptrace(i32 %2, i32 %0, i32 80, i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = tail call i8* @strerror(i32 %8)
%10 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %1
ret void
}