; LLVM IR from recp/cglm :: test/src (tests)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.test_status_t = type { ptr, i32 }

@stderr = external global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.727 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.748 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.749 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare { ptr, i32 } @test_assert_mat4_eq(ptr noundef, ptr noundef) #3

declare void @test_rand_mat4(ptr noundef) #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @glm_mat4_inv(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local { ptr, i32 } @test_glm_mat4_inv_precise() #5 {
  %1 = alloca %struct.test_status_t, align 8
  %2 = alloca [4 x [4 x float]], align 16
  %3 = alloca [4 x [4 x float]], align 16
  %4 = alloca [4 x [4 x float]], align 16
  %5 = alloca [4 x [4 x float]], align 16
  %6 = alloca [4 x [4 x float]], align 16
  %7 = alloca [4 x [4 x float]], align 16
  %8 = alloca i32, align 4
  %9 = alloca %struct.test_status_t, align 8
  %10 = alloca %struct.test_status_t, align 8
  %11 = alloca i32, align 4
  %12 = alloca %struct.test_status_t, align 8
  %13 = alloca %struct.test_status_t, align 8
  call void @llvm.lifetime.start.p0(i64 64, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 64, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 64, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 64, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 64, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 64, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %78, %0
  %15 = load i32, ptr %8, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 100000
  br i1 %16, label %17, label %81

17:                                               ; preds = %14
  %18 = getelementptr inbounds [4 x [4 x float]], ptr %2, i64 0, i64 0
  call void @test_rand_mat4(ptr noundef %18)
  %19 = getelementptr inbounds [4 x [4 x float]], ptr %3, i64 0, i64 0
  call void @test_rand_mat4(ptr noundef %19)
  %20 = getelementptr inbounds [4 x [4 x float]], ptr %2, i64 0, i64 0
  %21 = getelementptr inbounds [4 x [4 x float]], ptr %3, i64 0, i64 0
  call void @glm_mat4_inv(ptr noundef %20, ptr noundef %21)
  %22 = getelementptr inbounds [4 x [4 x float]], ptr %3, i64 0, i64 0
  %23 = getelementptr inbounds [4 x [4 x float]], ptr %4, i64 0, i64 0
  call void @glm_mat4_inv(ptr noundef %22, ptr noundef %23)
  br label %24

24:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #6
  %25 = getelementptr inbounds [4 x [4 x float]], ptr %2, i64 0, i64 0
  %26 = getelementptr inbounds [4 x [4 x float]], ptr %4, i64 0, i64 0
  %27 = call { ptr, i32 } @test_assert_mat4_eq(ptr noundef %25, ptr noundef %26)
  %28 = getelementptr inbounds { ptr, i32 }, ptr %10, i32 0, i32 0
  %29 = extractvalue { ptr, i32 } %27, 0
  store ptr %29, ptr %28, align 8
  %30 = getelementptr inbounds { ptr, i32 }, ptr %10, i32 0, i32 1
  %31 = extractvalue { ptr, i32 } %27, 1
  store i32 %31, ptr %30, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  %32 = getelementptr inbounds %struct.test_status_t, ptr %9, i32 0, i32 1
  %33 = load i32, ptr %32, align 8, !tbaa !12
  %34 = icmp ne i32 %33, 1
  br i1 %34, label %35, label %42

35:                                               ; preds = %24
  %36 = load ptr, ptr @stderr, align 8, !tbaa !10
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str.13, ptr noundef @.str.727, i32 noundef 395, ptr noundef @.str.748) #6
  %38 = getelementptr inbounds %struct.test_status_t, ptr %1, i32 0, i32 0
  %39 = getelementptr inbounds %struct.test_status_t, ptr %9, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  store ptr %40, ptr %38, align 8, !tbaa !14
  %41 = getelementptr inbounds %struct.test_status_t, ptr %1, i32 0, i32 1
  store i32 0, ptr %41, align 8, !tbaa !12
  store i32 1, ptr %11, align 4
  br label %43

