#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fmprint(double *, int, int, int /*<<< orphan*/ *);
double minimumc(double *, int, int, int, int *);
double minimumr(double *, int, int /*<<< orphan*/, int *);
int simplexd(double *, int, int, int, int /*<<< orphan*/ *);
int simplexp(double *, int, int, int, int /*<<< orphan*/ *);
int simplex(double *a, int n, int m, FILE *file) {
  double aux;
  int pos = 0, nm2, err = 0;
  nm2 = n + m + 2;
  aux = minimumc(&a[nm2], m, nm2, n + m, &pos);
  if (file)
    fmprint(a, m + 1, nm2, file);
  if (aux < 0)
    err = simplexd(a, n, m, pos + 1, file);
  if (!err) {
    aux = minimumr(a, nm2, 0, &pos);
    if (aux < 0)
      err = simplexp(a, n, m, pos, file);
  }
  return err;
}


x86 assembly (clang, -O0):
<simplex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0xc(%rbp),%ecx
add    -0x10(%rbp),%ecx
lea    -0x24(%rbp),%r8
call   1050 <minimumc@plt>
movsd  %xmm0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ca <simplex+0x7a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    $0x1,%esi
mov    -0x28(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1060 <fmprint@plt>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11f4 <simplex+0xa4>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%r8
call   1070 <simplexd@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1241 <simplex+0xf1>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
xor    %edx,%edx
lea    -0x24(%rbp),%rcx
call   1040 <minimumr@plt>
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    123c <simplex+0xec>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%r8
call   1030 <simplexp@plt>
mov    %eax,-0x2c(%rbp)
jmp    1241 <simplex+0xf1>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simplex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %edx,%ebx
mov    %esi,%r15d
mov    %rdi,%r12
movl   $0x0,0xc(%rsp)
lea    (%rbx,%r15,1),%eax
lea    0x2(%rbx,%r15,1),%r13d
movslq %eax,%rcx
lea    0x10(%rdi,%rcx,8),%rdi
lea    0xc(%rsp),%r8
mov    %edx,%esi
mov    %r13d,%edx
call   1050 <minimumc@plt>
test   %r14,%r14
je     11b3 <simplex+0x63>
lea    0x1(%rbx),%esi
mov    %r12,%rdi
mov    %r13d,%edx
mov    %r14,%rcx
movsd  %xmm0,0x10(%rsp)
call   1060 <fmprint@plt>
movsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    11da <simplex+0x8a>
mov    0xc(%rsp),%ecx
add    $0x1,%ecx
mov    %r12,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %r14,%r8
call   1070 <simplexd@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    120e <simplex+0xbe>
xor    %ebp,%ebp
lea    0xc(%rsp),%rcx
mov    %r12,%rdi
mov    %r13d,%esi
xor    %edx,%edx
call   1040 <minimumr@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    120e <simplex+0xbe>
mov    0xc(%rsp),%ecx
mov    %r12,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %r14,%r8
call   1030 <simplexp@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @simplex(double* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
store i32 0, i32* %10
store i32 0, i32* %12
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = add nsw i32 %13, %14
%16 = add nsw i32 %15, 2
store i32 %16, i32* %11
%17 = load double*, double** %5
%18 = load i32, i32* %11
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load i32, i32* %7
%22 = load i32, i32* %11
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = add nsw i32 %23, %24
%26 = call double @minimumc(double* %20, i32 %21, i32 %22, i32 %25, i32* %10)
store double %26, double* %9
%27 = load i32*, i32** %8
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %36
29: ; preds = %4
%30 = load double*, double** %5
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
%33 = load i32, i32* %11
%34 = load i32*, i32** %8
%35 = call i32 @fmprint(double* %30, i32 %32, i32 %33, i32* %34)
br label %36
36: ; preds = %29, %4
%37 = load double, double* %9
%38 = fcmp olt double %37, 0.000000e+00
br i1 %38, label %39, label %47
39: ; preds = %36
%40 = load double*, double** %5
%41 = load i32, i32* %6
%42 = load i32, i32* %7
%43 = load i32, i32* %10
%44 = add nsw i32 %43, 1
%45 = load i32*, i32** %8
%46 = call i32 @simplexd(double* %40, i32 %41, i32 %42, i32 %44, i32* %45)
store i32 %46, i32* %12
br label %47
47: ; preds = %39, %36
%48 = load i32, i32* %12
%49 = icmp ne i32 %48, 0
br i1 %49, label %64, label %50
50: ; preds = %47
%51 = load double*, double** %5
%52 = load i32, i32* %11
%53 = call double @minimumr(double* %51, i32 %52, i32 0, i32* %10)
store double %53, double* %9
%54 = load double, double* %9
%55 = fcmp olt double %54, 0.000000e+00
br i1 %55, label %56, label %63
56: ; preds = %50
%57 = load double*, double** %5
%58 = load i32, i32* %6
%59 = load i32, i32* %7
%60 = load i32, i32* %10
%61 = load i32*, i32** %8
%62 = call i32 @simplexp(double* %57, i32 %58, i32 %59, i32 %60, i32* %61)
store i32 %62, i32* %12
br label %63
63: ; preds = %56, %50
br label %64
64: ; preds = %63, %47
%65 = load i32, i32* %12
ret i32 %65
}

LLVM IR (-O2):
define i32 @simplex(double* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%7 = add nsw i32 %2, %1
%8 = add nsw i32 %7, 2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = call double @minimumc(double* %10, i32 %2, i32 %8, i32 %7, i32* %5)
%12 = icmp eq i32* %3, null
br i1 %12, label %16, label %13
13: ; preds = %4
%14 = add nsw i32 %2, 1
%15 = call i32 @fmprint(double* %0, i32 %14, i32 %8, i32* %3)
br label %16
16: ; preds = %13, %4
%17 = fcmp olt double %11, 0.000000e+00
br i1 %17, label %18, label %23
18: ; preds = %16
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
%21 = call i32 @simplexd(double* %0, i32 %1, i32 %2, i32 %20, i32* %3)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %16, %18
%24 = call double @minimumr(double* %0, i32 %8, i32 0, i32* %5)
%25 = fcmp olt double %24, 0.000000e+00
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %5
%28 = call i32 @simplexp(double* %0, i32 %1, i32 %2, i32 %27, i32* %3)
br label %29
29: ; preds = %23, %26, %18
%30 = phi i32 [ %21, %18 ], [ %28, %26 ], [ 0, %23 ]
ret i32 %30
}