; LLVM IR from kmilo17pet/qlibs :: qfis (qFIS_Inference)

; 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._qFIS_s = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64, i64, i64, i64, i64, float, i8, i32 }

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @qFIS_Inference(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = icmp ne ptr null, %5
  br i1 %6, label %7, label %76

7:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store i64 0, ptr %4, align 8, !tbaa !11
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._qFIS_s, ptr %8, i32 0, i32 13
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %10, i64 0
  %12 = load i8, ptr %11, align 1, !tbaa !16
  %13 = sext i8 %12 to i32
  %14 = icmp eq i32 -128, %13
  br i1 %14, label %15, label %57

15:                                               ; preds = %7
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._qFIS_s, ptr %16, i32 0, i32 8
  store ptr @qFIS_InferenceAntecedent, ptr %17, align 8, !tbaa !17
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._qFIS_s, ptr %18, i32 0, i32 22
  store float 0.000000e+00, ptr %19, align 8, !tbaa !18
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._qFIS_s, ptr %20, i32 0, i32 23
  store i8 -1, ptr %21, align 4, !tbaa !19
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._qFIS_s, ptr %22, i32 0, i32 21
  store i64 0, ptr %23, align 8, !tbaa !20
  store i64 1, ptr %4, align 8, !tbaa !11
  br label %24

24:                                               ; preds = %53, %15
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._qFIS_s, ptr %25, i32 0, i32 13
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = load i64, ptr %4, align 8, !tbaa !11
  %29 = getelementptr inbounds i8, ptr %27, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !16
  %31 = sext i8 %30 to i32
  %32 = icmp ne i32 -127, %31
  br i1 %32, label %33, label %41

33:                                               ; preds = %24
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._qFIS_s, ptr %34, i32 0, i32 21
  %36 = load i64, ptr %35, align 8, !tbaa !20
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._qFIS_s, ptr %37, i32 0, i32 20
  %39 = load i64, ptr %38, align 8, !tbaa !21
  %40 = icmp ult i64 %36, %39
  br label %41

41:                                               ; preds = %33, %24
  %42 = phi i1 [ false, %24 ], [ %40, %33 ]
  br i1 %42, label %43, label %56

43:                                               ; preds = %41
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._qFIS_s, ptr %44, i32 0, i32 8
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = load i64, ptr %4, align 8, !tbaa !11
  %49 = call i64 %46(ptr noundef %47, i64 noundef %48)
  store i64 %49, ptr %4, align 8, !tbaa !11
  %50 = load i64, ptr %4, align 8, !tbaa !11
  %51 = icmp eq i64 0, %50
  br i1 %51, label %52, label %53

52:                                               ; preds = %43
  br label %56

53:                                               ; preds = %43
  %54 = load i64, ptr %4, align 8, !tbaa !11
  %55 = add i64 %54, 1
  store i64 %55, ptr %4, align 8, !tbaa !11
  br label %24, !llvm.loop !22

56:                                               ; preds = %52, %41
  br label %57

57:                                               ; preds = %56, %7
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._qFIS_s, ptr %58, i32 0, i32 13
  %60 = load ptr, ptr %59, align 8, !tbaa !13
  %61 = load i64, ptr %4, align 8, !tbaa !11
  %62 = getelementptr inbounds i8, ptr %60, i64 %61
  %63 = load i8, ptr %62, align 1, !tbaa !16
  %64 = sext i8 %63 to i32
  %65 = icmp eq i32 -127, %64
  br i1 %65, label %66, label %75

66:                                               ; preds = %57
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._qFIS_s, ptr %67, i32 0, i32 21
  %69 = load i64, ptr %68, align 8, !tbaa !20
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._qFIS_s, ptr %70, i32 0, i32 20
  %72 = load i64, ptr %71, align 8, !tbaa !21
  %73 = icmp eq i64 %69, %72
  br i1 %73, label %74, label %75

74:                                               ; preds = %66
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %75

75:                                               ; preds = %74, %66, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %76

76:                                               ; preds = %75, %1
  %77 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %77
}

