#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*/ stdout;
int lu(int N, double *A, double *B) {
  int info;
  int lda = N;
  int ldb = N;
  int NRHS = 1;
  int ipiv[N];
  dgesv_(&N, &NRHS, A, &lda, ipiv, B, &ldb, &info);
  if (info > 0) {
    fprintf(stdout, "\nNonzero return value from LAPACK: %d\n", info);
  }
  return (info > 0);
}


x86 assembly (clang, -O0):
<lu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r8
sub    %rcx,%r8
mov    %r8,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%r9
lea    -0x4(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r10
lea    -0x1c(%rbp),%rax
sub    $0x10,%rsp
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <dgesv_@plt>
add    $0x10,%rsp
cmpl   $0x0,-0x1c(%rbp)
jle    11bd <lu+0x9d>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe48(%rip),%rsi
call   1030 <fprintf@plt>
cmpl   $0x0,-0x1c(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lu>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r9
mov    %rsi,%rdx
mov    %rsp,%r14
mov    %edi,-0x24(%rbp)
mov    %edi,-0x20(%rbp)
mov    %edi,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
mov    %edi,%eax
mov    %rsp,%r8
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r8
mov    %r8,%rsp
lea    -0x14(%rbp),%rax
lea    -0x1c(%rbp),%rbx
lea    -0x24(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rcx
push   %rax
push   %rbx
call   1040 <dgesv_@plt>
add    $0x10,%rsp
mov    -0x14(%rbp),%edx
test   %edx,%edx
jle    1199 <lu+0x79>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%edx
xor    %eax,%eax
test   %edx,%edx
setg   %al
mov    %r14,%rsp
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [39 x i8] c"\0ANonzero return value from LAPACK: %d\0A\00"
define i32 @lu(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
store i32 %0, i32* %4
store double* %1, double** %5
store double* %2, double** %6
%13 = load i32, i32* %4
store i32 %13, i32* %8
%14 = load i32, i32* %4
store i32 %14, i32* %9
store i32 1, i32* %10
%15 = load i32, i32* %4
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %11
%18 = alloca i32, i64 %16
store i64 %16, i64* %12
%19 = load double*, double** %5
%20 = load double*, double** %6
%21 = call i32 @dgesv_(i32* %4, i32* %10, double* %19, i32* %8, i32* %18, double* %20, i32* %9, i32* %7)
%22 = load i32, i32* %7
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %3
%25 = load i32, i32* @stdout
%26 = load i32, i32* %7
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %3
%29 = load i32, i32* %7
%30 = icmp sgt i32 %29, 0
%31 = zext i1 %30 to i32
%32 = load i8*, i8** %11
ret i32 %31
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [39 x i8] c"\0ANonzero return value from LAPACK: %d\0A\00"
define i32 @lu(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
store i32 %0, i32* %6
%11 = bitcast i32* %7 to i8*
store i32 %0, i32* %7
%12 = bitcast i32* %8 to i8*
store i32 1, i32* %8
%13 = zext i32 %0 to i64
%14 = tail call i8* @llvm.stacksave()
%15 = alloca i32, i64 %13
%16 = call i32 @dgesv_(i32* %4, i32* %8, double* %1, i32* %6, i32* %15, double* %2, i32* %7, i32* %5)
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %3
%20 = load i32, i32* @stdout
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %17)
%22 = load i32, i32* %5
br label %23
23: ; preds = %19, %3
%24 = phi i32 [ %22, %19 ], [ %17, %3 ]
%25 = icmp sgt i32 %24, 0
%26 = zext i1 %25 to i32
ret i32 %26
}