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

/* Variables and functions */
int SIG_BLOCK;
int SIG_SETMASK;
int SIG_UNBLOCK;
int rand();
int get_rand(void) {
  int r;
  r = rand();
  while ((r == SIG_BLOCK) || (r == SIG_SETMASK) || (r == SIG_UNBLOCK)) {
    r = get_rand();
  }
  return r;
}


x86 assembly (clang, -O0):
<get_rand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <rand@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    $0x1,%al
mov    0x2e92(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x5(%rbp)
je     1172 <get_rand+0x52>
mov    -0x4(%rbp),%ecx
mov    $0x1,%al
mov    0x2e8b(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x5(%rbp)
je     1172 <get_rand+0x52>
mov    -0x4(%rbp),%eax
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    1182 <get_rand+0x62>
jmp    118f <get_rand+0x6f>
call   1030 <get_rand@plt>
mov    %eax,-0x4(%rbp)
jmp    1132 <get_rand+0x12>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rand>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <rand@plt>
mov    0x2e9d(%rip),%rbx
mov    0x2ea6(%rip),%r14
mov    0x2ea7(%rip),%r15
jmp    1155 <get_rand+0x35>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1030 <get_rand@plt>
cmp    (%rbx),%eax
je     1150 <get_rand+0x30>
cmp    (%r14),%eax
je     1150 <get_rand+0x30>
cmp    (%r15),%eax
je     1150 <get_rand+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SIG_BLOCK = global i32 0
@SIG_SETMASK = global i32 0
@SIG_UNBLOCK = global i32 0
define i32 @get_rand() {
%1 = alloca i32
%2 = call i32 (...) @rand()
store i32 %2, i32* %1
br label %3
3: ; preds = %17, %0
%4 = load i32, i32* %1
%5 = load i32, i32* @SIG_BLOCK
%6 = icmp eq i32 %4, %5
br i1 %6, label %15, label %7
7: ; preds = %3
%8 = load i32, i32* %1
%9 = load i32, i32* @SIG_SETMASK
%10 = icmp eq i32 %8, %9
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = load i32, i32* %1
%13 = load i32, i32* @SIG_UNBLOCK
%14 = icmp eq i32 %12, %13
br label %15
15: ; preds = %11, %7, %3
%16 = phi i1 [ true, %7 ], [ true, %3 ], [ %14, %11 ]
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = call i32 @get_rand()
store i32 %18, i32* %1
br label %3
19: ; preds = %15
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@SIG_BLOCK = global i32 0
@SIG_SETMASK = global i32 0
@SIG_UNBLOCK = global i32 0
define i32 @get_rand() {
%1 = tail call i32 (...) @rand()
%2 = load i32, i32* @SIG_BLOCK
%3 = icmp eq i32 %1, %2
%4 = load i32, i32* @SIG_SETMASK
%5 = icmp eq i32 %1, %4
%6 = select i1 %3, i1 true, i1 %5
%7 = load i32, i32* @SIG_UNBLOCK
%8 = icmp eq i32 %1, %7
%9 = select i1 %6, i1 true, i1 %8
br i1 %9, label %10, label %20
10: ; preds = %0, %10
%11 = tail call i32 @get_rand()
%12 = load i32, i32* @SIG_BLOCK
%13 = icmp eq i32 %11, %12
%14 = load i32, i32* @SIG_SETMASK
%15 = icmp eq i32 %11, %14
%16 = select i1 %13, i1 true, i1 %15
%17 = load i32, i32* @SIG_UNBLOCK
%18 = icmp eq i32 %11, %17
%19 = select i1 %16, i1 true, i1 %18
br i1 %19, label %10, label %20
20: ; preds = %10, %0
%21 = phi i32 [ %1, %0 ], [ %11, %10 ]
ret i32 %21
}