#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 i;
  unsigned *rp;
  unsigned *relend;
  transitive_closure(R, n);
  rowsize = (((n) + (32 - 1) / 32));
  relend = R + n * rowsize;
  i = 0;
  rp = R;
  while (rp < relend) {
    *rp |= (1 << i);
    if (++i >= 32) {
      i = 0;
      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    $0x0,%eax
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   $0x0,-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    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x20,%eax
jb     11a3 <reflexive_transitive_closure+0x93>
movl   $0x0,-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    115c <reflexive_transitive_closure+0x4c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reflexive_transitive_closure>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <transitive_closure@plt>
mov    %ebp,%eax
imul   %eax,%eax
test   %eax,%eax
je     116c <reflexive_transitive_closure+0x5c>
lea    (%rbx,%rax,4),%rax
movslq %ebp,%rdx
xor    %esi,%esi
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
shl    %cl,%edi
or     %edi,(%rbx)
add    $0x1,%ecx
xor    %edi,%edi
cmp    $0x20,%ecx
setae  %dil
lea    (%rbx,%rdx,4),%rbp
cmovae %esi,%ecx
lea    0x0(,%rdi,4),%rbx
add    %rbp,%rbx
cmp    %rax,%rbx
jb     1140 <reflexive_transitive_closure+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
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, 0
store i32 %13, i32* %5
%14 = load i32*, i32** %3
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = mul nsw i32 %15, %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %14, i64 %18
store i32* %19, i32** %8
store i32 0, i32* %6
%20 = load i32*, i32** %3
store i32* %20, i32** %7
br label %21
21: ; preds = %37, %2
%22 = load i32*, i32** %7
%23 = load i32*, i32** %8
%24 = icmp ult i32* %22, %23
br i1 %24, label %25, label %42
25: ; preds = %21
%26 = load i32, i32* %6
%27 = shl i32 1, %26
%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 = add i32 %31, 1
store i32 %32, i32* %6
%33 = icmp uge i32 %32, 32
br i1 %33, label %34, label %37
34: ; preds = %25
store i32 0, i32* %6
%35 = load i32*, i32** %7
%36 = getelementptr inbounds i32, i32* %35, i32 1
store i32* %36, i32** %7
br label %37
37: ; preds = %34, %25
%38 = load i32, i32* %5
%39 = load i32*, i32** %7
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds i32, i32* %39, i64 %40
store i32* %41, i32** %7
br label %21
42: ; preds = %21
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 = mul nsw i32 %1, %1
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds i32, i32* %0, i64 %5
%7 = icmp eq i32 %4, 0
br i1 %7, label %23, label %8
8: ; preds = %2
%9 = sext i32 %1 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i32 [ 0, %8 ], [ %20, %10 ]
%12 = phi i32* [ %0, %8 ], [ %21, %10 ]
%13 = shl nuw i32 1, %11
%14 = load i32, i32* %12
%15 = or i32 %14, %13
store i32 %15, i32* %12
%16 = add i32 %11, 1
%17 = icmp ugt i32 %16, 31
%18 = zext i1 %17 to i64
%19 = getelementptr i32, i32* %12, i64 %9
%20 = select i1 %17, i32 0, i32 %16
%21 = getelementptr inbounds i32, i32* %19, i64 %18
%22 = icmp ult i32* %21, %6
br i1 %22, label %10, label %23
23: ; preds = %10, %2
ret void
}