#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 n;

/* Variables and functions */
int /*<<< orphan*/ transitive_closure(unsigned int *, int);
void reflexive_transitive_closure(unsigned *R, int n) {
  int rowsize;
  unsigned mask;
  unsigned *rp;
  unsigned *relend;
  transitive_closure(R, n);
  rowsize = (((n) + (32 - 1)) / 32);
  relend = R + n * rowsize;
  mask = 1;
  rp = R;
  while (rp < relend) {
    *rp |= mask;
    mask <<= 1;
    if (mask == 0) {
      mask = 1;
      rp++;
    }
    rp += rowsize;
  }
}


x86 assembly (clang, -O0):
<reflexive_transitive_closure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <transitive_closure@plt>
mov    -0xc(%rbp),%eax
add    $0x1f,%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11bd <reflexive_transitive_closure+0xad>
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11a3 <reflexive_transitive_closure+0x93>
movl   $0x1,-0x14(%rbp)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    1164 <reflexive_transitive_closure+0x54>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reflexive_transitive_closure>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
call   1030 <transitive_closure@plt>
lea    0x1f(%r14),%eax
lea    0x3e(%r14),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x5,%ecx
imul   %ecx,%r14d
test   %r14d,%r14d
jle    116a <reflexive_transitive_closure+0x5a>
movslq %r14d,%rax
lea    (%rbx,%rax,4),%rax
movslq %ecx,%rcx
mov    $0x1,%edx
mov    $0x1,%esi
nopl   0x0(%rax)
or     %esi,(%rbx)
xor    %edi,%edi
add    %esi,%esi
sete   %dil
lea    (%rbx,%rcx,4),%rbx
cmove  %edx,%esi
lea    (%rbx,%rdi,4),%rbx
cmp    %rax,%rbx
jb     1150 <reflexive_transitive_closure+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @reflexive_transitive_closure(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%9 = load i32*, i32** %3
%10 = load i32, i32* %4
%11 = call i32 @transitive_closure(i32* %9, i32 %10)
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 31
%14 = sdiv i32 %13, 32
store i32 %14, i32* %5
%15 = load i32*, i32** %3
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = mul nsw i32 %16, %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %15, i64 %19
store i32* %20, i32** %8
store i32 1, i32* %6
%21 = load i32*, i32** %3
store i32* %21, i32** %7
br label %22
22: ; preds = %38, %2
%23 = load i32*, i32** %7
%24 = load i32*, i32** %8
%25 = icmp ult i32* %23, %24
br i1 %25, label %26, label %43
26: ; preds = %22
%27 = load i32, i32* %6
%28 = load i32*, i32** %7
%29 = load i32, i32* %28
%30 = or i32 %29, %27
store i32 %30, i32* %28
%31 = load i32, i32* %6
%32 = shl i32 %31, 1
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %26
store i32 1, i32* %6
%36 = load i32*, i32** %7
%37 = getelementptr inbounds i32, i32* %36, i32 1
store i32* %37, i32** %7
br label %38
38: ; preds = %35, %26
%39 = load i32, i32* %5
%40 = load i32*, i32** %7
%41 = sext i32 %39 to i64
%42 = getelementptr inbounds i32, i32* %40, i64 %41
store i32* %42, i32** %7
br label %22
43: ; preds = %22
ret void
}

LLVM IR (-O2):
define void @reflexive_transitive_closure(i32* %0, i32 %1) {
%3 = tail call i32 @transitive_closure(i32* %0, i32 %1)
%4 = add nsw i32 %1, 31
%5 = sdiv i32 %4, 32
%6 = mul nsw i32 %5, %1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = icmp sgt i32 %6, 0
br i1 %9, label %10, label %24
10: ; preds = %2
%11 = sext i32 %5 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i32 [ 1, %10 ], [ %21, %12 ]
%14 = phi i32* [ %0, %10 ], [ %22, %12 ]
%15 = load i32, i32* %14
%16 = or i32 %15, %13
store i32 %16, i32* %14
%17 = shl i32 %13, 1
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i64
%20 = getelementptr i32, i32* %14, i64 %11
%21 = select i1 %18, i32 1, i32 %17
%22 = getelementptr inbounds i32, i32* %20, i64 %19
%23 = icmp ult i32* %22, %8
br i1 %23, label %12, label %24
24: ; preds = %12, %2
ret void
}