#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*/ assert(int);
int /*<<< orphan*/ printf(char *, double, double, double);
int /*<<< orphan*/ solve(double *, double *, double *, int);
void test_solve() {
  double A[] = {0, 1, 1, 1, 1, 0, 1, 0, 1};
  double b[] = {3, 2, 1};
  double x[3];
  solve(x, A, b, 3);
  printf("x = (%.2f, %.2f, %.2f)\n", x[0], x[1], x[2]);
  assert(x[0] == 0 && x[1] == 2 && x[2] == 1);
}


x86 assembly (clang, -O0):
<test_solve>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1050 <memset@plt>
movsd  0xe9d(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe90(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe83(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe76(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe69(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe5c(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    0xe60(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xe5d(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xe5a(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x70(%rbp),%rdx
mov    $0x3,%ecx
call   1030 <solve@plt>
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x80(%rbp),%xmm2
lea    0xe29(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x90(%rbp),%xmm0
ff
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x91(%rbp)
jne    126e <test_solve+0x12e>
jp     126e <test_solve+0x12e>
movsd  -0x88(%rbp),%xmm0
ff
xor    %eax,%eax
movsd  0xdcf(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x91(%rbp)
jne    126e <test_solve+0x12e>
jp     126e <test_solve+0x12e>
movsd  -0x80(%rbp),%xmm0
movsd  0xda4(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
mov    %al,-0x91(%rbp)
mov    -0x91(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_solve>:
sub    $0x88,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps 0xeab(%rip),%xmm0
movups %xmm0,0x48(%rsp)
movups %xmm0,0x58(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x70(%rsp)
mov    %rax,0x80(%rsp)
mov    0xeb3(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xe97(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %rsp,%rdi
lea    0x40(%rsp),%rsi
lea    0x20(%rsp),%rdx
mov    $0x3,%ecx
call   1030 <solve@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
xorpd  %xmm0,%xmm0
ucomisd (%rsp),%xmm0
setnp  %al
sete   %cl
and    %al,%cl
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd 0xe29(%rip),%xmm0
setnp  %al
sete   %dl
and    %al,%dl
and    %cl,%dl
ucomisd 0xe1f(%rip),%xmm1
setnp  %al
sete   %cl
and    %al,%cl
and    %dl,%cl
movzbl %cl,%edi
call   1050 <assert@plt>
add    $0x88,%rsp
ret

LLVM IR (-O0):
@__const.test_solve.b = [3 x double] [double 3.000000e+00, double 2.000000e+00, double 1.000000e+00]
@.str = [24 x i8] c"x = (%.2f, %.2f, %.2f)\0A\00"
define void @test_solve() {
%1 = alloca [9 x double]
%2 = alloca [3 x double]
%3 = alloca [3 x double]
%4 = bitcast [9 x double]* %1 to i8*
%5 = bitcast i8* %4 to [9 x double]*
%6 = getelementptr inbounds [9 x double], [9 x double]* %5, i32 0, i32 1
store double 1.000000e+00, double* %6
%7 = getelementptr inbounds [9 x double], [9 x double]* %5, i32 0, i32 2
store double 1.000000e+00, double* %7
%8 = getelementptr inbounds [9 x double], [9 x double]* %5, i32 0, i32 3
store double 1.000000e+00, double* %8
%9 = getelementptr inbounds [9 x double], [9 x double]* %5, i32 0, i32 4
store double 1.000000e+00, double* %9
%10 = getelementptr inbounds [9 x double], [9 x double]* %5, i32 0, i32 6
store double 1.000000e+00, double* %10
%11 = getelementptr inbounds [9 x double], [9 x double]* %5, i32 0, i32 8
store double 1.000000e+00, double* %11
%12 = bitcast [3 x double]* %2 to i8*
%13 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%14 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 0
%15 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%16 = call i32 @solve(double* %13, double* %14, double* %15, i32 3)
%17 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%18 = load double, double* %17
%19 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%20 = load double, double* %19
%21 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%22 = load double, double* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), double %18, double %20, double %22)
%24 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%25 = load double, double* %24
%26 = fcmp oeq double %25, 0.000000e+00
br i1 %26, label %27, label %35
27: ; preds = %0
%28 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%29 = load double, double* %28
%30 = fcmp oeq double %29, 2.000000e+00
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%33 = load double, double* %32
%34 = fcmp oeq double %33, 1.000000e+00
br label %35
35: ; preds = %31, %27, %0
%36 = phi i1 [ false, %27 ], [ false, %0 ], [ %34, %31 ]
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
ret void
}

LLVM IR (-O2):
@__const.test_solve.b = [3 x double] [double 3.000000e+00, double 2.000000e+00, double 1.000000e+00]
@.str = [24 x i8] c"x = (%.2f, %.2f, %.2f)\0A\00"
define void @test_solve() {
%1 = alloca [9 x double]
%2 = alloca [3 x double]
%3 = alloca [3 x double]
%4 = bitcast [9 x double]* %1 to i8*
%5 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 1
%6 = bitcast double* %5 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %6
%7 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 3
%8 = bitcast double* %7 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %8
%9 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 6
store double 1.000000e+00, double* %9
%10 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 8
store double 1.000000e+00, double* %10
%11 = bitcast [3 x double]* %2 to i8*
%12 = bitcast [3 x double]* %3 to i8*
%13 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%14 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 0
%15 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%16 = call i32 @solve(double* %13, double* %14, double* %15, i32 3)
%17 = load double, double* %13
%18 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%19 = load double, double* %18
%20 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%21 = load double, double* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), double %17, double %19, double %21)
%23 = load double, double* %13
%24 = fcmp oeq double %23, 0.000000e+00
%25 = load double, double* %18
%26 = fcmp oeq double %25, 2.000000e+00
%27 = select i1 %24, i1 %26, i1 false
%28 = load double, double* %20
%29 = fcmp oeq double %28, 1.000000e+00
%30 = select i1 %27, i1 %29, i1 false
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
ret void
}