#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*/ dgetrf_(int *, int *, double *, int *, int *, int *);
int /*<<< orphan*/ disp3x3(double *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int M = 3;
  int N = 3;
  double A[9] = {4, 0, 1, 4, 4, 1, -3, -1, 1};
  int LDA = 3;
  int IPIV[3];
  int INFO;
  printf("Inputs: \n");
  printf("  M = %d\n", M);
  printf("  N = %d\n", N);
  disp3x3(A);
  printf("  LDA = %d\n", LDA);
  dgetrf_(&M, &N, A, &LDA, IPIV, &INFO);
  printf("Outputs:\n");
  disp3x3(A);
  printf("  IPIV = [%d, %d, %d]\n", IPIV[0], IPIV[1], IPIV[2]);
  printf("  INFO = %d\n", INFO);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x48,%edx
call   1050 <memcpy@plt>
movl   $0x3,-0x64(%rbp)
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1030 <disp3x3@plt>
mov    -0x64(%rbp),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdx
lea    -0x70(%rbp),%r8
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x64(%rbp),%rcx
lea    -0x74(%rbp),%r9
call   1060 <dgetrf_@plt>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1030 <disp3x3@plt>
mov    -0x70(%rbp),%esi
mov    -0x6c(%rbp),%edx
mov    -0x68(%rbp),%ecx
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x74(%rbp),%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
movl   $0x3,0x10(%rsp)
movl   $0x3,0xc(%rsp)
mov    0xee4(%rip),%rax
mov    %rax,0x60(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe90(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe74(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x3,0x8(%rsp)
lea    0xeec(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9c(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe93(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <disp3x3@plt>
lea    0xe7d(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x4(%rsp),%r9
mov    %rbx,%rdx
call   1060 <dgetrf_@plt>
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <disp3x3@plt>
mov    0x14(%rsp),%esi
mov    0x18(%rsp),%edx
mov    0x1c(%rsp),%ecx
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xe3a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.A = [9 x double] [double 4.000000e+00, double 0.000000e+00, double 1.000000e+00, double 4.000000e+00, double 4.000000e+00, double 1.000000e+00, double -3.000000e+00, double -1.000000e+00, double 1.000000e+00]
@.str = [10 x i8] c"Inputs: \0A\00"
@.str.1 = [10 x i8] c" M = %d\0A\00"
@.str.2 = [10 x i8] c" N = %d\0A\00"
@.str.3 = [12 x i8] c" LDA = %d\0A\00"
@.str.4 = [10 x i8] c"Outputs:\0A\00"
@.str.5 = [23 x i8] c" IPIV = [%d, %d, %d]\0A\00"
@.str.6 = [13 x i8] c" INFO = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [9 x double]
%5 = alloca i32
%6 = alloca [3 x i32]
%7 = alloca i32
store i32 0, i32* %1
store i32 3, i32* %2
store i32 3, i32* %3
%8 = bitcast [9 x double]* %4 to i8*
store i32 3, i32* %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 0
%15 = call i32 @disp3x3(double* %14)
%16 = load i32, i32* %5
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 0
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%20 = call i32 @dgetrf_(i32* %2, i32* %3, double* %18, i32* %5, i32* %19, i32* %7)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%22 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 0
%23 = call i32 @disp3x3(double* %22)
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%25 = load i32, i32* %24
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
%27 = load i32, i32* %26
%28 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %25, i32 %27, i32 %29)
%31 = load i32, i32* %7
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
@__const.main.A = [9 x double] [double 4.000000e+00, double 0.000000e+00, double 1.000000e+00, double 4.000000e+00, double 4.000000e+00, double 1.000000e+00, double -3.000000e+00, double -1.000000e+00, double 1.000000e+00]
@.str.1 = [10 x i8] c" M = %d\0A\00"
@.str.2 = [10 x i8] c" N = %d\0A\00"
@.str.3 = [12 x i8] c" LDA = %d\0A\00"
@.str.5 = [23 x i8] c" IPIV = [%d, %d, %d]\0A\00"
@.str.6 = [13 x i8] c" INFO = %d\0A\00"
@str = [9 x i8] c"Inputs: \00"
@str.7 = [9 x i8] c"Outputs:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [9 x double]
%4 = alloca i32
%5 = alloca [3 x i32]
%6 = alloca i32
%7 = bitcast i32* %1 to i8*
store i32 3, i32* %1
%8 = bitcast i32* %2 to i8*
store i32 3, i32* %2
%9 = bitcast [9 x double]* %3 to i8*
%10 = bitcast i32* %4 to i8*
store i32 3, i32* %4
%11 = bitcast [3 x i32]* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 3)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 3)
%16 = getelementptr inbounds [9 x double], [9 x double]* %3, i64 0, i64 0
%17 = call i32 @disp3x3(double* %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 3)
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%20 = call i32 @dgetrf_(i32* %1, i32* %2, double* %16, i32* %4, i32* %19, i32* %6)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0))
%22 = call i32 @disp3x3(double* %16)
%23 = load i32, i32* %19
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 1
%25 = load i32, i32* %24
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 2
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %23, i32 %25, i32 %27)
%29 = load i32, i32* %6
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %29)
ret i32 0
}