#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 */
union sigval {
  int sival_int;
};
struct timeval {
  int tv_sec;
  int tv_usec;
};
typedef int /*<<< orphan*/ sigset_t;
struct TYPE_3__ {
  union sigval si_value;
};
typedef TYPE_1__ siginfo_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, int, int);
scalar_t__ getpid();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int sigwaitinfo(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void mysignalhandler1(int n, siginfo_t *info, void *k) {
  sigset_t set;
  int signalid;
  union sigval data = info->si_value;
  struct timeval tp;
  signalid = data.sival_int;
  sigemptyset(&set);
  sigaddset(&set, signalid);
  gettimeofday(&tp, NULL);
  fprintf(stderr,
          "CFSCHED Signal to sleep to process id: %d with signal id:%d time:%d "
          "sec %d usec\n",
          (int)getpid(), signalid, tp.tv_sec, tp.tv_usec);
  signalid = sigwaitinfo(&set, NULL);
  gettimeofday(&tp, NULL);
  fprintf(stderr,
          "CFSCHED Signal to wake up process id: %d with signal id:%d time:%d "
          "sec %d usec\n",
          (int)getpid(), signalid, tp.tv_sec, tp.tv_usec);
}


x86 assembly (clang, -O0):
<mysignalhandler1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
lea    -0x1c(%rbp),%rdi
call   1060 <sigemptyset@plt>
mov    -0x20(%rbp),%esi
lea    -0x1c(%rbp),%rdi
call   1080 <sigaddset@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x38(%rbp),%edi
mov    %eax,%edx
mov    -0x20(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
lea    0xe32(%rip),%rsi
call   1050 <fprintf@plt>
lea    -0x1c(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <sigwaitinfo@plt>
mov    %eax,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%edx
mov    -0x20(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
lea    0xe37(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mysignalhandler1>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    (%rsi),%ebp
lea    0xc(%rsp),%r15
mov    %r15,%rdi
call   1060 <sigemptyset@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1080 <sigaddset@plt>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x2e47(%rip),%r12
mov    (%r12),%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
mov    (%rsp),%r8d
mov    0x4(%rsp),%r9d
lea    0xe4c(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
mov    %ebp,%ecx
call   1050 <fprintf@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1070 <sigwaitinfo@plt>
mov    %eax,%ebx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    (%r12),%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
mov    (%rsp),%r8d
mov    0x4(%rsp),%r9d
lea    0xe61(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
mov    %ebx,%ecx
call   1050 <fprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { %union.sigval }
%union.sigval = type { i32 }
%struct.timeval = type { i32, i32 }
@stderr = global i32 0
@.str = [81 x i8] c"CFSCHED Signal to sleep to process id: %d with signal id:%d time:%d sec %d usec\0A\00"
@.str.1 = [80 x i8] c"CFSCHED Signal to wake up process id: %d with signal id:%d time:%d sec %d usec\0A\00"
define void @mysignalhandler1(i32 %0, %struct.TYPE_3__* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.TYPE_3__*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca %union.sigval
%10 = alloca %struct.timeval
store i32 %0, i32* %4
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %5
store i8* %2, i8** %6
%11 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 0
%13 = bitcast %union.sigval* %9 to i8*
%14 = bitcast %union.sigval* %12 to i8*
%15 = bitcast %union.sigval* %9 to i32*
%16 = load i32, i32* %15
store i32 %16, i32* %8
%17 = call i32 @sigemptyset(i32* %7)
%18 = load i32, i32* %8
%19 = call i32 @sigaddset(i32* %7, i32 %18)
%20 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
%21 = load i32, i32* @stderr
%22 = call i64 (...) @getpid()
%23 = trunc i64 %22 to i32
%24 = load i32, i32* %8
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
%28 = load i32, i32* %27
%29 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24, i32 %26, i32 %28)
%30 = call i32 @sigwaitinfo(i32* %7, i32* null)
store i32 %30, i32* %8
%31 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
%32 = load i32, i32* @stderr
%33 = call i64 (...) @getpid()
%34 = trunc i64 %33 to i32
%35 = load i32, i32* %8
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%37 = load i32, i32* %36
%38 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
%39 = load i32, i32* %38
%40 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %35, i32 %37, i32 %39)
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { %union.sigval }
%union.sigval = type { i32 }
%struct.timeval = type { i32, i32 }
@stderr = global i32 0
@.str = [81 x i8] c"CFSCHED Signal to sleep to process id: %d with signal id:%d time:%d sec %d usec\0A\00"
@.str.1 = [80 x i8] c"CFSCHED Signal to wake up process id: %d with signal id:%d time:%d sec %d usec\0A\00"
define void @mysignalhandler1(i32 %0, %struct.TYPE_3__* nocapture %1, i8* nocapture readnone %2) {
%4 = alloca i32
%5 = alloca %struct.timeval
%6 = bitcast i32* %4 to i8*
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0, i32 0
%8 = load i32, i32* %7
%9 = bitcast %struct.timeval* %5 to i8*
%10 = call i32 @sigemptyset(i32* %4)
%11 = call i32 @sigaddset(i32* %4, i32 %8)
%12 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%13 = load i32, i32* @stderr
%14 = call i64 (...) @getpid()
%15 = trunc i64 %14 to i32
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%19 = load i32, i32* %18
%20 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %8, i32 %17, i32 %19)
%21 = call i32 @sigwaitinfo(i32* %4, i32* null)
%22 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%23 = load i32, i32* @stderr
%24 = call i64 (...) @getpid()
%25 = trunc i64 %24 to i32
%26 = load i32, i32* %16
%27 = load i32, i32* %18
%28 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %21, i32 %26, i32 %27)
ret void
}