42:                                               ; preds = %24
  store i32 0, ptr %11, align 4
  br label %43

43:                                               ; preds = %42, %35
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #6
  %44 = load i32, ptr %11, align 4
  switch i32 %44, label %84 [
    i32 0, label %45
  ]

45:                                               ; preds = %43
  br label %46

46:                                               ; preds = %45
  br label %47

47:                                               ; preds = %46
  %48 = getelementptr inbounds [4 x [4 x float]], ptr %5, i64 0, i64 0
  call void @test_rand_mat4(ptr noundef %48)
  %49 = getelementptr inbounds [4 x [4 x float]], ptr %6, i64 0, i64 0
  call void @test_rand_mat4(ptr noundef %49)
  %50 = getelementptr inbounds [4 x [4 x float]], ptr %5, i64 0, i64 0
  %51 = getelementptr inbounds [4 x [4 x float]], ptr %6, i64 0, i64 0
  call void @glmc_mat4_inv_precise(ptr noundef %50, ptr noundef %51)
  %52 = getelementptr inbounds [4 x [4 x float]], ptr %6, i64 0, i64 0
  %53 = getelementptr inbounds [4 x [4 x float]], ptr %7, i64 0, i64 0
  call void @glmc_mat4_inv_precise(ptr noundef %52, ptr noundef %53)
  br label %54

54:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #6
  %55 = getelementptr inbounds [4 x [4 x float]], ptr %5, i64 0, i64 0
  %56 = getelementptr inbounds [4 x [4 x float]], ptr %7, i64 0, i64 0
  %57 = call { ptr, i32 } @test_assert_mat4_eq(ptr noundef %55, ptr noundef %56)
  %58 = getelementptr inbounds { ptr, i32 }, ptr %13, i32 0, i32 0
  %59 = extractvalue { ptr, i32 } %57, 0
  store ptr %59, ptr %58, align 8
  %60 = getelementptr inbounds { ptr, i32 }, ptr %13, i32 0, i32 1
  %61 = extractvalue { ptr, i32 } %57, 1
  store i32 %61, ptr %60, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %13, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #6
  %62 = getelementptr inbounds %struct.test_status_t, ptr %12, i32 0, i32 1
  %63 = load i32, ptr %62, align 8, !tbaa !12
  %64 = icmp ne i32 %63, 1
  br i1 %64, label %65, label %72

65:                                               ; preds = %54
  %66 = load ptr, ptr @stderr, align 8, !tbaa !10
  %67 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef @.str.13, ptr noundef @.str.727, i32 noundef 402, ptr noundef @.str.749) #6
  %68 = getelementptr inbounds %struct.test_status_t, ptr %1, i32 0, i32 0
  %69 = getelementptr inbounds %struct.test_status_t, ptr %12, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !14
  store ptr %70, ptr %68, align 8, !tbaa !14
  %71 = getelementptr inbounds %struct.test_status_t, ptr %1, i32 0, i32 1
  store i32 0, ptr %71, align 8, !tbaa !12
  store i32 1, ptr %11, align 4
  br label %73

72:                                               ; preds = %54
  store i32 0, ptr %11, align 4
  br label %73

73:                                               ; preds = %72, %65
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #6
  %74 = load i32, ptr %11, align 4
  switch i32 %74, label %84 [
    i32 0, label %75
  ]

75:                                               ; preds = %73
  br label %76

76:                                               ; preds = %75
  br label %77

77:                                               ; preds = %76
  br label %78

78:                                               ; preds = %77
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %8, align 4, !tbaa !5
  br label %14, !llvm.loop !15

81:                                               ; preds = %14
  %82 = getelementptr inbounds %struct.test_status_t, ptr %1, i32 0, i32 0
  store ptr null, ptr %82, align 8, !tbaa !14
  %83 = getelementptr inbounds %struct.test_status_t, ptr %1, i32 0, i32 1
  store i32 1, ptr %83, align 8, !tbaa !12
  store i32 1, ptr %11, align 4
  br label %84

