#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 */
double dot_product(double *, double *);
double norm(double *);
scalar_t__ strcmp(char *, char *);
int space_relation(char *operator, double center[3], double vcen[3],
                   double vrad, double vaxis[3]) {
  int k, t;
  double r, d;
  double vector[3];
  for (k = 0; k < 3; k++)
    vector[k] = center[k] - vcen[k];
  r = norm(vector);
  d = dot_product(vector, vaxis);
  if (strcmp(operator, "inside") == 0)
    t = (r <= vrad);
  else if (strcmp(operator, "outside") == 0)
    t = (r > vrad);
  else if (strcmp(operator, "below") == 0)
    t = (d <= 0.0);
  else if (strcmp(operator, "above") == 0)
    t = (d > 0.0);
  else
    t = 0;
  return (t);
}


x86 assembly (clang, -O0):
<space_relation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    1190 <space_relation+0x60>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movslq -0x2c(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1154 <space_relation+0x24>
lea    -0x60(%rbp),%rdi
call   1040 <norm@plt>
movsd  %xmm0,-0x38(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <dot_product@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11e8 <space_relation+0xb8>
movsd  -0x38(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x30(%rbp)
jmp    129a <space_relation+0x16a>
mov    -0x8(%rbp),%rdi
lea    0xe14(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    121c <space_relation+0xec>
movsd  -0x38(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x30(%rbp)
jmp    1295 <space_relation+0x165>
mov    -0x8(%rbp),%rdi
lea    0xde8(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    124e <space_relation+0x11e>
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp),%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x30(%rbp)
jmp    1290 <space_relation+0x160>
mov    -0x8(%rbp),%rdi
lea    0xdbc(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1284 <space_relation+0x154>
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x30(%rbp)
jmp    128b <space_relation+0x15b>
movl   $0x0,-0x30(%rbp)
jmp    1290 <space_relation+0x160>
jmp    1295 <space_relation+0x165>
jmp    129a <space_relation+0x16a>
mov    -0x30(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<space_relation>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rcx,%r15
movsd  %xmm0,0x18(%rsp)
mov    %rdi,%r14
movupd (%rsi),%xmm0
movupd (%rdx),%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x20(%rsp)
movsd  0x10(%rsi),%xmm0
subsd  0x10(%rdx),%xmm0
movsd  %xmm0,0x30(%rsp)
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <norm@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <dot_product@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe6e(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11f1 <space_relation+0xc1>
lea    0xe61(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ff <space_relation+0xcf>
lea    0xe55(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1210 <space_relation+0xe0>
lea    0xe47(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
sete   %cl
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
seta   %al
and    %cl,%al
jmp    121d <space_relation+0xed>
movsd  0x18(%rsp),%xmm0
ucomisd 0x10(%rsp),%xmm0
jmp    121a <space_relation+0xea>
movsd  0x10(%rsp),%xmm0
ucomisd 0x18(%rsp),%xmm0
seta   %al
jmp    121d <space_relation+0xed>
xorpd  %xmm0,%xmm0
ucomisd 0x8(%rsp),%xmm0
setae  %al
movzbl %al,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"inside\00"
@.str.1 = [8 x i8] c"outside\00"
@.str.2 = [6 x i8] c"below\00"
@.str.3 = [6 x i8] c"above\00"
define i32 @space_relation(i8* %0, double* %1, double* %2, double %3, double* %4) {
%6 = alloca i8*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca [3 x double]
store i8* %0, i8** %6
store double* %1, double** %7
store double* %2, double** %8
store double %3, double* %9
store double* %4, double** %10
store i32 0, i32* %11
br label %16
16: ; preds = %34, %5
%17 = load i32, i32* %11
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %37
19: ; preds = %16
%20 = load double*, double** %7
%21 = load i32, i32* %11
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = load double*, double** %8
%26 = load i32, i32* %11
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = fsub double %24, %29
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 %32
store double %30, double* %33
br label %34
34: ; preds = %19
%35 = load i32, i32* %11
%36 = add nsw i32 %35, 1
store i32 %36, i32* %11
br label %16
37: ; preds = %16
%38 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 0
%39 = call double @norm(double* %38)
store double %39, double* %13
%40 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 0
%41 = load double*, double** %10
%42 = call double @dot_product(double* %40, double* %41)
store double %42, double* %14
%43 = load i8*, i8** %6
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %37
%47 = load double, double* %13
%48 = load double, double* %9
%49 = fcmp ole double %47, %48
%50 = zext i1 %49 to i32
store i32 %50, i32* %12
br label %80
51: ; preds = %37
%52 = load i8*, i8** %6
%53 = call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %60
55: ; preds = %51
%56 = load double, double* %13
%57 = load double, double* %9
%58 = fcmp ogt double %56, %57
%59 = zext i1 %58 to i32
store i32 %59, i32* %12
br label %79
60: ; preds = %51
%61 = load i8*, i8** %6
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %60
%65 = load double, double* %14
%66 = fcmp ole double %65, 0.000000e+00
%67 = zext i1 %66 to i32
store i32 %67, i32* %12
br label %78
68: ; preds = %60
%69 = load i8*, i8** %6
%70 = call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %76
72: ; preds = %68
%73 = load double, double* %14
%74 = fcmp ogt double %73, 0.000000e+00
%75 = zext i1 %74 to i32
store i32 %75, i32* %12
br label %77
76: ; preds = %68
store i32 0, i32* %12
br label %77
77: ; preds = %76, %72
br label %78
78: ; preds = %77, %64
br label %79
79: ; preds = %78, %55
br label %80
80: ; preds = %79, %46
%81 = load i32, i32* %12
ret i32 %81
}

LLVM IR (-O2):
@.str = [7 x i8] c"inside\00"
@.str.1 = [8 x i8] c"outside\00"
@.str.2 = [6 x i8] c"below\00"
@.str.3 = [6 x i8] c"above\00"
define i32 @space_relation(i8* %0, double* nocapture %1, double* nocapture %2, double %3, double* %4) {
%6 = alloca [3 x double]
%7 = bitcast [3 x double]* %6 to i8*
%8 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%9 = bitcast double* %1 to <2 x double>*
%10 = load <2 x double>, <2 x double>* %9
%11 = bitcast double* %2 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = fsub <2 x double> %10, %12
%14 = bitcast [3 x double]* %6 to <2 x double>*
store <2 x double> %13, <2 x double>* %14
%15 = getelementptr inbounds double, double* %1, i64 2
%16 = load double, double* %15
%17 = getelementptr inbounds double, double* %2, i64 2
%18 = load double, double* %17
%19 = fsub double %16, %18
%20 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
store double %19, double* %20
%21 = call double @norm(double* %8)
%22 = call double @dot_product(double* %8, double* %4)
%23 = call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %5
%26 = fcmp ole double %21, %3
br label %42
27: ; preds = %5
%28 = call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = fcmp ogt double %21, %3
br label %42
32: ; preds = %27
%33 = call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = fcmp ole double %22, 0.000000e+00
br label %42
37: ; preds = %32
%38 = call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
%40 = fcmp ogt double %22, 0.000000e+00
%41 = select i1 %39, i1 %40, i1 false
br label %42
42: ; preds = %37, %30, %35, %25
%43 = phi i1 [ %26, %25 ], [ %31, %30 ], [ %36, %35 ], [ %41, %37 ]
%44 = zext i1 %43 to i32
ret i32 %44
}