#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_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int sival_int;
};
struct TYPE_5__ {
  int si_uid;
  int si_pid;
  scalar_t__ si_code;
  TYPE_1__ si_value;
  int /*<<< orphan*/ si_signo;
};
typedef TYPE_2__ siginfo_t;

/* Variables and functions */
scalar_t__ SI_QUEUE;
int /*<<< orphan*/ printf(char *, int, int, char *, int, char *);
char *strsignal(int /*<<< orphan*/);
void fun(int sig, siginfo_t *p, void *x) {
  printf("uid:%d, pid:%d, sig:%s, data:%d, code:%s\n", p->si_uid, p->si_pid,
         strsignal(p->si_signo), p->si_value.sival_int,
         p->si_code == SI_QUEUE ? "sigqueue" : "other");
}


x86 assembly (clang, -O0):
<fun>:
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),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%edi
call   1040 <strsignal@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e76(%rip),%rax
mov    (%rax),%r10
lea    0xeb7(%rip),%r9
lea    0xea7(%rip),%rax
cmp    %r10,%rdi
cmove  %rax,%r9
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    (%rsi),%ebp
mov    0x4(%rsi),%r14d
mov    0x14(%rsi),%edi
call   1040 <strsignal@plt>
mov    0x10(%rbx),%r8d
mov    0x8(%rbx),%rcx
mov    0x2ea4(%rip),%rdx
cmp    (%rdx),%rcx
lea    0xedc(%rip),%rcx
lea    0xede(%rip),%r9
cmove  %rcx,%r9
lea    0xea0(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %rax,%rcx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, i32, i64, %struct.TYPE_4__, i32 }
%struct.TYPE_4__ = type { i32 }
@.str = [42 x i8] c"uid:%d, pid:%d, sig:%s, data:%d, code:%s\0A\00"
@SI_QUEUE = global i64 0
@.str.1 = [9 x i8] c"sigqueue\00"
@.str.2 = [6 x i8] c"other\00"
define void @fun(i32 %0, %struct.TYPE_5__* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.TYPE_5__*
%6 = alloca i8*
store i32 %0, i32* %4
store %struct.TYPE_5__* %1, %struct.TYPE_5__** %5
store i8* %2, i8** %6
%7 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %10, i32 0, i32 1
%12 = load i32, i32* %11
%13 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %13, i32 0, i32 4
%15 = load i32, i32* %14
%16 = call i8* @strsignal(i32 %15)
%17 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%18 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %17, i32 0, i32 3
%19 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%22 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %21, i32 0, i32 2
%23 = load i64, i64* %22
%24 = load i64, i64* @SI_QUEUE
%25 = icmp eq i64 %23, %24
%26 = zext i1 %25 to i64
%27 = select i1 %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%28 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12, i8* %16, i32 %20, i8* %27)
ret void
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i32, i64, %struct.TYPE_4__, i32 }
%struct.TYPE_4__ = type { i32 }
@.str = [42 x i8] c"uid:%d, pid:%d, sig:%s, data:%d, code:%s\0A\00"
@SI_QUEUE = global i64 0
@.str.1 = [9 x i8] c"sigqueue\00"
@.str.2 = [6 x i8] c"other\00"
define void @fun(i32 %0, %struct.TYPE_5__* nocapture %1, i8* nocapture readnone %2) {
%4 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 4
%9 = load i32, i32* %8
%10 = tail call i8* @strsignal(i32 %9)
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 3, i32 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 2
%14 = load i64, i64* %13
%15 = load i64, i64* @SI_QUEUE
%16 = icmp eq i64 %14, %15
%17 = select i1 %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7, i8* %10, i32 %12, i8* %17)
ret void
}