#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 */

/* Type definitions */
struct task {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ emit_signal(struct task *, int, int);
scalar_t__ get_arg_u64(void *, char *);
struct task *get_current_task(int);
void signal_deliver_process(const char *modname, int pass, double clock,
                            int cpu, void *args) {
  int sig;
  struct task *task;
  if (pass == 2) {
    sig = (int)get_arg_u64(args, "sig");
    task = get_current_task(cpu);
    if (task)
      emit_signal(task, sig, cpu);
  }
}


x86 assembly (clang, -O0):
<signal_deliver_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
cmpl   $0x2,-0xc(%rbp)
jne    1193 <signal_deliver_process+0x63>
mov    -0x28(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1050 <get_arg_u64@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <get_current_task@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     118e <signal_deliver_process+0x5e>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <emit_signal@plt>
jmp    1193 <signal_deliver_process+0x63>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signal_deliver_process>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%esi
jne    116d <signal_deliver_process+0x3d>
mov    %edx,%ebx
lea    0xebe(%rip),%rsi
mov    %rcx,%rdi
call   1050 <get_arg_u64@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1040 <get_current_task@plt>
test   %rax,%rax
je     116d <signal_deliver_process+0x3d>
mov    %rax,%rdi
mov    %r14d,%esi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <emit_signal@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.task = type { i32 }
@.str = [4 x i8] c"sig\00"
define void @signal_deliver_process(i8* %0, i32 %1, double %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca %struct.task*
store i8* %0, i8** %6
store i32 %1, i32* %7
store double %2, double* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%13 = load i32, i32* %7
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %29
15: ; preds = %5
%16 = load i8*, i8** %10
%17 = call i64 @get_arg_u64(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%18 = trunc i64 %17 to i32
store i32 %18, i32* %11
%19 = load i32, i32* %9
%20 = call %struct.task* @get_current_task(i32 %19)
store %struct.task* %20, %struct.task** %12
%21 = load %struct.task*, %struct.task** %12
%22 = icmp ne %struct.task* %21, null
br i1 %22, label %23, label %28
23: ; preds = %15
%24 = load %struct.task*, %struct.task** %12
%25 = load i32, i32* %11
%26 = load i32, i32* %9
%27 = call i32 @emit_signal(%struct.task* %24, i32 %25, i32 %26)
br label %28
28: ; preds = %23, %15
br label %29
29: ; preds = %28, %5
ret void
}

LLVM IR (-O2):
%struct.task = type { i32 }
@.str = [4 x i8] c"sig\00"
define void @signal_deliver_process(i8* nocapture readnone %0, i32 %1, double %2, i32 %3, i8* %4) {
%6 = icmp eq i32 %1, 2
br i1 %6, label %7, label %14
7: ; preds = %5
%8 = tail call i64 @get_arg_u64(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = tail call %struct.task* @get_current_task(i32 %3)
%10 = icmp eq %struct.task* %9, null
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = trunc i64 %8 to i32
%13 = tail call i32 @emit_signal(%struct.task* %9, i32 %12, i32 %3)
br label %14
14: ; preds = %7, %11, %5
ret void
}