#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 *resid, int *flow, 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] && resid[i]) {
      touch2(i, pointers, indices, flow, touched);
    }
  }
}


x86 assembly (clang, -O0):
<reachability>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
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    1167 <reachability+0x57>
mov    0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1139 <reachability+0x29>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c9 <reachability+0xb9>
mov    0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11b6 <reachability+0xa6>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11b6 <reachability+0xa6>
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    0x10(%rbp),%r8
call   1030 <touch2@plt>
jmp    11bb <reachability+0xab>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    116e <reachability+0x5e>
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,(%rsp)
mov    %r8,%r13
mov    %rcx,%r15
mov    %rdx,%r12
mov    %edi,%ebp
mov    0x40(%rsp),%rbx
add    %edi,%esi
test   %esi,%esi
jle    115a <reachability+0x3a>
add    $0xffffffff,%esi
lea    0x4(,%rsi,4),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
test   %ebp,%ebp
jle    119d <reachability+0x7d>
mov    %ebp,%r14d
xor    %ebp,%ebp
jmp    1179 <reachability+0x59>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbp
cmp    %rbp,%r14
je     119d <reachability+0x7d>
cmpl   $0x0,(%rbx,%rbp,4)
jne    1170 <reachability+0x50>
cmpl   $0x0,0x0(%r13,%rbp,4)
je     1170 <reachability+0x50>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r15,%rdx
mov    (%rsp),%rcx
mov    %rbx,%r8
call   1030 <touch2@plt>
jmp    1170 <reachability+0x50>
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, i32* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
store i32 0, i32* %15
br label %16
16: ; preds = %27, %7
%17 = load i32, i32* %15
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = add nsw i32 %18, %19
%21 = icmp slt i32 %17, %20
br i1 %21, label %22, label %30
22: ; preds = %16
%23 = load i32*, i32** %14
%24 = load i32, i32* %15
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 0, i32* %26
br label %27
27: ; preds = %22
%28 = load i32, i32* %15
%29 = add nsw i32 %28, 1
store i32 %29, i32* %15
br label %16
30: ; preds = %16
store i32 0, i32* %15
br label %31
31: ; preds = %57, %30
%32 = load i32, i32* %15
%33 = load i32, i32* %8
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %60
35: ; preds = %31
%36 = load i32*, i32** %14
%37 = load i32, i32* %15
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = icmp ne i32 %40, 0
br i1 %41, label %56, label %42
42: ; preds = %35
%43 = load i32*, i32** %12
%44 = load i32, i32* %15
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32, i32* %46
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %42
%50 = load i32, i32* %15
%51 = load i32*, i32** %10
%52 = load i32*, i32** %11
%53 = load i32*, i32** %13
%54 = load i32*, i32** %14
%55 = call i32 @touch2(i32 %50, i32* %51, i32* %52, i32* %53, i32* %54)
br label %56
56: ; preds = %49, %42, %35
br label %57
57: ; preds = %56
%58 = load i32, i32* %15
%59 = add nsw i32 %58, 1
store i32 %59, i32* %15
br label %31
60: ; preds = %31
ret void
}

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