#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__ {
  int si_int;
  int /*<<< orphan*/ si_pid;
};
typedef TYPE_1__ siginfo_t;

/* Variables and functions */
int /*<<< orphan*/ LOG_DEBUG;
int /*<<< orphan*/ read_shm(int /*<<< orphan*/, int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int, int, ...);
void handler(int sig, siginfo_t *info, void *ctx) {
  int shmid = 0;
  syslog(LOG_DEBUG, "daemon: handler %d %d %d", sig, info->si_int,
         info->si_pid);
  if ((shmid = info->si_int) != -1) {
    syslog(LOG_DEBUG, "daemon: from :%d  shmid :%d", info->si_pid, shmid);
    read_shm(info->si_pid, shmid);
  }
}


x86 assembly (clang, -O0):
<handler>:
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    0x2e9f(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%r8d
lea    0xea5(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11a4 <handler+0x84>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x1c(%rbp),%esi
call   1030 <read_shm@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handler>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%edx
mov    0x2eb0(%rip),%r14
mov    (%r14),%edi
mov    (%rsi),%ecx
mov    0x4(%rsi),%r8d
lea    0xec0(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    (%rbx),%ebp
cmp    $0xffffffff,%ebp
je     1172 <handler+0x52>
mov    (%r14),%edi
mov    0x4(%rbx),%edx
lea    0xebe(%rip),%rsi
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <syslog@plt>
mov    0x4(%rbx),%edi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <read_shm@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@LOG_DEBUG = global i32 0
@.str = [25 x i8] c"daemon: handler %d %d %d\00"
@.str.1 = [28 x i8] c"daemon: from :%d shmid :%d\00"
define void @handler(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* @LOG_DEBUG
%9 = load i32, i32* %4
%10 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
%12 = load i32, i32* %11
%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 = call i32 (i32, i8*, i32, i32, ...) @syslog(i32 %8, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12, i32 %15)
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 0
%19 = load i32, i32* %18
store i32 %19, i32* %7
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %33
21: ; preds = %3
%22 = load i32, i32* @LOG_DEBUG
%23 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 1
%25 = load i32, i32* %24
%26 = load i32, i32* %7
%27 = call i32 (i32, i8*, i32, i32, ...) @syslog(i32 %22, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %26)
%28 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %28, i32 0, i32 1
%30 = load i32, i32* %29
%31 = load i32, i32* %7
%32 = call i32 @read_shm(i32 %30, i32 %31)
br label %33
33: ; preds = %21, %3
ret void
}

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