#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 ptrace_lwpinfo {
  int dummy;
};

/* Variables and functions */
char *decode_pl_event(struct ptrace_lwpinfo *);
char *decode_pl_flags(struct ptrace_lwpinfo *);
char *decode_wait_status(int);
int /*<<< orphan*/ printf(char *, ...);
void wait_info(int pid, int status, struct ptrace_lwpinfo *lwpinfo) {
  printf(">>>> "
         "pid %d wait %s",
         pid, decode_wait_status(status));
  if (lwpinfo != NULL) {
    printf(" event %s flags %s", decode_pl_event(lwpinfo),
           decode_pl_flags(lwpinfo));
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<wait_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <decode_wait_status@plt>
mov    -0x14(%rbp),%esi
mov    %rax,%rdx
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11aa <wait_info+0x6a>
mov    -0x10(%rbp),%rdi
call   1030 <decode_pl_event@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <decode_pl_flags@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wait_info>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %edi,%ebp
mov    %esi,%edi
call   1060 <decode_wait_status@plt>
lea    0xe9a(%rip),%rdi
mov    %ebp,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbx,%rbx
je     119e <wait_info+0x4e>
mov    %rbx,%rdi
call   1030 <decode_pl_event@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1070 <decode_pl_flags@plt>
lea    0xe83(%rip),%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <putchar@plt>

LLVM IR (-O0):
%struct.ptrace_lwpinfo = type { i32 }
@.str = [20 x i8] c">>>> pid %d wait %s\00"
@.str.1 = [19 x i8] c" event %s flags %s\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @wait_info(i32 %0, i32 %1, %struct.ptrace_lwpinfo* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.ptrace_lwpinfo*
store i32 %0, i32* %4
store i32 %1, i32* %5
store %struct.ptrace_lwpinfo* %2, %struct.ptrace_lwpinfo** %6
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = call i8* @decode_wait_status(i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %7, i8* %9)
%11 = load %struct.ptrace_lwpinfo*, %struct.ptrace_lwpinfo** %6
%12 = icmp ne %struct.ptrace_lwpinfo* %11, null
br i1 %12, label %13, label %19
13: ; preds = %3
%14 = load %struct.ptrace_lwpinfo*, %struct.ptrace_lwpinfo** %6
%15 = call i8* @decode_pl_event(%struct.ptrace_lwpinfo* %14)
%16 = load %struct.ptrace_lwpinfo*, %struct.ptrace_lwpinfo** %6
%17 = call i8* @decode_pl_flags(%struct.ptrace_lwpinfo* %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %17)
br label %19
19: ; preds = %13, %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.ptrace_lwpinfo = type { i32 }
@.str = [20 x i8] c">>>> pid %d wait %s\00"
@.str.1 = [19 x i8] c" event %s flags %s\00"
define void @wait_info(i32 %0, i32 %1, %struct.ptrace_lwpinfo* %2) {
%4 = tail call i8* @decode_wait_status(i32 %1)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %4)
%6 = icmp eq %struct.ptrace_lwpinfo* %2, null
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = tail call i8* @decode_pl_event(%struct.ptrace_lwpinfo* %2)
%9 = tail call i8* @decode_pl_flags(%struct.ptrace_lwpinfo* %2)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* %9)
br label %11
11: ; preds = %7, %3
%12 = tail call i32 @putchar(i32 10)
ret void
}