; Function Attrs: nounwind uwtable
declare hidden i64 @qFIS_InferenceAntecedent(ptr noundef, i64 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 104}
!14 = !{!"_qFIS_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !15, i64 176, !7, i64 180, !10, i64 184}
!15 = !{!"float", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!14, !6, i64 64}
!18 = !{!14, !15, i64 176}
!19 = !{!14, !7, i64 180}
!20 = !{!14, !12, i64 168}
!21 = !{!14, !12, i64 160}
!22 = distinct !{!22, !23}
!23 = !{!"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"

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @qFIS_Inference(ptr noundef %0) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %36, label %2

2:                                                ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 104
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = load i8, ptr %4, align 1, !tbaa !13
  %6 = icmp eq i8 %5, -128
  br i1 %6, label %7, label %.critedge

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr @qFIS_InferenceAntecedent, ptr %8, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %0, i64 176
  store float 0.000000e+00, ptr %9, align 8, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %0, i64 180
  store i8 -1, ptr %10, align 4, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %0, i64 168
  store i64 0, ptr %11, align 8, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %4, i64 1
  %13 = load i8, ptr %12, align 1, !tbaa !13
  %.not2425 = icmp eq i8 %13, -127
  br i1 %.not2425, label %.critedge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %7
  %14 = getelementptr inbounds i8, ptr %0, i64 160
  %15 = load i64, ptr %11, align 8, !tbaa !17
  %16 = load i64, ptr %14, align 8, !tbaa !18
  %17 = icmp ult i64 %15, %16
  br i1 %17, label %.lr.ph35, label %.critedge.loopexit

18:                                               ; preds = %.lr.ph35
  %19 = add i64 %27, 1
  %20 = getelementptr inbounds i8, ptr %.pre.pre, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !13
  %.not24 = icmp eq i8 %21, -127
  br i1 %.not24, label %.critedge.loopexit, label %22, !llvm.loop !19

22:                                               ; preds = %18
  %23 = load i64, ptr %11, align 8, !tbaa !17
  %24 = load i64, ptr %14, align 8, !tbaa !18
  %25 = icmp ult i64 %23, %24
  br i1 %25, label %.lr.ph35, label %.critedge.loopexit, !llvm.loop !19

.lr.ph35:                                         ; preds = %.lr.ph, %22
  %.02634 = phi i64 [ %19, %22 ], [ 1, %.lr.ph ]
  %26 = load ptr, ptr %8, align 8, !tbaa !14
  %27 = tail call i64 %26(ptr noundef nonnull %0, i64 noundef %.02634) #1
  %28 = icmp eq i64 %27, 0
  %.pre.pre = load ptr, ptr %3, align 8, !tbaa !5
  br i1 %28, label %.critedge.loopexit, label %18

.critedge.loopexit:                               ; preds = %18, %.lr.ph35, %22, %.lr.ph
  %.pre = phi ptr [ %4, %.lr.ph ], [ %.pre.pre, %22 ], [ %.pre.pre, %.lr.ph35 ], [ %.pre.pre, %18 ]
  %.1.ph = phi i64 [ 1, %.lr.ph ], [ %19, %18 ], [ 0, %.lr.ph35 ], [ %19, %22 ]
  %.phi.trans.insert = getelementptr inbounds i8, ptr %.pre, i64 %.1.ph
  %.pre31 = load i8, ptr %.phi.trans.insert, align 1, !tbaa !13
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %2
  %29 = phi i8 [ %5, %2 ], [ %.pre31, %.critedge.loopexit ]
  %30 = icmp eq i8 %29, -127
  br i1 %30, label %.critedge.thread, label %36

.critedge.thread:                                 ; preds = %7, %.critedge
  %31 = getelementptr inbounds i8, ptr %0, i64 168
  %32 = load i64, ptr %31, align 8, !tbaa !17
  %33 = getelementptr inbounds i8, ptr %0, i64 160
  %34 = load i64, ptr %33, align 8, !tbaa !18
  %35 = icmp eq i64 %32, %34
  %spec.select = zext i1 %35 to i32
  br label %36

36:                                               ; preds = %.critedge.thread, %.critedge, %1
  %.120 = phi i32 [ 0, %1 ], [ 0, %.critedge ], [ %spec.select, %.critedge.thread ]
  ret i32 %.120
}

; Function Attrs: nounwind uwtable
declare hidden i64 @qFIS_InferenceAntecedent(ptr noundef, i64 noundef) #0

attributes #0 = { 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 #1 = { 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, !7, i64 104}
!6 = !{!"_qFIS_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !11, i64 176, !8, i64 180, !12, i64 184}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!8, !8, i64 0}
!14 = !{!6, !7, i64 64}
!15 = !{!6, !11, i64 176}
!16 = !{!6, !8, i64 180}
!17 = !{!6, !10, i64 168}
!18 = !{!6, !10, i64 160}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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