#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*/ dgesv_(int *, int *, double *, int *, int *, double *, int *,
                          int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, double, double, double);
int /*<<< orphan*/ stderr;
int main(void) {
  double A[9] = {76, 27, 18, 25, 89, 60, 11, 51, 32};
  double b[3] = {10, 7, 43};
  int N = 3;
  int nrhs = 1;
  int lda = 3;
  int ipiv[3];
  int ldb = 3;
  int info;
  dgesv_(&N, &nrhs, A, &lda, ipiv, b, &ldb, &info);
  if (info == 0)
    printf("The solution is %lf %lf %lf\n", b[0], b[1], b[2]);
  else
    fprintf(stderr, "dgesv_ fails %d\n", info);
  return info;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x48,%edx
call   1050 <memcpy@plt>
mov    0xee2(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xedf(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xedc(%rip),%rax
mov    %rax,-0x60(%rbp)
movl   $0x3,-0x74(%rbp)
movl   $0x1,-0x78(%rbp)
movl   $0x3,-0x7c(%rbp)
movl   $0x3,-0x8c(%rbp)
lea    -0x50(%rbp),%rdx
lea    -0x88(%rbp),%r8
lea    -0x70(%rbp),%r9
lea    -0x74(%rbp),%rdi
lea    -0x78(%rbp),%rsi
lea    -0x7c(%rbp),%rcx
lea    -0x8c(%rbp),%r10
lea    -0x90(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1060 <dgesv_@plt>
cmpl   $0x0,-0x90(%rbp)
jne    120b <main+0xcb>
movsd  -0x70(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
jmp    1226 <main+0xe6>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    -0x90(%rbp),%edx
lea    0xe64(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x90(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x98,%rsp
mov    0xf02(%rip),%rax
mov    %rax,0x80(%rsp)
movaps 0xee3(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xec7(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xeab(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe8f(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
mov    0xee3(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xec7(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x3,0x1c(%rsp)
movl   $0x1,0x18(%rsp)
movl   $0x3,0x14(%rsp)
movl   $0x3,0x10(%rsp)
lea    0xc(%rsp),%rax
lea    0x10(%rsp),%r10
lea    0x1c(%rsp),%rdi
lea    0x18(%rsp),%rsi
lea    0x40(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x8c(%rsp),%r8
lea    0x20(%rsp),%r9
push   %rax
push   %r10
call   1050 <dgesv_@plt>
add    $0x10,%rsp
mov    0xc(%rsp),%edx
test   %edx,%edx
je     1204 <main+0xd4>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1222 <main+0xf2>
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
add    $0x98,%rsp
ret

LLVM IR (-O0):
@__const.main.A = [9 x double] [double 7.600000e+01, double 2.700000e+01, double 1.800000e+01, double 2.500000e+01, double 8.900000e+01, double 6.000000e+01, double 1.100000e+01, double 5.100000e+01, double 3.200000e+01]
@__const.main.b = [3 x double] [double 1.000000e+01, double 7.000000e+00, double 4.300000e+01]
@.str = [29 x i8] c"The solution is %lf %lf %lf\0A\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"dgesv_ fails %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x double]
%3 = alloca [3 x double]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [3 x i32]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = bitcast [9 x double]* %2 to i8*
%11 = bitcast [3 x double]* %3 to i8*
store i32 3, i32* %4
store i32 1, i32* %5
store i32 3, i32* %6
store i32 3, i32* %8
%12 = getelementptr inbounds [9 x double], [9 x double]* %2, i64 0, i64 0
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%14 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%15 = call i32 @dgesv_(i32* %4, i32* %5, double* %12, i32* %6, i32* %13, double* %14, i32* %8, i32* %9)
%16 = load i32, i32* %9
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %0
%19 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%20 = load double, double* %19
%21 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%22 = load double, double* %21
%23 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%24 = load double, double* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %20, double %22, double %24)
br label %30
26: ; preds = %0
%27 = load i32, i32* @stderr
%28 = load i32, i32* %9
%29 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %26, %18
%31 = load i32, i32* %9
ret i32 %31
}

LLVM IR (-O2):
@__const.main.A = [9 x double] [double 7.600000e+01, double 2.700000e+01, double 1.800000e+01, double 2.500000e+01, double 8.900000e+01, double 6.000000e+01, double 1.100000e+01, double 5.100000e+01, double 3.200000e+01]
@__const.main.b = [3 x double] [double 1.000000e+01, double 7.000000e+00, double 4.300000e+01]
@.str = [29 x i8] c"The solution is %lf %lf %lf\0A\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"dgesv_ fails %d\0A\00"
define i32 @main() {
%1 = alloca [9 x double]
%2 = alloca [3 x double]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [3 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = bitcast [9 x double]* %1 to i8*
%10 = bitcast [3 x double]* %2 to i8*
%11 = bitcast i32* %3 to i8*
store i32 3, i32* %3
%12 = bitcast i32* %4 to i8*
store i32 1, i32* %4
%13 = bitcast i32* %5 to i8*
store i32 3, i32* %5
%14 = bitcast [3 x i32]* %6 to i8*
%15 = bitcast i32* %7 to i8*
store i32 3, i32* %7
%16 = bitcast i32* %8 to i8*
%17 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 0
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%19 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%20 = call i32 @dgesv_(i32* %3, i32* %4, double* %17, i32* %5, i32* %18, double* %19, i32* %7, i32* %8)
%21 = load i32, i32* %8
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %0
%24 = load double, double* %19
%25 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%26 = load double, double* %25
%27 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 2
%28 = load double, double* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %24, double %26, double %28)
br label %33
30: ; preds = %0
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %33
33: ; preds = %30, %23
%34 = load i32, i32* %8
ret i32 %34
}