84:                                               ; preds = %81, %73, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr %2) #6
  %85 = load { ptr, i32 }, ptr %1, align 8
  ret { ptr, i32 } %85
}

declare void @glmc_mat4_inv_precise(ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { alwaysinline nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i64 0, i64 8, !10, i64 8, i64 4, !5}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 8}
!13 = !{!"test_status_t", !11, i64 0, !6, i64 8}
!14 = !{!13, !11, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.727 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.748 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.749 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare { ptr, i32 } @test_assert_mat4_eq(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @test_rand_mat4(ptr noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @glm_mat4_inv(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local { ptr, i32 } @test_glm_mat4_inv_precise() local_unnamed_addr #4 {
  %1 = alloca [4 x [4 x float]], align 16
  %2 = alloca [4 x [4 x float]], align 16
  %3 = alloca [4 x [4 x float]], align 16
  %4 = alloca [4 x [4 x float]], align 16
  %5 = alloca [4 x [4 x float]], align 16
  %6 = alloca [4 x [4 x float]], align 16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %6) #5
  br label %9

7:                                                ; preds = %16
  %8 = add nuw nsw i32 %.024, 1
  %exitcond.not = icmp eq i32 %8, 100000
  br i1 %exitcond.not, label %.loopexit, label %9, !llvm.loop !5

9:                                                ; preds = %0, %7
  %.024 = phi i32 [ 0, %0 ], [ %8, %7 ]
  call void @test_rand_mat4(ptr noundef nonnull %1) #5
  call void @test_rand_mat4(ptr noundef nonnull %2) #5
  call void @glm_mat4_inv(ptr noundef nonnull %1, ptr noundef nonnull %2)
  call void @glm_mat4_inv(ptr noundef nonnull %2, ptr noundef nonnull %3)
  %10 = call { ptr, i32 } @test_assert_mat4_eq(ptr noundef nonnull %1, ptr noundef nonnull %3) #5
  %11 = extractvalue { ptr, i32 } %10, 1
  %.not = icmp eq i32 %11, 1
  br i1 %.not, label %16, label %12

12:                                               ; preds = %9
  %13 = extractvalue { ptr, i32 } %10, 0
  %14 = load ptr, ptr @stderr, align 8, !tbaa !7
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.727, i32 noundef 395, ptr noundef nonnull @.str.748) #6
  br label %.loopexit

16:                                               ; preds = %9
  call void @test_rand_mat4(ptr noundef nonnull %4) #5
  call void @test_rand_mat4(ptr noundef nonnull %5) #5
  call void @glmc_mat4_inv_precise(ptr noundef nonnull %4, ptr noundef nonnull %5) #5
  call void @glmc_mat4_inv_precise(ptr noundef nonnull %5, ptr noundef nonnull %6) #5
  %17 = call { ptr, i32 } @test_assert_mat4_eq(ptr noundef nonnull %4, ptr noundef nonnull %6) #5
  %18 = extractvalue { ptr, i32 } %17, 1
  %.not16 = icmp eq i32 %18, 1
  br i1 %.not16, label %7, label %19

19:                                               ; preds = %16
  %20 = extractvalue { ptr, i32 } %17, 0
  %21 = load ptr, ptr @stderr, align 8, !tbaa !7
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.727, i32 noundef 402, ptr noundef nonnull @.str.749) #6
  br label %.loopexit

.loopexit:                                        ; preds = %7, %19, %12
  %.sroa.013.3 = phi ptr [ %20, %19 ], [ %13, %12 ], [ null, %7 ]
  %.sroa.414.3 = phi i32 [ 0, %19 ], [ 0, %12 ], [ 1, %7 ]
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %1) #5
  %.fca.0.insert = insertvalue { ptr, i32 } poison, ptr %.sroa.013.3, 0
  %.fca.1.insert = insertvalue { ptr, i32 } %.fca.0.insert, i32 %.sroa.414.3, 1
  ret { ptr, i32 } %.fca.1.insert
}

declare void @glmc_mat4_inv_precise(ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { alwaysinline nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { cold nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass