#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 */
double fabs(float);
int /*<<< orphan*/ frlufact(float *, unsigned int *, float const *, int);
int /*<<< orphan*/ frmatprintf(char *, int, int, int, int, float const *);
int /*<<< orphan*/ printf(char *);
int testfrgolub(void) {
  static const float a[9] = {3, 17, 10, 2, 4, -2, 6, 18, -12};
  static const float uexp[9] = {6,  18,      -12,      1.0 / 3, 8,
                                16, 1.0 / 2, -1.0 / 4, 6};
  float u[9];
  unsigned int p[2];
  unsigned int i, err = 0;
  frlufact(u, p, a, 3);
  for (i = 0; i < 9; i++)
    if (fabs(u[i] - uexp[i]) > 0.0001)
      err |= 1;
  if (err & 1) {
    printf("LU factorization (Golub example) error!\n");
    frmatprintf("a", 3, 3, 3, 1, a);
    frmatprintf("u", 3, 3, 3, 1, u);
    frmatprintf("uexp", 3, 3, 3, 1, uexp);
  }
  return err ? 1 : 0;
}


x86 assembly (clang, -O0):
<testfrgolub>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    0xeb2(%rip),%rdx
mov    $0x3,%ecx
call   1060 <frlufact@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x9,-0x3c(%rbp)
jae    11c6 <testfrgolub+0x86>
mov    -0x3c(%rbp),%eax
movss  -0x30(%rbp,%rax,4),%xmm0
mov    -0x3c(%rbp),%eax
mov    %eax,%ecx
lea    0xeb2(%rip),%rax
subss  (%rax,%rcx,4),%xmm0
call   1050 <fabs@plt>
movsd  0xe60(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b3 <testfrgolub+0x73>
mov    -0x40(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11b8 <testfrgolub+0x78>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    116f <testfrgolub+0x2f>
mov    -0x40(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1244 <testfrgolub+0x104>
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
mov    $0x3,%ecx
mov    $0x1,%r8d
lea    0xe16(%rip),%r9
mov    %ecx,%esi
mov    %ecx,%edx
call   1030 <frmatprintf@plt>
lea    -0x30(%rbp),%r9
lea    0xe81(%rip),%rdi
mov    $0x3,%ecx
mov    $0x1,%r8d
mov    %ecx,%esi
mov    %ecx,%edx
call   1030 <frmatprintf@plt>
lea    0xe68(%rip),%rdi
mov    $0x3,%ecx
mov    $0x1,%r8d
lea    0xe05(%rip),%r9
mov    %ecx,%esi
mov    %ecx,%edx
call   1030 <frmatprintf@plt>
mov    -0x40(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testfrgolub>:
push   %rbx
sub    $0xb0,%rsp
lea    0xef1(%rip),%rdx
mov    %rsp,%rdi
lea    0xa8(%rsp),%rsi
mov    $0x3,%ecx
call   1060 <frlufact@plt>
movss  (%rsp),%xmm0
addss  0xe8f(%rip),%xmm0
call   1050 <fabs@plt>
movaps %xmm0,0x60(%rsp)
movss  0x4(%rsp),%xmm0
addss  0xe7b(%rip),%xmm0
call   1050 <fabs@plt>
movaps %xmm0,0x90(%rsp)
movss  0x8(%rsp),%xmm0
addss  0xe64(%rip),%xmm0
call   1050 <fabs@plt>
movaps %xmm0,0x50(%rsp)
movss  0xc(%rsp),%xmm0
addss  0xe50(%rip),%xmm0
call   1050 <fabs@plt>
movaps %xmm0,0x80(%rsp)
movss  0x10(%rsp),%xmm0
addss  0xe39(%rip),%xmm0
call   1050 <fabs@plt>
movaps %xmm0,0x40(%rsp)
movss  0x14(%rsp),%xmm0
addss  0xe25(%rip),%xmm0
call   1050 <fabs@plt>
movaps %xmm0,0x70(%rsp)
movss  0x18(%rsp),%xmm0
addss  0xe11(%rip),%xmm0
call   1050 <fabs@plt>
movaps %xmm0,0x30(%rsp)
movss  0x1c(%rsp),%xmm0
addss  0xdfd(%rip),%xmm0
call   1050 <fabs@plt>
movaps 0x30(%rsp),%xmm1
movlhps %xmm0,%xmm1
movaps %xmm1,0x30(%rsp)
movaps 0x40(%rsp),%xmm0
unpcklpd 0x70(%rsp),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x50(%rsp),%xmm0
unpcklpd 0x80(%rsp),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0x60(%rsp),%xmm0
unpcklpd 0x90(%rsp),%xmm0
movaps %xmm0,0x60(%rsp)
movss  0xd91(%rip),%xmm0
addss  0x20(%rsp),%xmm0
call   1050 <fabs@plt>
ucomisd 0xdae(%rip),%xmm0
seta   %al
movapd 0xd93(%rip),%xmm2
movapd %xmm2,%xmm0
cmpltpd 0x60(%rsp),%xmm0
movapd %xmm2,%xmm1
cmpltpd 0x50(%rsp),%xmm1
packssdw %xmm1,%xmm0
movapd %xmm2,%xmm1
cmpltpd 0x40(%rsp),%xmm1
cmpltpd 0x30(%rsp),%xmm2
packssdw %xmm2,%xmm1
packssdw %xmm1,%xmm0
pmovmskb %xmm0,%ecx
test   $0xaaaa,%ecx
setne  %bl
or     %al,%bl
cmp    $0x1,%bl
jne    1359 <testfrgolub+0x219>
lea    0xdbd(%rip),%rdi
call   1030 <puts@plt>
lea    0xda8(%rip),%rdi
lea    0xd4d(%rip),%r9
mov    $0x3,%esi
mov    $0x3,%edx
mov    $0x3,%ecx
mov    $0x1,%r8d
call   1040 <frmatprintf@plt>
lea    0xd82(%rip),%rdi
mov    %rsp,%r9
mov    $0x3,%esi
mov    $0x3,%edx
mov    $0x3,%ecx
mov    $0x1,%r8d
call   1040 <frmatprintf@plt>
lea    0xd60(%rip),%rdi
lea    0xd31(%rip),%r9
mov    $0x3,%esi
mov    $0x3,%edx
mov    $0x3,%ecx
mov    $0x1,%r8d
call   1040 <frmatprintf@plt>
movzbl %bl,%eax
add    $0xb0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@testfrgolub.a = internal constant [9 x float] [float 3.000000e+00, float 1.700000e+01, float 1.000000e+01, float 2.000000e+00, float 4.000000e+00, float -2.000000e+00, float 6.000000e+00, float 1.800000e+01, float -1.200000e+01]
@testfrgolub.uexp = internal constant [9 x float] [float 6.000000e+00, float 1.800000e+01, float -1.200000e+01, float 0x3FD5555560000000, float 8.000000e+00, float 1.600000e+01, float 5.000000e-01, float -2.500000e-01, float 6.000000e+00]
@.str = [41 x i8] c"LU factorization (Golub example) error!\0A\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [2 x i8] c"u\00"
@.str.3 = [5 x i8] c"uexp\00"
define i32 @testfrgolub() {
%1 = alloca [9 x float]
%2 = alloca [2 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %4
%5 = getelementptr inbounds [9 x float], [9 x float]* %1, i64 0, i64 0
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%7 = call i32 @frlufact(float* %5, i32* %6, float* getelementptr inbounds ([9 x float], [9 x float]* @testfrgolub.a, i64 0, i64 0), i32 3)
store i32 0, i32* %3
br label %8
8: ; preds = %27, %0
%9 = load i32, i32* %3
%10 = icmp ult i32 %9, 9
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = load i32, i32* %3
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds [9 x float], [9 x float]* %1, i64 0, i64 %13
%15 = load float, float* %14
%16 = load i32, i32* %3
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [9 x float], [9 x float]* @testfrgolub.uexp, i64 0, i64 %17
%19 = load float, float* %18
%20 = fsub float %15, %19
%21 = call double @fabs(float %20)
%22 = fcmp ogt double %21, 1.000000e-04
br i1 %22, label %23, label %26
23: ; preds = %11
%24 = load i32, i32* %4
%25 = or i32 %24, 1
store i32 %25, i32* %4
br label %26
26: ; preds = %23, %11
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = add i32 %28, 1
store i32 %29, i32* %3
br label %8
30: ; preds = %8
%31 = load i32, i32* %4
%32 = and i32 %31, 1
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %30
%35 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%36 = call i32 @frmatprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 3, i32 3, i32 1, float* getelementptr inbounds ([9 x float], [9 x float]* @testfrgolub.a, i64 0, i64 0))
%37 = getelementptr inbounds [9 x float], [9 x float]* %1, i64 0, i64 0
%38 = call i32 @frmatprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 3, i32 3, i32 1, float* %37)
%39 = call i32 @frmatprintf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 3, i32 3, i32 1, float* getelementptr inbounds ([9 x float], [9 x float]* @testfrgolub.uexp, i64 0, i64 0))
br label %40
40: ; preds = %34, %30
%41 = load i32, i32* %4
%42 = icmp ne i32 %41, 0
%43 = zext i1 %42 to i64
%44 = select i1 %42, i32 1, i32 0
ret i32 %44
}

LLVM IR (-O2):
@testfrgolub.a = internal constant [9 x float] [float 3.000000e+00, float 1.700000e+01, float 1.000000e+01, float 2.000000e+00, float 4.000000e+00, float -2.000000e+00, float 6.000000e+00, float 1.800000e+01, float -1.200000e+01]
@testfrgolub.uexp = internal constant [9 x float] [float 6.000000e+00, float 1.800000e+01, float -1.200000e+01, float 0x3FD5555560000000, float 8.000000e+00, float 1.600000e+01, float 5.000000e-01, float -2.500000e-01, float 6.000000e+00]
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [2 x i8] c"u\00"
@.str.3 = [5 x i8] c"uexp\00"
@str = [40 x i8] c"LU factorization (Golub example) error!\00"
define i32 @testfrgolub() {
%1 = alloca [9 x float]
%2 = alloca [2 x i32]
%3 = bitcast [9 x float]* %1 to i8*
%4 = bitcast [2 x i32]* %2 to i8*
%5 = getelementptr inbounds [9 x float], [9 x float]* %1, i64 0, i64 0
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%7 = call i32 @frlufact(float* %5, i32* %6, float* getelementptr inbounds ([9 x float], [9 x float]* @testfrgolub.a, i64 0, i64 0), i32 3)
%8 = load float, float* %5
%9 = fadd float %8, -6.000000e+00
%10 = call double @fabs(float %9)
%11 = getelementptr inbounds [9 x float], [9 x float]* %1, i64 0, i64 1
%12 = load float, float* %11
%13 = fadd float %12, -1.800000e+01
%14 = call double @fabs(float %13)
%15 = getelementptr inbounds [9 x float], [9 x float]* %1, i64 0, i64 2
%16 = load float, float* %15
%17 = fadd float %16, 1.200000e+01
%18 = call double @fabs(float %17)
%19 = getelementptr inbounds [9 x float], [9 x float]* %1, i64 0, i64 3
%20 = load float, float* %19
%21 = fadd float %20, 0xBFD5555560000000
%22 = call double @fabs(float %21)
%23 = getelementptr inbounds [9 x float], [9 x float]* %1, i64 0, i64 4
%24 = load float, float* %23
%25 = fadd float %24, -8.000000e+00
%26 = call double @fabs(float %25)
%27 = getelementptr inbounds [9 x float], [9 x float]* %1, i64 0, i64 5
%28 = load float, float* %27
%29 = fadd float %28, -1.600000e+01
%30 = call double @fabs(float %29)
%31 = getelementptr inbounds [9 x float], [9 x float]* %1, i64 0, i64 6
%32 = load float, float* %31
%33 = fadd float %32, -5.000000e-01
%34 = call double @fabs(float %33)
%35 = getelementptr inbounds [9 x float], [9 x float]* %1, i64 0, i64 7
%36 = load float, float* %35
%37 = fadd float %36, 2.500000e-01
%38 = call double @fabs(float %37)
%39 = insertelement <8 x double> poison, double %10, i64 0
%40 = insertelement <8 x double> %39, double %14, i64 1
%41 = insertelement <8 x double> %40, double %18, i64 2
%42 = insertelement <8 x double> %41, double %22, i64 3
%43 = insertelement <8 x double> %42, double %26, i64 4
%44 = insertelement <8 x double> %43, double %30, i64 5
%45 = insertelement <8 x double> %44, double %34, i64 6
%46 = insertelement <8 x double> %45, double %38, i64 7
%47 = fcmp ogt <8 x double> %46, <double 1.000000e-04, double 1.000000e-04, double 1.000000e-04, double 1.000000e-04, double 1.000000e-04, double 1.000000e-04, double 1.000000e-04, double 1.000000e-04>
%48 = getelementptr inbounds [9 x float], [9 x float]* %1, i64 0, i64 8
%49 = load float, float* %48
%50 = fadd float %49, -6.000000e+00
%51 = call double @fabs(float %50)
%52 = fcmp ogt double %51, 1.000000e-04
%53 = bitcast <8 x i1> %47 to i8
%54 = icmp ne i8 %53, 0
%55 = or i1 %54, %52
br i1 %55, label %56, label %61
56: ; preds = %0
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%58 = call i32 @frmatprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 3, i32 3, i32 1, float* getelementptr inbounds ([9 x float], [9 x float]* @testfrgolub.a, i64 0, i64 0))
%59 = call i32 @frmatprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 3, i32 3, i32 1, float* %5)
%60 = call i32 @frmatprintf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 3, i32 3, i32 1, float* getelementptr inbounds ([9 x float], [9 x float]* @testfrgolub.uexp, i64 0, i64 0))
br label %61
61: ; preds = %56, %0
%62 = zext i1 %55 to i32
ret i32 %62
}