#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 */
typedef int uint32_t;

/* Variables and functions */
int get_magic_number(int, int, int);
scalar_t__ is_irrelevant(int, int, int);
int is_forced(uint32_t rn, int rank, int var_p) {
  uint32_t rm;
  if (is_irrelevant(rn, rank, var_p))
    return -1;
  rm = rn & get_magic_number(rank, var_p, 1);
  return rm == 0 ? 0 : (rm == rn ? 1 : -1);
}


x86 assembly (clang, -O0):
<is_forced>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <is_irrelevant@plt>
cmp    $0x0,%rax
je     1155 <is_forced+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a7 <is_forced+0x87>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    $0x1,%edx
call   1040 <get_magic_number@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1189 <is_forced+0x69>
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a1 <is_forced+0x81>
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%esi
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_forced>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <is_irrelevant@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    1160 <is_forced+0x40>
mov    %ebp,%edi
mov    %r14d,%esi
mov    $0x1,%edx
call   1040 <get_magic_number@plt>
mov    %eax,%ecx
and    %ebx,%ecx
xor    %eax,%eax
cmp    %ebx,%ecx
sete   %al
test   %ecx,%ecx
lea    -0x1(%rax,%rax,1),%eax
cmove  %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_forced(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = call i64 @is_irrelevant(i32 %9, i32 %10, i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -1, i32* %4
br label %32
15: ; preds = %3
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = call i32 @get_magic_number(i32 %17, i32 %18, i32 1)
%20 = and i32 %16, %19
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %15
br label %30
24: ; preds = %15
%25 = load i32, i32* %8
%26 = load i32, i32* %5
%27 = icmp eq i32 %25, %26
%28 = zext i1 %27 to i64
%29 = select i1 %27, i32 1, i32 -1
br label %30
30: ; preds = %24, %23
%31 = phi i32 [ 0, %23 ], [ %29, %24 ]
store i32 %31, i32* %4
br label %32
32: ; preds = %30, %14
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
define i32 @is_forced(i32 %0, i32 %1, i32 %2) {
%4 = tail call i64 @is_irrelevant(i32 %0, i32 %1, i32 %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = tail call i32 @get_magic_number(i32 %1, i32 %2, i32 1)
%8 = and i32 %7, %0
%9 = icmp eq i32 %8, 0
%10 = icmp eq i32 %8, %0
%11 = select i1 %10, i32 1, i32 -1
%12 = select i1 %9, i32 0, i32 %11
br label %13
13: ; preds = %3, %6
%14 = phi i32 [ %12, %6 ], [ -1, %3 ]
ret i32 %14
}