#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 timespec {
  int tv_nsec;
  scalar_t__ tv_sec;
};
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ PTRACE_CONT;
int /*<<< orphan*/ checktargetsig(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct timespec *malloc(int);
int /*<<< orphan*/ nanosleep(struct timespec *, int /*<<< orphan*/ *);
int ptrace(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void ptrace_cont(pid_t target) {
  struct timespec *sleeptime = malloc(sizeof(struct timespec));
  sleeptime->tv_sec = 0;
  sleeptime->tv_nsec = 5000000;
  if (ptrace(PTRACE_CONT, target, NULL, NULL) == -1) {
    fprintf(stderr, "ptrace(PTRACE_CONT) failed\n");
    exit(1);
  }
  nanosleep(sleeptime, NULL);
  checktargetsig(target);
}


x86 assembly (clang, -O0):
<ptrace_cont>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x4c4b40,(%rax)
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1060 <ptrace@plt>
cmp    $0xffffffff,%eax
jne    11cf <ptrace_cont+0x6f>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <nanosleep@plt>
mov    -0x4(%rbp),%edi
call   1070 <checktargetsig@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptrace_cont>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movq   $0x0,0x8(%rax)
movl   $0x4c4b40,(%rax)
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    %ebp,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1060 <ptrace@plt>
cmp    $0xffffffff,%eax
je     11b0 <ptrace_cont+0x50>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <nanosleep@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <checktargetsig@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
@PTRACE_CONT = global i32 0
@stderr = global i32 0
@.str = [28 x i8] c"ptrace(PTRACE_CONT) failed\0A\00"
define void @ptrace_cont(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.timespec*
store i32 %0, i32* %2
%4 = call %struct.timespec* @malloc(i32 16)
store %struct.timespec* %4, %struct.timespec** %3
%5 = load %struct.timespec*, %struct.timespec** %3
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
store i64 0, i64* %6
%7 = load %struct.timespec*, %struct.timespec** %3
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
store i32 5000000, i32* %8
%9 = load i32, i32* @PTRACE_CONT
%10 = load i32, i32* %2
%11 = call i32 @ptrace(i32 %9, i32 %10, i32* null, i32* null)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %1
%18 = load %struct.timespec*, %struct.timespec** %3
%19 = call i32 @nanosleep(%struct.timespec* %18, i32* null)
%20 = load i32, i32* %2
%21 = call i32 @checktargetsig(i32 %20)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
@PTRACE_CONT = global i32 0
@stderr = global i32 0
@.str = [28 x i8] c"ptrace(PTRACE_CONT) failed\0A\00"
define void @ptrace_cont(i32 %0) {
%2 = tail call %struct.timespec* @malloc(i32 16)
%3 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
store i64 0, i64* %3
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
store i32 5000000, i32* %4
%5 = load i32, i32* @PTRACE_CONT
%6 = tail call i32 @ptrace(i32 %5, i32 %0, i32* null, i32* null)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %1
%13 = tail call i32 @nanosleep(%struct.timespec* %2, i32* null)
%14 = tail call i32 @checktargetsig(i32 %0)
ret void
}