#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 /*<<< orphan*/ touch2(int, int *, int *, int *, int *);
void reachability(int n_left, int n_right, int *pointers, int *indices,
                  int *matching, int *touched) {
  int i;
  for (i = 0; i < n_left + n_right; i++) {
    touched[i] = 0;
  }
  for (i = 0; i < n_left; i++) {
    if (!touched[i] && matching[i] == -1) {
      touch2(i, pointers, indices, matching, touched);
    }
  }
}


x86 assembly (clang, -O0):
<reachability>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    1163 <reachability+0x53>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1135 <reachability+0x25>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c5 <reachability+0xb5>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11b2 <reachability+0xa2>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
jne    11b2 <reachability+0xa2>
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <touch2@plt>
jmp    11b7 <reachability+0xa7>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    116a <reachability+0x5a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reachability>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r13
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %edi,%ebx
add    %edi,%esi
test   %esi,%esi
jle    1154 <reachability+0x34>
add    $0xffffffff,%esi
lea    0x4(,%rsi,4),%rdx
mov    %r13,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
test   %ebx,%ebx
jle    118d <reachability+0x6d>
mov    %ebx,%ebp
xor    %ebx,%ebx
jmp    1169 <reachability+0x49>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%rbp
je     118d <reachability+0x6d>
cmpl   $0x0,0x0(%r13,%rbx,4)
jne    1160 <reachability+0x40>
cmpl   $0xffffffff,(%r14,%rbx,4)
jne    1160 <reachability+0x40>
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %r13,%r8
call   1030 <touch2@plt>
jmp    1160 <reachability+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @reachability(i32 %0, i32 %1, i32* %2, i32* %3, i32* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32* %5, i32** %12
store i32 0, i32* %13
br label %14
14: ; preds = %25, %6
%15 = load i32, i32* %13
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = add nsw i32 %16, %17
%19 = icmp slt i32 %15, %18
br i1 %19, label %20, label %28
20: ; preds = %14
%21 = load i32*, i32** %12
%22 = load i32, i32* %13
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 0, i32* %24
br label %25
25: ; preds = %20
%26 = load i32, i32* %13
%27 = add nsw i32 %26, 1
store i32 %27, i32* %13
br label %14
28: ; preds = %14
store i32 0, i32* %13
br label %29
29: ; preds = %55, %28
%30 = load i32, i32* %13
%31 = load i32, i32* %7
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %58
33: ; preds = %29
%34 = load i32*, i32** %12
%35 = load i32, i32* %13
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = icmp ne i32 %38, 0
br i1 %39, label %54, label %40
40: ; preds = %33
%41 = load i32*, i32** %11
%42 = load i32, i32* %13
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %54
47: ; preds = %40
%48 = load i32, i32* %13
%49 = load i32*, i32** %9
%50 = load i32*, i32** %10
%51 = load i32*, i32** %11
%52 = load i32*, i32** %12
%53 = call i32 @touch2(i32 %48, i32* %49, i32* %50, i32* %51, i32* %52)
br label %54
54: ; preds = %47, %40, %33
br label %55
55: ; preds = %54
%56 = load i32, i32* %13
%57 = add nsw i32 %56, 1
store i32 %57, i32* %13
br label %29
58: ; preds = %29
ret void
}

LLVM IR (-O2):
define void @reachability(i32 %0, i32 %1, i32* %2, i32* %3, i32* %4, i32* %5) {
%7 = add i32 %1, %0
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = bitcast i32* %5 to i8*
%11 = add nsw i32 %7, -1
%12 = zext i32 %11 to i64
%13 = shl nuw nsw i64 %12, 2
%14 = add nuw nsw i64 %13, 4
br label %15
15: ; preds = %9, %6
%16 = icmp sgt i32 %0, 0
br i1 %16, label %17, label %34
17: ; preds = %15
%18 = zext i32 %0 to i64
br label %19
19: ; preds = %17, %31
%20 = phi i64 [ 0, %17 ], [ %32, %31 ]
%21 = getelementptr inbounds i32, i32* %5, i64 %20
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %19
%25 = getelementptr inbounds i32, i32* %4, i64 %20
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = trunc i64 %20 to i32
%30 = tail call i32 @touch2(i32 %29, i32* %2, i32* %3, i32* %4, i32* %5)
br label %31
31: ; preds = %19, %24, %28
%32 = add nuw nsw i64 %20, 1
%33 = icmp eq i64 %32, %18
br i1 %33, label %34, label %19
34: ; preds = %31, %15
ret void
}