#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 pt_regs {
  int /*<<< orphan*/ rip;
};
struct iovec {
  int member_1;
  struct pt_regs *member_0;
};
typedef int /*<<< orphan*/ regs;

/* Variables and functions */
int /*<<< orphan*/ NT_PRSTATUS;
int /*<<< orphan*/ PTRACE_GETREGSET;
int /*<<< orphan*/ memset(struct pt_regs *, int /*<<< orphan*/, int);
int /*<<< orphan*/ ptrace(int /*<<< orphan*/, int, int /*<<< orphan*/,
                          struct iovec *);
void resume_next(int pid) {
  struct pt_regs regs;
  memset(&regs, 0, sizeof(regs));
  struct iovec io = {&regs, sizeof(regs)};
  ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &io);
  regs.rip++;
}


x86 assembly (clang, -O0):
<resume_next>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
lea    -0x8(%rbp),%rax
mov    %eax,-0x18(%rbp)
mov    $0x4,%eax
mov    %rax,-0x10(%rbp)
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
mov    0x2e9a(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rcx
call   1040 <ptrace@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<resume_next>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    %r14d,0x8(%rsp)
movq   $0x4,0x10(%rsp)
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
mov    0x2e9f(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %ebx,%esi
call   1040 <ptrace@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.pt_regs = type { i32 }
%struct.iovec = type { i32, %struct.pt_regs* }
@PTRACE_GETREGSET = global i32 0
@NT_PRSTATUS = global i32 0
define void @resume_next(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.pt_regs
%4 = alloca %struct.iovec
store i32 %0, i32* %2
%5 = call i32 @memset(%struct.pt_regs* %3, i32 0, i32 4)
%6 = getelementptr inbounds %struct.iovec, %struct.iovec* %4, i32 0, i32 0
%7 = ptrtoint %struct.pt_regs* %3 to i32
store i32 %7, i32* %6
%8 = getelementptr inbounds %struct.iovec, %struct.iovec* %4, i32 0, i32 1
store %struct.pt_regs* inttoptr (i64 4 to %struct.pt_regs*), %struct.pt_regs** %8
%9 = load i32, i32* @PTRACE_GETREGSET
%10 = load i32, i32* %2
%11 = load i32, i32* @NT_PRSTATUS
%12 = call i32 @ptrace(i32 %9, i32 %10, i32 %11, %struct.iovec* %4)
%13 = getelementptr inbounds %struct.pt_regs, %struct.pt_regs* %3, i32 0, i32 0
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1
store i32 %15, i32* %13
ret void
}

LLVM IR (-O2):
%struct.pt_regs = type { i32 }
%struct.iovec = type { i32, %struct.pt_regs* }
@PTRACE_GETREGSET = global i32 0
@NT_PRSTATUS = global i32 0
define void @resume_next(i32 %0) {
%2 = alloca %struct.pt_regs
%3 = alloca %struct.iovec
%4 = bitcast %struct.pt_regs* %2 to i8*
%5 = call i32 @memset(%struct.pt_regs* %2, i32 0, i32 4)
%6 = bitcast %struct.iovec* %3 to i8*
%7 = getelementptr inbounds %struct.iovec, %struct.iovec* %3, i64 0, i32 0
%8 = ptrtoint %struct.pt_regs* %2 to i64
%9 = trunc i64 %8 to i32
store i32 %9, i32* %7
%10 = getelementptr inbounds %struct.iovec, %struct.iovec* %3, i64 0, i32 1
store %struct.pt_regs* inttoptr (i64 4 to %struct.pt_regs*), %struct.pt_regs** %10
%11 = load i32, i32* @PTRACE_GETREGSET
%12 = load i32, i32* @NT_PRSTATUS
%13 = call i32 @ptrace(i32 %11, i32 %0, i32 %12, %struct.iovec* %3)
ret void
}