#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*/ get_atom_center(int, double *);
int /*<<< orphan*/ get_region_center(int, double *);
int /*<<< orphan*/ get_region_direction(int, double *);
double get_region_radius(int);
int /*<<< orphan*/ include_member(int, int, int);
int init_for(int);
int lookup_region(char *);
int next_for(int);
int space_relation(char *, double *, double *, double, double *);
void center_field(int from_set, int to_set, char *operator, char * value) {
  int region_number, o, t;
  double vrad;
  double center[3], vcen[3], vaxis[3];
  region_number = lookup_region(value);
  get_region_center(region_number, vcen);
  vrad = get_region_radius(region_number);
  get_region_direction(region_number, vaxis);
  for (o = init_for(from_set); o != 0; o = next_for(from_set)) {
    get_atom_center(o, center);
    t = space_relation(operator, center, vcen, vrad, vaxis);
    if (t)
      include_member(to_set, 6, o);
  }
}


x86 assembly (clang, -O0):
<center_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   10b0 <lookup_region@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1090 <get_region_center@plt>
mov    -0x1c(%rbp),%edi
call   1080 <get_region_radius@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x90(%rbp),%rsi
call   1050 <get_region_direction@plt>
mov    -0x4(%rbp),%edi
call   1030 <init_for@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     124d <center_field+0xbd>
mov    -0x20(%rbp),%edi
lea    -0x50(%rbp),%rsi
call   1060 <get_atom_center@plt>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x70(%rbp),%rdx
movsd  -0x30(%rbp),%xmm0
lea    -0x90(%rbp),%rcx
call   1040 <space_relation@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1238 <center_field+0xa8>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%edx
mov    $0x6,%esi
call   1070 <include_member@plt>
jmp    123d <center_field+0xad>
mov    -0x4(%rbp),%edi
call   10a0 <next_for@plt>
mov    %eax,-0x20(%rbp)
jmp    11e8 <center_field+0x58>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<center_field>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdx,%r15
mov    %esi,0x4(%rsp)
mov    %edi,%r13d
mov    %rcx,%rdi
call   10b0 <lookup_region@plt>
mov    %eax,%ebx
lea    0x30(%rsp),%rsi
mov    %eax,%edi
call   1090 <get_region_center@plt>
mov    %ebx,%edi
call   1080 <get_region_radius@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
call   1050 <get_region_direction@plt>
mov    %r13d,%edi
call   1030 <init_for@plt>
test   %eax,%eax
je     1245 <center_field+0xb5>
mov    %eax,%ebp
lea    0x50(%rsp),%rbx
lea    0x30(%rsp),%r12
lea    0x10(%rsp),%r14
jmp    120e <center_field+0x7e>
cs nopw 0x0(%rax,%rax,1)
mov    %r13d,%edi
call   10a0 <next_for@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1245 <center_field+0xb5>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <get_atom_center@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
movsd  0x8(%rsp),%xmm0
mov    %r14,%rcx
call   1040 <space_relation@plt>
test   %eax,%eax
je     1200 <center_field+0x70>
mov    0x4(%rsp),%edi
mov    $0x6,%esi
mov    %ebp,%edx
call   1070 <include_member@plt>
jmp    1200 <center_field+0x70>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @center_field(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca [3 x double]
%14 = alloca [3 x double]
%15 = alloca [3 x double]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%16 = load i8*, i8** %8
%17 = call i32 @lookup_region(i8* %16)
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
%20 = call i32 @get_region_center(i32 %18, double* %19)
%21 = load i32, i32* %9
%22 = call double @get_region_radius(i32 %21)
store double %22, double* %12
%23 = load i32, i32* %9
%24 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 0
%25 = call i32 @get_region_direction(i32 %23, double* %24)
%26 = load i32, i32* %5
%27 = call i32 @init_for(i32 %26)
store i32 %27, i32* %10
br label %28
28: ; preds = %48, %4
%29 = load i32, i32* %10
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %51
31: ; preds = %28
%32 = load i32, i32* %10
%33 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%34 = call i32 @get_atom_center(i32 %32, double* %33)
%35 = load i8*, i8** %7
%36 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%37 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
%38 = load double, double* %12
%39 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 0
%40 = call i32 @space_relation(i8* %35, double* %36, double* %37, double %38, double* %39)
store i32 %40, i32* %11
%41 = load i32, i32* %11
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %31
%44 = load i32, i32* %6
%45 = load i32, i32* %10
%46 = call i32 @include_member(i32 %44, i32 6, i32 %45)
br label %47
47: ; preds = %43, %31
br label %48
48: ; preds = %47
%49 = load i32, i32* %5
%50 = call i32 @next_for(i32 %49)
store i32 %50, i32* %10
br label %28
51: ; preds = %28
ret void
}

LLVM IR (-O2):
define void @center_field(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = alloca [3 x double]
%8 = bitcast [3 x double]* %5 to i8*
%9 = bitcast [3 x double]* %6 to i8*
%10 = bitcast [3 x double]* %7 to i8*
%11 = tail call i32 @lookup_region(i8* %3)
%12 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%13 = call i32 @get_region_center(i32 %11, double* %12)
%14 = call double @get_region_radius(i32 %11)
%15 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%16 = call i32 @get_region_direction(i32 %11, double* %15)
%17 = call i32 @init_for(i32 %0)
%18 = icmp eq i32 %17, 0
br i1 %18, label %31, label %19
19: ; preds = %4
%20 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
br label %21
21: ; preds = %19, %28
%22 = phi i32 [ %17, %19 ], [ %29, %28 ]
%23 = call i32 @get_atom_center(i32 %22, double* %20)
%24 = call i32 @space_relation(i8* %2, double* %20, double* %12, double %14, double* %15)
%25 = icmp eq i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %21
%27 = call i32 @include_member(i32 %1, i32 6, i32 %22)
br label %28
28: ; preds = %21, %26
%29 = call i32 @next_for(i32 %0)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %21
31: ; preds = %28, %4
ret void
}