#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_struct {
  int dummy;
};

/* Variables and functions */
scalar_t__ __fatal_signal_pending(struct task_struct *);
int /*<<< orphan*/ signal_pending(struct task_struct *);
__attribute__((always_)) int signal_pending_state(long state,
                                                  struct task_struct *p) {
  if (!(state & (1 | 128)))
    return 0;
  if (!signal_pending(p))
    return 0;
  return (state & 1) || __fatal_signal_pending(p);
}


x86 assembly (clang, -O0):
<signal_pending_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x81,%rax
cmp    $0x0,%rax
jne    1150 <signal_pending_state+0x30>
movl   $0x0,-0x4(%rbp)
jmp    11a3 <signal_pending_state+0x83>
mov    -0x18(%rbp),%rdi
call   1030 <signal_pending@plt>
cmp    $0x0,%eax
jne    116e <signal_pending_state+0x4e>
movl   $0x0,-0x4(%rbp)
jmp    11a3 <signal_pending_state+0x83>
mov    -0x10(%rbp),%rcx
and    $0x1,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
jne    1198 <signal_pending_state+0x78>
mov    -0x18(%rbp),%rdi
call   1040 <__fatal_signal_pending@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signal_pending_state>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
xor    %ebp,%ebp
test   $0x81,%bl
je     1158 <signal_pending_state+0x38>
mov    %rsi,%r14
mov    %rsi,%rdi
call   1030 <signal_pending@plt>
test   %eax,%eax
je     1158 <signal_pending_state+0x38>
mov    $0x1,%ebp
test   $0x1,%bl
jne    1158 <signal_pending_state+0x38>
mov    %r14,%rdi
call   1040 <__fatal_signal_pending@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.task_struct = type { i32 }
define i32 @signal_pending_state(i64 %0, %struct.task_struct* %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca %struct.task_struct*
store i64 %0, i64* %4
store %struct.task_struct* %1, %struct.task_struct** %5
%6 = load i64, i64* %4
%7 = and i64 %6, 129
%8 = icmp ne i64 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %2
store i32 0, i32* %3
br label %26
10: ; preds = %2
%11 = load %struct.task_struct*, %struct.task_struct** %5
%12 = call i32 @signal_pending(%struct.task_struct* %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %10
store i32 0, i32* %3
br label %26
15: ; preds = %10
%16 = load i64, i64* %4
%17 = and i64 %16, 1
%18 = icmp ne i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load %struct.task_struct*, %struct.task_struct** %5
%21 = call i64 @__fatal_signal_pending(%struct.task_struct* %20)
%22 = icmp ne i64 %21, 0
br label %23
23: ; preds = %19, %15
%24 = phi i1 [ true, %15 ], [ %22, %19 ]
%25 = zext i1 %24 to i32
store i32 %25, i32* %3
br label %26
26: ; preds = %23, %14, %9
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.task_struct = type { i32 }
define i32 @signal_pending_state(i64 %0, %struct.task_struct* %1) {
%3 = and i64 %0, 129
%4 = icmp eq i64 %3, 0
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = tail call i32 @signal_pending(%struct.task_struct* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = and i64 %0, 1
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = tail call i64 @__fatal_signal_pending(%struct.task_struct* %1)
%13 = icmp ne i64 %12, 0
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %8, %11, %5, %2
%16 = phi i32 [ 0, %2 ], [ 0, %5 ], [ 1, %8 ], [ %14, %11 ]
ret i32 %16
}