#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  scalar_t__ si_code;
  scalar_t__ si_pid;
};
typedef TYPE_1__ siginfo_t;

/* Variables and functions */
scalar_t__ CLD_DUMPED;
scalar_t__ CLD_EXITED;
scalar_t__ CLD_KILLED;
int SIGCHLD;
int /*<<< orphan*/ printf(char *, scalar_t__);
void sig_cld(int signo, siginfo_t *info, void *param) {
  int status = 0;
  if (signo == SIGCHLD) {
    if (info->si_code == CLD_EXITED || info->si_code == CLD_KILLED ||
        info->si_code == CLD_DUMPED) {
      printf("pid (auto wait in signal) = %d\n", info->si_pid);
    } else {
      printf("unknown signal code %d\n", info->si_code);
    }
  }
}


x86 assembly (clang, -O0):
<sig_cld>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eac(%rip),%rcx
cmp    (%rcx),%eax
jne    11b2 <sig_cld+0xa2>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e86(%rip),%rcx
cmp    (%rcx),%rax
je     1181 <sig_cld+0x71>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e97(%rip),%rcx
cmp    (%rcx),%rax
je     1181 <sig_cld+0x71>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e50(%rip),%rcx
cmp    (%rcx),%rax
jne    119a <sig_cld+0x8a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
jmp    11ad <sig_cld+0x9d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
jmp    11b2 <sig_cld+0xa2>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sig_cld>:
mov    0x2ec9(%rip),%rax
cmp    %edi,(%rax)
jne    1151 <sig_cld+0x41>
mov    (%rsi),%rax
mov    0x2eab(%rip),%rcx
cmp    (%rcx),%rax
je     1152 <sig_cld+0x42>
mov    0x2ec7(%rip),%rcx
cmp    (%rcx),%rax
je     1152 <sig_cld+0x42>
mov    0x2e8b(%rip),%rcx
cmp    (%rcx),%rax
je     1152 <sig_cld+0x42>
lea    0xed7(%rip),%rdi
mov    %rax,%rsi
jmp    1030 <printf@plt>
ret
mov    0x8(%rsi),%rsi
lea    0xea3(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i64 }
@SIGCHLD = global i32 0
@CLD_EXITED = global i64 0
@CLD_KILLED = global i64 0
@CLD_DUMPED = global i64 0
@.str = [32 x i8] c"pid (auto wait in signal) = %d\0A\00"
@.str.1 = [24 x i8] c"unknown signal code %d\0A\00"
define void @sig_cld(i32 %0, %struct.TYPE_3__* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.TYPE_3__*
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %5
store i8* %2, i8** %6
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = load i32, i32* @SIGCHLD
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %40
11: ; preds = %3
%12 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 0
%14 = load i64, i64* %13
%15 = load i64, i64* @CLD_EXITED
%16 = icmp eq i64 %14, %15
br i1 %16, label %29, label %17
17: ; preds = %11
%18 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %18, i32 0, i32 0
%20 = load i64, i64* %19
%21 = load i64, i64* @CLD_KILLED
%22 = icmp eq i64 %20, %21
br i1 %22, label %29, label %23
23: ; preds = %17
%24 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%25 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %24, i32 0, i32 0
%26 = load i64, i64* %25
%27 = load i64, i64* @CLD_DUMPED
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %34
29: ; preds = %23, %17, %11
%30 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %30, i32 0, i32 1
%32 = load i64, i64* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %32)
br label %39
34: ; preds = %23
%35 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%36 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %35, i32 0, i32 0
%37 = load i64, i64* %36
%38 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 %37)
br label %39
39: ; preds = %34, %29
br label %40
40: ; preds = %39, %3
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i64 }
@SIGCHLD = global i32 0
@CLD_EXITED = global i64 0
@CLD_KILLED = global i64 0
@CLD_DUMPED = global i64 0
@.str = [32 x i8] c"pid (auto wait in signal) = %d\0A\00"
@.str.1 = [24 x i8] c"unknown signal code %d\0A\00"
define void @sig_cld(i32 %0, %struct.TYPE_3__* nocapture %1, i8* nocapture readnone %2) {
%4 = load i32, i32* @SIGCHLD
%5 = icmp eq i32 %4, %0
br i1 %5, label %6, label %23
6: ; preds = %3
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%8 = load i64, i64* %7
%9 = load i64, i64* @CLD_EXITED
%10 = icmp eq i64 %8, %9
%11 = load i64, i64* @CLD_KILLED
%12 = icmp eq i64 %8, %11
%13 = select i1 %10, i1 true, i1 %12
%14 = load i64, i64* @CLD_DUMPED
%15 = icmp eq i64 %8, %14
%16 = select i1 %13, i1 true, i1 %15
br i1 %16, label %17, label %21
17: ; preds = %6
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%19 = load i64, i64* %18
%20 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %19)
br label %23
21: ; preds = %6
%22 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 %8)
br label %23
23: ; preds = %17, %21, %3
ret void
}