#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 *calloc(int, int);
int /*<<< orphan*/ divide(int, int *, int **, int, int, int *, int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void findRings(int nbAtoms, int *nBonds, int **bonds, int *nRings, int **rings,
               int *seen, int *buf) {
  int at1, at2;
  int aBond, aCycle, cycleSze, newCycle;
  int i, isSame, aRing;
  int *ringSze;
  ringSze = calloc(nbAtoms, sizeof(int));
  *nRings = 0;
  fprintf(stderr, "findRings:\n");
  for (at1 = 0; at1 < nbAtoms; at1++) {
    for (aBond = 0; aBond < nBonds[at1]; aBond++) {
      at2 = bonds[at1][aBond];
      if (at2 < at1)
        continue;
      if (!divide(nbAtoms, nBonds, bonds, at1, at2, seen, buf)) {
        rings[at1][at2] = rings[at2][at1] = 1;
      }
    }
  }
  fprintf(stderr, "findRings: found %d rings\n", *nRings);
  for (at1 = 0; at1 < nbAtoms; at1++) {
    for (at2 = 0; at2 < nbAtoms; at2++) {
      fprintf(stderr, "%2d", rings[at1][at2]);
    }
    fprintf(stderr, "\n");
  }
}


x86 assembly (clang, -O0):
<findRings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    125a <findRings+0x12a>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x34(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1247 <findRings+0x117>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11da <findRings+0xaa>
jmp    1239 <findRings+0x109>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%r8d
mov    -0x30(%rbp),%r9
mov    0x10(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <divide@plt>
cmp    $0x0,%eax
jne    1234 <findRings+0x104>
mov    -0x28(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    1239 <findRings+0x109>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    119f <findRings+0x6f>
jmp    124c <findRings+0x11c>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118c <findRings+0x5c>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12fa <findRings+0x1ca>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12d5 <findRings+0x1a5>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xd67(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1291 <findRings+0x161>
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
lea    0xd25(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    127e <findRings+0x14e>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findRings>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x30(%rsp)
mov    %r8,%r13
mov    %rcx,%r12
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %edi,%r15d
mov    0x70(%rsp),%rax
mov    %rax,0x28(%rsp)
mov    $0x4,%esi
call   1040 <calloc@plt>
movl   $0x0,(%r12)
mov    0x2e6b(%rip),%r14
mov    (%r14),%edi
lea    0xe81(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %r15d,%r15d
jle    12c9 <findRings+0x199>
mov    %r12,0x20(%rsp)
mov    %r15d,0x14(%rsp)
mov    %r15d,%ecx
xor    %r14d,%r14d
mov    %rcx,0x18(%rsp)
jmp    11b9 <findRings+0x89>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %rcx,%r14
je     1233 <findRings+0x103>
cmpl   $0x0,(%rbx,%r14,4)
jle    11b0 <findRings+0x80>
xor    %r12d,%r12d
jmp    11dd <findRings+0xad>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r12
movslq (%rbx,%r14,4),%rax
cmp    %rax,%r12
jge    11b0 <findRings+0x80>
mov    0x0(%rbp,%r14,8),%rax
movslq (%rax,%r12,4),%r15
cmp    %r15,%r14
jg     11d0 <findRings+0xa0>
mov    0x28(%rsp),%rax
mov    %rax,(%rsp)
mov    0x14(%rsp),%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r14d,%ecx
mov    %r15d,%r8d
mov    0x30(%rsp),%r9
call   1030 <divide@plt>
mov    0x18(%rsp),%rcx
test   %eax,%eax
jne    11d0 <findRings+0xa0>
mov    0x0(%r13,%r15,8),%rax
movl   $0x1,(%rax,%r14,4)
mov    0x0(%r13,%r14,8),%rax
movl   $0x1,(%rax,%r15,4)
jmp    11d0 <findRings+0xa0>
mov    0x2da6(%rip),%r12
mov    (%r12),%edi
mov    0x20(%rsp),%rax
mov    (%rax),%edx
lea    0xdc0(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
cmpl   $0x0,0x14(%rsp)
jle    12ba <findRings+0x18a>
lea    0xdc6(%rip),%r15
xor    %ebp,%ebp
mov    0x18(%rsp),%r14
nopl   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12),%edi
mov    0x0(%r13,%rbp,8),%rax
mov    (%rax,%rbx,4),%edx
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1280 <findRings+0x150>
mov    (%r12),%edi
lea    0xd60(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%rbp
cmp    %r14,%rbp
jne    1270 <findRings+0x140>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r14),%edi
mov    (%r12),%edx
lea    0xd35(%rip),%rsi
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c"findRings:\0A\00"
@.str.1 = [27 x i8] c"findRings: found %d rings\0A\00"
@.str.2 = [4 x i8] c"%2d\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @findRings(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
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = 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
%25 = load i32, i32* %8
%26 = call i32* @calloc(i32 %25, i32 4)
store i32* %26, i32** %24
%27 = load i32*, i32** %11
store i32 0, i32* %27
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %15
br label %30
30: ; preds = %89, %7
%31 = load i32, i32* %15
%32 = load i32, i32* %8
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %92
34: ; preds = %30
store i32 0, i32* %17
br label %35
35: ; preds = %85, %34
%36 = load i32, i32* %17
%37 = load i32*, i32** %9
%38 = load i32, i32* %15
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = load i32, i32* %40
%42 = icmp slt i32 %36, %41
br i1 %42, label %43, label %88
43: ; preds = %35
%44 = load i32**, i32*** %10
%45 = load i32, i32* %15
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32*, i32** %44, i64 %46
%48 = load i32*, i32** %47
%49 = load i32, i32* %17
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
%52 = load i32, i32* %51
store i32 %52, i32* %16
%53 = load i32, i32* %16
%54 = load i32, i32* %15
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %57
56: ; preds = %43
br label %85
57: ; preds = %43
%58 = load i32, i32* %8
%59 = load i32*, i32** %9
%60 = load i32**, i32*** %10
%61 = load i32, i32* %15
%62 = load i32, i32* %16
%63 = load i32*, i32** %13
%64 = load i32*, i32** %14
%65 = call i32 @divide(i32 %58, i32* %59, i32** %60, i32 %61, i32 %62, i32* %63, i32* %64)
%66 = icmp ne i32 %65, 0
br i1 %66, label %84, label %67
67: ; preds = %57
%68 = load i32**, i32*** %12
%69 = load i32, i32* %16
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32*, i32** %68, i64 %70
%72 = load i32*, i32** %71
%73 = load i32, i32* %15
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %72, i64 %74
store i32 1, i32* %75
%76 = load i32**, i32*** %12
%77 = load i32, i32* %15
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i32*, i32** %76, i64 %78
%80 = load i32*, i32** %79
%81 = load i32, i32* %16
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i32, i32* %80, i64 %82
store i32 1, i32* %83
br label %84
84: ; preds = %67, %57
br label %85
85: ; preds = %84, %56
%86 = load i32, i32* %17
%87 = add nsw i32 %86, 1
store i32 %87, i32* %17
br label %35
88: ; preds = %35
br label %89
89: ; preds = %88
%90 = load i32, i32* %15
%91 = add nsw i32 %90, 1
store i32 %91, i32* %15
br label %30
92: ; preds = %30
%93 = load i32, i32* @stderr
%94 = load i32*, i32** %11
%95 = load i32, i32* %94
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %95)
store i32 0, i32* %15
br label %97
97: ; preds = %124, %92
%98 = load i32, i32* %15
%99 = load i32, i32* %8
%100 = icmp slt i32 %98, %99
br i1 %100, label %101, label %127
101: ; preds = %97
store i32 0, i32* %16
br label %102
102: ; preds = %118, %101
%103 = load i32, i32* %16
%104 = load i32, i32* %8
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %121
106: ; preds = %102
%107 = load i32, i32* @stderr
%108 = load i32**, i32*** %12
%109 = load i32, i32* %15
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i32*, i32** %108, i64 %110
%112 = load i32*, i32** %111
%113 = load i32, i32* %16
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i32, i32* %112, i64 %114
%116 = load i32, i32* %115
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %116)
br label %118
118: ; preds = %106
%119 = load i32, i32* %16
%120 = add nsw i32 %119, 1
store i32 %120, i32* %16
br label %102
121: ; preds = %102
%122 = load i32, i32* @stderr
%123 = call i32 (i32, i8*, ...) @fprintf(i32 %122, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %124
124: ; preds = %121
%125 = load i32, i32* %15
%126 = add nsw i32 %125, 1
store i32 %126, i32* %15
br label %97
127: ; preds = %97
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [12 x i8] c"findRings:\0A\00"
@.str.1 = [27 x i8] c"findRings: found %d rings\0A\00"
@.str.2 = [4 x i8] c"%2d\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @findRings(i32 %0, i32* %1, i32** %2, i32* nocapture %3, i32** nocapture %4, i32* %5, i32* %6) {
%8 = tail call i32* @calloc(i32 %0, i32 4)
store i32 0, i32* %3
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%11 = icmp sgt i32 %0, 0
br i1 %11, label %16, label %12
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = load i32, i32* %3
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %74
16: ; preds = %7
%17 = zext i32 %0 to i64
br label %18
18: ; preds = %16, %48
%19 = phi i64 [ 0, %16 ], [ %49, %48 ]
%20 = getelementptr inbounds i32, i32* %1, i64 %19
%21 = load i32, i32* %20
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %48
23: ; preds = %18
%24 = getelementptr inbounds i32*, i32** %2, i64 %19
%25 = getelementptr inbounds i32*, i32** %4, i64 %19
%26 = trunc i64 %19 to i32
br label %27
27: ; preds = %23, %43
%28 = phi i64 [ 0, %23 ], [ %44, %43 ]
%29 = load i32*, i32** %24
%30 = getelementptr inbounds i32, i32* %29, i64 %28
%31 = load i32, i32* %30
%32 = sext i32 %31 to i64
%33 = icmp sgt i64 %19, %32
br i1 %33, label %43, label %34
34: ; preds = %27
%35 = tail call i32 @divide(i32 %0, i32* %1, i32** %2, i32 %26, i32 %31, i32* %5, i32* %6)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %34
%38 = getelementptr inbounds i32*, i32** %4, i64 %32
%39 = load i32*, i32** %38
%40 = getelementptr inbounds i32, i32* %39, i64 %19
store i32 1, i32* %40
%41 = load i32*, i32** %25
%42 = getelementptr inbounds i32, i32* %41, i64 %32
store i32 1, i32* %42
br label %43
43: ; preds = %34, %37, %27
%44 = add nuw nsw i64 %28, 1
%45 = load i32, i32* %20
%46 = sext i32 %45 to i64
%47 = icmp slt i64 %44, %46
br i1 %47, label %27, label %48
48: ; preds = %43, %18
%49 = add nuw nsw i64 %19, 1
%50 = icmp eq i64 %49, %17
br i1 %50, label %51, label %18
51: ; preds = %48
%52 = load i32, i32* @stderr
%53 = load i32, i32* %3
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %53)
br i1 %11, label %55, label %74
55: ; preds = %51
%56 = zext i32 %0 to i64
br label %57
57: ; preds = %69, %55
%58 = phi i64 [ 0, %55 ], [ %72, %69 ]
%59 = getelementptr inbounds i32*, i32** %4, i64 %58
br label %60
60: ; preds = %57, %60
%61 = phi i64 [ 0, %57 ], [ %67, %60 ]
%62 = load i32, i32* @stderr
%63 = load i32*, i32** %59
%64 = getelementptr inbounds i32, i32* %63, i64 %61
%65 = load i32, i32* %64
%66 = tail call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %65)
%67 = add nuw nsw i64 %61, 1
%68 = icmp eq i64 %67, %56
br i1 %68, label %69, label %60
69: ; preds = %60
%70 = load i32, i32* @stderr
%71 = tail call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%72 = add nuw nsw i64 %58, 1
%73 = icmp eq i64 %72, %56
br i1 %73, label %74, label %57
74: ; preds = %69, %12, %51
ret void
}