#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_signo;
  int si_pid;
};
typedef TYPE_1__ siginfo_t;

/* Variables and functions */
scalar_t__ SIGCHLD;
int /*<<< orphan*/ printf(char *, scalar_t__, ...);
void handler2(int sig, siginfo_t *info, void *param) {
  if (info->si_signo == SIGCHLD) {
    printf("handler2() : SIGCHLD from %d\n", info->si_pid);
  }
  printf("handler2() : %d from %d\n", info->si_signo, info->si_pid);
}


x86 assembly (clang, -O0):
<handler2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2eb7(%rip),%rcx
cmp    (%rcx),%rax
jne    1150 <handler2+0x40>
mov    -0x10(%rbp),%rax
movslq 0x8(%rax),%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edx
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handler2>:
push   %rbx
mov    %rsi,%rbx
mov    (%rsi),%rsi
mov    0x2eca(%rip),%rax
cmp    (%rax),%rsi
jne    1138 <handler2+0x28>
movslq 0x8(%rbx),%rsi
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%rsi
mov    0x8(%rbx),%edx
lea    0xedc(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i32 }
@SIGCHLD = global i64 0
@.str = [30 x i8] c"handler2() : SIGCHLD from %d\0A\00"
@.str.1 = [25 x i8] c"handler2() : %d from %d\0A\00"
define void @handler2(i32 %0, %struct.TYPE_3__* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.TYPE_3__*
%6 = alloca i8*
store i32 %0, i32* %4
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %5
store i8* %2, i8** %6
%7 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%9 = load i64, i64* %8
%10 = load i64, i64* @SIGCHLD
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %18
12: ; preds = %3
%13 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = sext i32 %15 to i64
%17 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 %16)
br label %18
18: ; preds = %12, %3
%19 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 0
%21 = load i64, i64* %20
%22 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %22, i32 0, i32 1
%24 = load i32, i32* %23
%25 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %21, i32 %24)
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i32 }
@SIGCHLD = global i64 0
@.str = [30 x i8] c"handler2() : SIGCHLD from %d\0A\00"
@.str.1 = [25 x i8] c"handler2() : %d from %d\0A\00"
define void @handler2(i32 %0, %struct.TYPE_3__* nocapture %1, i8* nocapture readnone %2) {
%4 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%5 = load i64, i64* %4
%6 = load i64, i64* @SIGCHLD
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %14
8: ; preds = %3
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = sext i32 %10 to i64
%12 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 %11)
%13 = load i64, i64* %4
br label %14
14: ; preds = %8, %3
%15 = phi i64 [ %13, %8 ], [ %5, %3 ]
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%17 = load i32, i32* %16
%18 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 %15, i32 %17)
ret void
}