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

; 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_MF_t = type { ptr, ptr, float, float, i64 }

@qFIS_SetMF.fShape = external hidden constant [27 x ptr], align 16

; 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_SetMF(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, float noundef %6) #1 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca float, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store float %6, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  store i32 0, ptr %15, align 4, !tbaa !9
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = icmp ne ptr null, %16
  br i1 %17, label %18, label %73

18:                                               ; preds = %7
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = icmp sge i32 %19, 0
  br i1 %20, label %21, label %73

21:                                               ; preds = %18
  %22 = load i32, ptr %10, align 4, !tbaa !9
  %23 = icmp sge i32 %22, 0
  br i1 %23, label %24, label %73

24:                                               ; preds = %21
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = icmp ult i32 %25, 27
  br i1 %26, label %27, label %73

27:                                               ; preds = %24
  %28 = load ptr, ptr %12, align 8, !tbaa !5
  %29 = icmp ne ptr null, %28
  br i1 %29, label %30, label %37

30:                                               ; preds = %27
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %struct.qFIS_MF_t, ptr %32, i64 %34
  %36 = getelementptr inbounds %struct.qFIS_MF_t, ptr %35, i32 0, i32 0
  store ptr %31, ptr %36, align 8, !tbaa !13
  br label %47

37:                                               ; preds = %27
  %38 = load i32, ptr %11, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds [27 x ptr], ptr @qFIS_SetMF.fShape, i64 0, i64 %39
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %struct.qFIS_MF_t, ptr %42, i64 %44
  %46 = getelementptr inbounds %struct.qFIS_MF_t, ptr %45, i32 0, i32 0
  store ptr %41, ptr %46, align 8, !tbaa !13
  br label %47

47:                                               ; preds = %37, %30
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds %struct.qFIS_MF_t, ptr %50, i64 %52
  %54 = getelementptr inbounds %struct.qFIS_MF_t, ptr %53, i32 0, i32 4
  store i64 %49, ptr %54, align 8, !tbaa !16
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = load i32, ptr %10, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.qFIS_MF_t, ptr %56, i64 %58
  %60 = getelementptr inbounds %struct.qFIS_MF_t, ptr %59, i32 0, i32 1
  store ptr %55, ptr %60, align 8, !tbaa !17
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = load i32, ptr %10, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds %struct.qFIS_MF_t, ptr %61, i64 %63
  %65 = getelementptr inbounds %struct.qFIS_MF_t, ptr %64, i32 0, i32 2
  store float 0.000000e+00, ptr %65, align 8, !tbaa !18
  %66 = load float, ptr %14, align 4, !tbaa !11
  %67 = call float @qFIS_Bound(float noundef %66, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds %struct.qFIS_MF_t, ptr %68, i64 %70
  %72 = getelementptr inbounds %struct.qFIS_MF_t, ptr %71, i32 0, i32 3
  store float %67, ptr %72, align 4, !tbaa !19
  store i32 1, ptr %15, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %47, %24, %21, %18, %7
  %74 = load i32, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  ret i32 %74
}

; Function Attrs: nounwind uwtable
declare hidden float @qFIS_Bound(float noundef, float noundef, float 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 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"", !6, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !15, i64 24}
!15 = !{!"long", !7, i64 0}
!16 = !{!14, !15, i64 24}
!17 = !{!14, !6, i64 8}
!18 = !{!14, !12, i64 16}
!19 = !{!14, !12, i64 20}


; 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"

%struct.qFIS_MF_t = type { ptr, ptr, float, float, i64 }

@qFIS_SetMF.fShape = external hidden local_unnamed_addr constant [27 x ptr], align 16

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @qFIS_SetMF(ptr noundef writeonly %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, float noundef %6) local_unnamed_addr #0 {
  %8 = icmp ne ptr %0, null
  %9 = or i32 %2, %1
  %10 = icmp sgt i32 %9, -1
  %or.cond3 = and i1 %8, %10
  %11 = icmp ult i32 %3, 27
  %or.cond5 = and i1 %11, %or.cond3
  br i1 %or.cond5, label %12, label %27

12:                                               ; preds = %7
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %13, label %17

13:                                               ; preds = %12
  %14 = zext nneg i32 %3 to i64
  %15 = getelementptr inbounds [27 x ptr], ptr @qFIS_SetMF.fShape, i64 0, i64 %14
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %12, %13
  %.sink = phi ptr [ %16, %13 ], [ %4, %12 ]
  %18 = zext nneg i32 %2 to i64
  %19 = getelementptr inbounds %struct.qFIS_MF_t, ptr %0, i64 %18
  store ptr %.sink, ptr %19, align 8, !tbaa !9
  %20 = zext nneg i32 %1 to i64
  %21 = getelementptr inbounds %struct.qFIS_MF_t, ptr %0, i64 %18
  %22 = getelementptr inbounds i8, ptr %21, i64 24
  store i64 %20, ptr %22, align 8, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %21, i64 8
  store ptr %5, ptr %23, align 8, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %21, i64 16
  store float 0.000000e+00, ptr %24, align 8, !tbaa !15
  %25 = tail call float @qFIS_Bound(float noundef %6, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %26 = getelementptr inbounds i8, ptr %21, i64 20
  store float %25, ptr %26, align 4, !tbaa !16
  br label %27

27:                                               ; preds = %17, %7
  %.0 = phi i32 [ 1, %17 ], [ 0, %7 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden float @qFIS_Bound(float noundef, float noundef, float noundef) local_unnamed_addr #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" }

!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, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !12, i64 24}
!11 = !{!"float", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, i64 24}
!14 = !{!10, !6, i64 8}
!15 = !{!10, !11, i64 16}
!16 = !{!10, !11, i64 20}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass