#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned int,
                           unsigned int);
void write_edges(FILE *fileout, unsigned int *J_slap, unsigned int *r_slap,
                 unsigned int N) {
  unsigned int i, j;
  for (i = 0; i < N; i++) {
    for (j = r_slap[i]; j < r_slap[i + 1]; j++) {
      if (J_slap[j] > i) {
        fprintf(fileout, "%d %d\n", i, J_slap[j]);
      }
    }
  }
}


x86 assembly (clang, -O0):
<write_edges>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11b5 <write_edges+0xa5>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%edx
add    $0x1,%edx
mov    %edx,%edx
cmp    (%rcx,%rdx,4),%eax
jae    11a2 <write_edges+0x92>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
cmp    -0x20(%rbp),%eax
jbe    118f <write_edges+0x7f>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,4),%ecx
lea    0xe76(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1194 <write_edges+0x84>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1147 <write_edges+0x37>
jmp    11a7 <write_edges+0x97>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112e <write_edges+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_edges>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
je     118c <write_edges+0x7c>
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r15
mov    %ecx,%eax
mov    %rax,(%rsp)
mov    (%rdx),%ecx
xor    %ebp,%ebp
jmp    1148 <write_edges+0x38>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%ecx
cmp    (%rsp),%rbp
je     118c <write_edges+0x7c>
mov    %rbp,%rbx
add    $0x1,%rbp
mov    0x4(%r14,%rbx,4),%eax
cmp    %eax,%ecx
jae    1140 <write_edges+0x30>
mov    %ecx,%r12d
jmp    116b <write_edges+0x5b>
nopl   (%rax)
add    $0x1,%r12
mov    %eax,%ecx
cmp    %rcx,%r12
jae    1140 <write_edges+0x30>
mov    0x0(%r13,%r12,4),%ecx
cmp    %rcx,%rbx
jae    1160 <write_edges+0x50>
mov    %r15,%rdi
lea    0xe81(%rip),%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
mov    (%r14,%rbp,4),%eax
jmp    1160 <write_edges+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d %d\0A\00"
define void @write_edges(i32* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %11
11: ; preds = %52, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %8
%14 = icmp ult i32 %12, %13
br i1 %14, label %15, label %55
15: ; preds = %11
%16 = load i32*, i32** %7
%17 = load i32, i32* %9
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
store i32 %20, i32* %10
br label %21
21: ; preds = %48, %15
%22 = load i32, i32* %10
%23 = load i32*, i32** %7
%24 = load i32, i32* %9
%25 = add i32 %24, 1
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %23, i64 %26
%28 = load i32, i32* %27
%29 = icmp ult i32 %22, %28
br i1 %29, label %30, label %51
30: ; preds = %21
%31 = load i32*, i32** %6
%32 = load i32, i32* %10
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = load i32, i32* %9
%37 = icmp ugt i32 %35, %36
br i1 %37, label %38, label %47
38: ; preds = %30
%39 = load i32*, i32** %5
%40 = load i32, i32* %9
%41 = load i32*, i32** %6
%42 = load i32, i32* %10
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = call i32 @fprintf(i32* %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %40, i32 %45)
br label %47
47: ; preds = %38, %30
br label %48
48: ; preds = %47
%49 = load i32, i32* %10
%50 = add i32 %49, 1
store i32 %50, i32* %10
br label %21
51: ; preds = %21
br label %52
52: ; preds = %51
%53 = load i32, i32* %9
%54 = add i32 %53, 1
store i32 %54, i32* %9
br label %11
55: ; preds = %11
ret void
}

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