#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 *maximal_support_point(double *, int, double *);
double *minimal_support_point(double *, int, double *);
double gjk_convex_convex_gap(double *a, int na, double *b, int nb,
                             double *normal) {
  double *p, *q, d[3];
  p = maximal_support_point(a, na, normal);
  q = minimal_support_point(b, nb, normal);
  {
    (d)[0] = (q)[0] - (p)[0];
    (d)[1] = (q)[1] - (p)[1];
    (d)[2] = (q)[2] - (p)[2];
  };
  return ((normal)[0] * (d)[0] + (normal)[1] * (d)[1] + (normal)[2] * (d)[2]);
}


x86 assembly (clang, -O0):
<gjk_convex_convex_gap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1030 <maximal_support_point@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1040 <minimal_support_point@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x38(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x30(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x38(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x30(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x50(%rbp),%xmm2
mov    -0x28(%rbp),%rax
movsd  0x8(%rax),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x28(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gjk_convex_convex_gap>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8,%rbx
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %r8,%rdx
call   1030 <maximal_support_point@plt>
mov    %rax,%rbp
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1040 <minimal_support_point@plt>
movsd  (%rax),%xmm1
movsd  0x8(%rax),%xmm2
subsd  0x0(%rbp),%xmm1
subsd  0x8(%rbp),%xmm2
movsd  0x10(%rax),%xmm0
subsd  0x10(%rbp),%xmm0
mulsd  0x8(%rbx),%xmm2
mulsd  (%rbx),%xmm1
addsd  %xmm2,%xmm1
mulsd  0x10(%rbx),%xmm0
addsd  %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @gjk_convex_convex_gap(double* %0, i32 %1, double* %2, i32 %3, double* %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca double*
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca [3 x double]
store double* %0, double** %6
store i32 %1, i32* %7
store double* %2, double** %8
store i32 %3, i32* %9
store double* %4, double** %10
%14 = load double*, double** %6
%15 = load i32, i32* %7
%16 = load double*, double** %10
%17 = call double* @maximal_support_point(double* %14, i32 %15, double* %16)
store double* %17, double** %11
%18 = load double*, double** %8
%19 = load i32, i32* %9
%20 = load double*, double** %10
%21 = call double* @minimal_support_point(double* %18, i32 %19, double* %20)
store double* %21, double** %12
%22 = load double*, double** %12
%23 = getelementptr inbounds double, double* %22, i64 0
%24 = load double, double* %23
%25 = load double*, double** %11
%26 = getelementptr inbounds double, double* %25, i64 0
%27 = load double, double* %26
%28 = fsub double %24, %27
%29 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
store double %28, double* %29
%30 = load double*, double** %12
%31 = getelementptr inbounds double, double* %30, i64 1
%32 = load double, double* %31
%33 = load double*, double** %11
%34 = getelementptr inbounds double, double* %33, i64 1
%35 = load double, double* %34
%36 = fsub double %32, %35
%37 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 1
store double %36, double* %37
%38 = load double*, double** %12
%39 = getelementptr inbounds double, double* %38, i64 2
%40 = load double, double* %39
%41 = load double*, double** %11
%42 = getelementptr inbounds double, double* %41, i64 2
%43 = load double, double* %42
%44 = fsub double %40, %43
%45 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 2
store double %44, double* %45
%46 = load double*, double** %10
%47 = getelementptr inbounds double, double* %46, i64 0
%48 = load double, double* %47
%49 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%50 = load double, double* %49
%51 = load double*, double** %10
%52 = getelementptr inbounds double, double* %51, i64 1
%53 = load double, double* %52
%54 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 1
%55 = load double, double* %54
%56 = fmul double %53, %55
%57 = call double @llvm.fmuladd.f64(double %48, double %50, double %56)
%58 = load double*, double** %10
%59 = getelementptr inbounds double, double* %58, i64 2
%60 = load double, double* %59
%61 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 2
%62 = load double, double* %61
%63 = call double @llvm.fmuladd.f64(double %60, double %62, double %57)
ret double %63
}

LLVM IR (-O2):
define double @gjk_convex_convex_gap(double* %0, i32 %1, double* %2, i32 %3, double* %4) {
%6 = tail call double* @maximal_support_point(double* %0, i32 %1, double* %4)
%7 = tail call double* @minimal_support_point(double* %2, i32 %3, double* %4)
%8 = load double, double* %7
%9 = load double, double* %6
%10 = fsub double %8, %9
%11 = getelementptr inbounds double, double* %7, i64 1
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %6, i64 1
%14 = load double, double* %13
%15 = fsub double %12, %14
%16 = getelementptr inbounds double, double* %7, i64 2
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %6, i64 2
%19 = load double, double* %18
%20 = fsub double %17, %19
%21 = load double, double* %4
%22 = getelementptr inbounds double, double* %4, i64 1
%23 = load double, double* %22
%24 = fmul double %15, %23
%25 = tail call double @llvm.fmuladd.f64(double %21, double %10, double %24)
%26 = getelementptr inbounds double, double* %4, i64 2
%27 = load double, double* %26
%28 = tail call double @llvm.fmuladd.f64(double %27, double %20, double %25)
ret double %28
}