#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 */
long find_1st_atom(char *, char **, long, long, char *);
void bring_atoms(long ib, long ie, long rnum, char **AtomName, long *nmatch,
                 long *batom) {
  static char *RingAtom[9] = {" C4 ", " N3 ", " C2 ", " N1 ", " C6 ",
                              " C5 ", " N7 ", " C8 ", " N9 "};
  long i, j;
  *nmatch = 0;
  for (i = 0; i < rnum; i++) {
    j = find_1st_atom(RingAtom[i], AtomName, ib, ie, "in base ring atoms");
    if (j)
      batom[++*nmatch] = j;
  }
}


x86 assembly (clang, -O0):
<bring_atoms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11bb <bring_atoms+0xab>
mov    -0x38(%rbp),%rcx
lea    0x2ed4(%rip),%rax
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xeba(%rip),%r8
call   1030 <find_1st_atom@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     11a5 <bring_atoms+0x95>
mov    -0x40(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rsi
mov    (%rsi),%rcx
mov    %rcx,%rdi
add    $0x1,%rdi
mov    %rdi,(%rsi)
mov    %rdx,0x8(%rax,%rcx,8)
jmp    11aa <bring_atoms+0x9a>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1143 <bring_atoms+0x33>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bring_atoms>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,(%rsp)
movq   $0x0,(%r8)
test   %rdx,%rdx
jle    1198 <bring_atoms+0x88>
mov    %r8,%r12
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r13
mov    %rdi,%rbp
lea    0xebf(%rip),%r14
jmp    115a <bring_atoms+0x4a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x4,%r14
add    $0xffffffffffffffff,%rbx
je     1198 <bring_atoms+0x88>
movslq (%r14),%rdi
lea    0xe9c(%rip),%rax
add    %rax,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %r13,%rcx
lea    0xeda(%rip),%r8
call   1030 <find_1st_atom@plt>
test   %rax,%rax
je     1150 <bring_atoms+0x40>
mov    (%r12),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,(%r12)
mov    (%rsp),%rdx
mov    %rax,0x8(%rdx,%rcx,8)
jmp    1150 <bring_atoms+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@bring_atoms.RingAtom = internal global [9 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0)]
@.str = [5 x i8] c" C4 \00"
@.str.1 = [5 x i8] c" N3 \00"
@.str.2 = [5 x i8] c" C2 \00"
@.str.3 = [5 x i8] c" N1 \00"
@.str.4 = [5 x i8] c" C6 \00"
@.str.5 = [5 x i8] c" C5 \00"
@.str.6 = [5 x i8] c" N7 \00"
@.str.7 = [5 x i8] c" C8 \00"
@.str.8 = [5 x i8] c" N9 \00"
@.str.9 = [19 x i8] c"in base ring atoms\00"
define void @bring_atoms(i64 %0, i64 %1, i64 %2, i8** %3, i64* %4, i64* %5) {
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8**
%11 = alloca i64*
%12 = alloca i64*
%13 = alloca i64
%14 = alloca i64
store i64 %0, i64* %7
store i64 %1, i64* %8
store i64 %2, i64* %9
store i8** %3, i8*** %10
store i64* %4, i64** %11
store i64* %5, i64** %12
%15 = load i64*, i64** %11
store i64 0, i64* %15
store i64 0, i64* %13
br label %16
16: ; preds = %38, %6
%17 = load i64, i64* %13
%18 = load i64, i64* %9
%19 = icmp slt i64 %17, %18
br i1 %19, label %20, label %41
20: ; preds = %16
%21 = load i64, i64* %13
%22 = getelementptr inbounds [9 x i8*], [9 x i8*]* @bring_atoms.RingAtom, i64 0, i64 %21
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %10
%25 = load i64, i64* %7
%26 = load i64, i64* %8
%27 = call i64 @find_1st_atom(i8* %23, i8** %24, i64 %25, i64 %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
store i64 %27, i64* %14
%28 = load i64, i64* %14
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %20
%31 = load i64, i64* %14
%32 = load i64*, i64** %12
%33 = load i64*, i64** %11
%34 = load i64, i64* %33
%35 = add nsw i64 %34, 1
store i64 %35, i64* %33
%36 = getelementptr inbounds i64, i64* %32, i64 %35
store i64 %31, i64* %36
br label %37
37: ; preds = %30, %20
br label %38
38: ; preds = %37
%39 = load i64, i64* %13
%40 = add nsw i64 %39, 1
store i64 %40, i64* %13
br label %16
41: ; preds = %16
ret void
}

LLVM IR (-O2):
@reltable.bring_atoms = internal unnamed_addr constant [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([9 x i32]* @reltable.bring_atoms to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([9 x i32]* @reltable.bring_atoms to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([9 x i32]* @reltable.bring_atoms to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([9 x i32]* @reltable.bring_atoms to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.bring_atoms to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.bring_atoms to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.bring_atoms to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.7 to i64), i64 ptrtoint ([9 x i32]* @reltable.bring_atoms to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.8 to i64), i64 ptrtoint ([9 x i32]* @reltable.bring_atoms to i64)) to i32)]
@.str = [5 x i8] c" C4 \00"
@.str.1 = [5 x i8] c" N3 \00"
@.str.2 = [5 x i8] c" C2 \00"
@.str.3 = [5 x i8] c" N1 \00"
@.str.4 = [5 x i8] c" C6 \00"
@.str.5 = [5 x i8] c" C5 \00"
@.str.6 = [5 x i8] c" N7 \00"
@.str.7 = [5 x i8] c" C8 \00"
@.str.8 = [5 x i8] c" N9 \00"
@.str.9 = [19 x i8] c"in base ring atoms\00"
define void @bring_atoms(i64 %0, i64 %1, i64 %2, i8** %3, i64* nocapture %4, i64* nocapture writeonly %5) {
store i64 0, i64* %4
%7 = icmp sgt i64 %2, 0
br i1 %7, label %8, label %21
8: ; preds = %6, %18
%9 = phi i64 [ %19, %18 ], [ 0, %6 ]
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.bring_atoms to i8*), i64 %10)
%12 = tail call i64 @find_1st_atom(i8* %11, i8** %3, i64 %0, i64 %1, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %8
%15 = load i64, i64* %4
%16 = add nsw i64 %15, 1
store i64 %16, i64* %4
%17 = getelementptr inbounds i64, i64* %5, i64 %16
store i64 %12, i64* %17
br label %18
18: ; preds = %8, %14
%19 = add nuw nsw i64 %9, 1
%20 = icmp eq i64 %19, %2
br i1 %20, label %21, label %8
21: ; preds = %18, %6
ret void
}