; LLVM IR from jovanlanik/wip :: src (wip_mdl)

; 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.msh_ply_desc = type { ptr, ptr, i16, i32, i32, ptr, ptr, ptr, i8 }
%struct.msh_ply_element = type { [64 x i8], i32, ptr, i64, ptr, i64 }
%struct.msh_ply_array_header = type { i64, i64 }
%struct.msh_ply_property = type { i32, i16, i32, i32, i16, i32, i32, i32, i32, i32, i64, [32 x i8], ptr, ptr }

; Function Attrs: nounwind uwtable
declare dso_local ptr @msh_ply_find_element(ptr noundef, ptr noundef) #0

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(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) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @msh_ply_has_properties(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.msh_ply_desc, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = call ptr @msh_ply_find_element(ptr noundef %12, ptr noundef %15)
  store ptr %16, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %86

20:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !13
  br label %21

21:                                               ; preds = %80, %20
  %22 = load i32, ptr %8, align 4, !tbaa !13
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.msh_ply_desc, ptr %23, i32 0, i32 2
  %25 = load i16, ptr %24, align 8, !tbaa !14
  %26 = sext i16 %25 to i32
  %27 = icmp slt i32 %22, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %21
  store i32 2, ptr %7, align 4
  br label %83

29:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.msh_ply_desc, ptr %30, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = load i32, ptr %8, align 4, !tbaa !13
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds ptr, ptr %32, i64 %34
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  store ptr %36, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  store i8 0, ptr %10, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store i64 0, ptr %11, align 8, !tbaa !18
  br label %37

37:                                               ; preds = %68, %29
  %38 = load i64, ptr %11, align 8, !tbaa !18
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.msh_ply_element, ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !20
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %50

43:                                               ; preds = %37
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.msh_ply_element, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !20
  %47 = getelementptr inbounds i8, ptr %46, i64 -16
  %48 = getelementptr inbounds %struct.msh_ply_array_header, ptr %47, i32 0, i32 0
  %49 = load i64, ptr %48, align 8, !tbaa !22
  br label %51

50:                                               ; preds = %37
  br label %51

51:                                               ; preds = %50, %43
  %52 = phi i64 [ %49, %43 ], [ 0, %50 ]
  %53 = icmp ult i64 %38, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %51
  store i32 5, ptr %7, align 4
  br label %71

55:                                               ; preds = %51
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.msh_ply_element, ptr %56, i32 0, i32 2
  %58 = load ptr, ptr %57, align 8, !tbaa !20
  %59 = load i64, ptr %11, align 8, !tbaa !18
  %60 = getelementptr inbounds %struct.msh_ply_property, ptr %58, i64 %59
  %61 = getelementptr inbounds %struct.msh_ply_property, ptr %60, i32 0, i32 11
  %62 = getelementptr inbounds [32 x i8], ptr %61, i64 0, i64 0
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = call i32 @strcmp(ptr noundef %62, ptr noundef %63) #4
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %67, label %66

66:                                               ; preds = %55
  store i8 1, ptr %10, align 1, !tbaa !16
  store i32 5, ptr %7, align 4
  br label %71

67:                                               ; preds = %55
  br label %68

68:                                               ; preds = %67
  %69 = load i64, ptr %11, align 8, !tbaa !18
  %70 = add i64 %69, 1
  store i64 %70, ptr %11, align 8, !tbaa !18
  br label %37, !llvm.loop !24

71:                                               ; preds = %66, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %72

72:                                               ; preds = %71
  %73 = load i8, ptr %10, align 1, !tbaa !16, !range !26, !noundef !27
  %74 = trunc i8 %73 to i1
  br i1 %74, label %76, label %75

75:                                               ; preds = %72
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %77

76:                                               ; preds = %72
  store i32 0, ptr %7, align 4
  br label %77

77:                                               ; preds = %76, %75
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %78 = load i32, ptr %7, align 4
  switch i32 %78, label %83 [
    i32 0, label %79
  ]

79:                                               ; preds = %77
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %8, align 4, !tbaa !13
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %8, align 4, !tbaa !13
  br label %21, !llvm.loop !28

83:                                               ; preds = %77, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %84 = load i32, ptr %7, align 4
  switch i32 %84, label %86 [
    i32 2, label %85
  ]

85:                                               ; preds = %83
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %86

86:                                               ; preds = %85, %83, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %87 = load i1, ptr %3, align 1
  ret i1 %87
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind willreturn memory(read) "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 = { nounwind }
attributes #4 = { nounwind willreturn memory(read) }

!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 = !{!"msh_ply_desc", !6, i64 0, !6, i64 8, !11, i64 16, !12, i64 20, !12, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !7, i64 56}
!11 = !{!"short", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !11, i64 16}
!15 = !{!10, !6, i64 8}
!16 = !{!17, !17, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!21, !6, i64 72}
!21 = !{!"msh_ply_element", !7, i64 0, !12, i64 64, !6, i64 72, !19, i64 80, !6, i64 88, !19, i64 96}
!22 = !{!23, !19, i64 0}
!23 = !{!"msh_ply_array_header", !19, i64 0, !19, i64 8}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = distinct !{!28, !25}


; 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.msh_ply_property = type { i32, i16, i32, i32, i16, i32, i32, i32, i32, i32, i64, [32 x i8], ptr, ptr }

; Function Attrs: nounwind uwtable
declare dso_local ptr @msh_ply_find_element(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @msh_ply_has_properties(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %1, align 8, !tbaa !5
  %4 = tail call ptr @msh_ply_find_element(ptr noundef %0, ptr noundef %3)
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %.critedge, label %.preheader

.preheader:                                       ; preds = %2
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = load i16, ptr %5, align 8, !tbaa !12
  %wide.trip.count = sext i16 %6 to i64
  %.not2833 = icmp slt i16 %6, 1
  br i1 %.not2833, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %4, i64 72
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %.not26 = icmp eq ptr %10, null
  br i1 %.not26, label %.critedge, label %.lr.ph.split

.lr.ph.split:                                     ; preds = %.lr.ph
  %11 = getelementptr inbounds i8, ptr %10, i64 -16
  %12 = load i64, ptr %11, align 8, !tbaa !17
  %13 = zext nneg i16 %6 to i64
  br label %.split

.split:                                           ; preds = %.lr.ph.split, %.split32
  %indvars.iv = phi i64 [ 0, %.lr.ph.split ], [ %indvars.iv.next, %.split32 ]
  %14 = getelementptr inbounds ptr, ptr %8, i64 %indvars.iv
  %15 = load ptr, ptr %14, align 8, !tbaa !19
  br label %16

16:                                               ; preds = %17, %.split
  %.0 = phi i64 [ 0, %.split ], [ %20, %17 ]
  %exitcond.not = icmp eq i64 %.0, %12
  br i1 %exitcond.not, label %.critedge, label %17

17:                                               ; preds = %16
  %18 = getelementptr inbounds %struct.msh_ply_property, ptr %10, i64 %.0, i32 11
  %19 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) %15) #2
  %.not27 = icmp eq i32 %19, 0
  %20 = add i64 %.0, 1
  br i1 %.not27, label %.split32, label %16, !llvm.loop !20

.split32:                                         ; preds = %17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond37 = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond37, label %.critedge.loopexit35, label %.split, !llvm.loop !22

.critedge.loopexit35:                             ; preds = %.split32
  %.not28 = icmp uge i64 %indvars.iv.next, %13
  br label %.critedge

.critedge:                                        ; preds = %16, %.lr.ph, %.critedge.loopexit35, %.preheader, %2
  %.3 = phi i1 [ false, %2 ], [ true, %.preheader ], [ %.not28, %.critedge.loopexit35 ], [ false, %.lr.ph ], [ false, %16 ]
  ret i1 %.3
}

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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }

!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 0}
!6 = !{!"msh_ply_desc", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 20, !11, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !8, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !7, i64 8}
!14 = !{!15, !7, i64 72}
!15 = !{!"msh_ply_element", !8, i64 0, !11, i64 64, !7, i64 72, !16, i64 80, !7, i64 88, !16, i64 96}
!16 = !{!"long", !8, i64 0}
!17 = !{!18, !16, i64 0}
!18 = !{!"msh_ply_array_header", !16, i64 0, !16, i64 8}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass