#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*/ backsb(double *, int, double *);
int /*<<< orphan*/ elim(double *, int, int);
unsigned short order(double *, int, int);
int gauss(double *matrix, int n, double *soln) {
  int pivot = 0;
  unsigned short error = 0;
  while ((pivot < (n - 1)) && (!error)) {
    if (!(error = order(matrix, n, pivot))) {
      elim(matrix, n, pivot);
      pivot++;
    }
  }
  if (error) {
    return 1;
  } else {
    backsb(matrix, n, soln);
  }
  return 0;
}


x86 assembly (clang, -O0):
<gauss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movw   $0x0,-0x26(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x27(%rbp)
jge    1173 <gauss+0x43>
cmpw   $0x0,-0x26(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x27(%rbp)
mov    -0x27(%rbp),%al
test   $0x1,%al
jne    1183 <gauss+0x53>
jmp    11bd <gauss+0x8d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1050 <order@plt>
mov    %ax,-0x26(%rbp)
cmp    $0x0,%ax
jne    11b8 <gauss+0x88>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <elim@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1150 <gauss+0x20>
cmpw   $0x0,-0x26(%rbp)
je     11d4 <gauss+0xa4>
movl   $0x1,-0x4(%rbp)
jmp    11eb <gauss+0xbb>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <backsb@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gauss>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,(%rsp)
mov    %esi,%r13d
mov    %rdi,%r15
cmp    $0x2,%esi
jl     1194 <gauss+0x64>
lea    -0x1(%r13),%r14d
mov    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x1(%r12),%ebx
mov    %r15,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1050 <order@plt>
test   %ax,%ax
jne    11a7 <gauss+0x77>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1030 <elim@plt>
cmp    %r14d,%r12d
jge    1194 <gauss+0x64>
add    $0x1,%r12d
test   %bp,%bp
je     1160 <gauss+0x30>
mov    %r15,%rdi
mov    %r13d,%esi
mov    (%rsp),%rdx
call   1040 <backsb@plt>
xor    %eax,%eax
jmp    11ac <gauss+0x7c>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @gauss(double* %0, i32 %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca i32
%7 = alloca double*
%8 = alloca i32
%9 = alloca i16
store double* %0, double** %5
store i32 %1, i32* %6
store double* %2, double** %7
store i32 0, i32* %8
store i16 0, i16* %9
br label %10
10: ; preds = %34, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %6
%13 = sub nsw i32 %12, 1
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i16, i16* %9
%17 = icmp ne i16 %16, 0
%18 = xor i1 %17, true
br label %19
19: ; preds = %15, %10
%20 = phi i1 [ false, %10 ], [ %18, %15 ]
br i1 %20, label %21, label %35
21: ; preds = %19
%22 = load double*, double** %5
%23 = load i32, i32* %6
%24 = load i32, i32* %8
%25 = call zeroext i16 @order(double* %22, i32 %23, i32 %24)
store i16 %25, i16* %9
%26 = icmp ne i16 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %21
%28 = load double*, double** %5
%29 = load i32, i32* %6
%30 = load i32, i32* %8
%31 = call i32 @elim(double* %28, i32 %29, i32 %30)
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %34
34: ; preds = %27, %21
br label %10
35: ; preds = %19
%36 = load i16, i16* %9
%37 = icmp ne i16 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %35
store i32 1, i32* %4
br label %45
39: ; preds = %35
%40 = load double*, double** %5
%41 = load i32, i32* %6
%42 = load double*, double** %7
%43 = call i32 @backsb(double* %40, i32 %41, double* %42)
br label %44
44: ; preds = %39
store i32 0, i32* %4
br label %45
45: ; preds = %44, %38
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
define i32 @gauss(double* %0, i32 %1, double* %2) {
%4 = add nsw i32 %1, -1
%5 = icmp sgt i32 %1, 1
br i1 %5, label %6, label %15
6: ; preds = %3, %10
%7 = phi i32 [ %12, %10 ], [ 0, %3 ]
%8 = tail call zeroext i16 @order(double* %0, i32 %1, i32 %7)
%9 = icmp eq i16 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %6
%11 = tail call i32 @elim(double* %0, i32 %1, i32 %7)
%12 = add nuw nsw i32 %7, 1
%13 = icmp slt i32 %12, %4
%14 = select i1 %13, i1 %9, i1 false
br i1 %14, label %6, label %15
15: ; preds = %10, %3
%16 = tail call i32 @backsb(double* %0, i32 %1, double* %2)
br label %17
17: ; preds = %6, %15
%18 = phi i32 [ 0, %15 ], [ 1, %6 ]
ret i32 %18
}