; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmext (mec_mr3_dict)

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

@dict = external hidden constant [796 x %struct.mec_mr3_dict], align 16
@.str = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [129 x i8], align 1
@__PRETTY_FUNCTION__.check_mec_mr3_dict = external hidden unnamed_addr constant [26 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @check_mec_mr3_dict() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  store ptr @dict, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 1, ptr %2, align 4, !tbaa !9
  br label %4

4:                                                ; preds = %47, %0
  %5 = load i32, ptr %2, align 4, !tbaa !9
  %6 = icmp ult i32 %5, 796
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %50

8:                                                ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %9 = load i32, ptr %2, align 4, !tbaa !9
  %10 = zext i32 %9 to i64
  %11 = getelementptr inbounds %struct.mec_mr3_dict, ptr @dict, i64 %10
  store ptr %11, ptr %3, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.mec_mr3_dict, ptr %12, i32 0, i32 0
  %14 = load i8, ptr %13, align 8, !tbaa !11
  %15 = zext i8 %14 to i32
  %16 = load ptr, ptr %1, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.mec_mr3_dict, ptr %16, i32 0, i32 0
  %18 = load i8, ptr %17, align 8, !tbaa !11
  %19 = zext i8 %18 to i32
  %20 = icmp eq i32 %15, %19
  br i1 %20, label %21, label %32

21:                                               ; preds = %8
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.mec_mr3_dict, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !13
  %25 = load ptr, ptr %1, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.mec_mr3_dict, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !13
  %28 = icmp ugt i32 %24, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %21
  br label %31

30:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 834, ptr noundef @__PRETTY_FUNCTION__.check_mec_mr3_dict) #4
  unreachable

31:                                               ; preds = %29
  br label %45

32:                                               ; preds = %8
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mec_mr3_dict, ptr %33, i32 0, i32 0
  %35 = load i8, ptr %34, align 8, !tbaa !11
  %36 = zext i8 %35 to i32
  %37 = load ptr, ptr %1, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.mec_mr3_dict, ptr %37, i32 0, i32 0
  %39 = load i8, ptr %38, align 8, !tbaa !11
  %40 = zext i8 %39 to i32
  %41 = icmp sgt i32 %36, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %32
  br label %44

43:                                               ; preds = %32
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 836, ptr noundef @__PRETTY_FUNCTION__.check_mec_mr3_dict) #4
  unreachable

44:                                               ; preds = %42
  br label %45

45:                                               ; preds = %44, %31
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %46, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %47

47:                                               ; preds = %45
  %48 = load i32, ptr %2, align 4, !tbaa !9
  %49 = add i32 %48, 1
  store i32 %49, ptr %2, align 4, !tbaa !9
  br label %4, !llvm.loop !14

50:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 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

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 = { noreturn 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 = { nounwind }
attributes #4 = { noreturn 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, !7, i64 0}
!12 = !{!"mec_mr3_dict", !7, i64 0, !10, i64 4, !10, i64 8, !6, i64 16}
!13 = !{!12, !10, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"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"

%struct.mec_mr3_dict = type { i8, i32, i32, ptr }

@dict = external hidden local_unnamed_addr constant [796 x %struct.mec_mr3_dict], align 16
@.str = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [129 x i8], align 1
@__PRETTY_FUNCTION__.check_mec_mr3_dict = external hidden unnamed_addr constant [26 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @check_mec_mr3_dict() local_unnamed_addr #0 {
  %.pre = load i8, ptr @dict, align 16, !tbaa !5
  br label %2

1:                                                ; preds = %17
  ret void

2:                                                ; preds = %30, %0
  %3 = phi i8 [ %.pre, %0 ], [ %20, %30 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next.1, %30 ]
  %.013 = phi ptr [ @dict, %0 ], [ %19, %30 ]
  %4 = getelementptr inbounds %struct.mec_mr3_dict, ptr @dict, i64 %indvars.iv
  %5 = load i8, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i8 %5, %3
  br i1 %6, label %7, label %14

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %4, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %.013, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %12 = icmp ugt i32 %9, %11
  br i1 %12, label %17, label %13

13:                                               ; preds = %24, %7
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 834, ptr noundef nonnull @__PRETTY_FUNCTION__.check_mec_mr3_dict) #2
  unreachable

14:                                               ; preds = %2
  %15 = icmp ugt i8 %5, %3
  br i1 %15, label %17, label %16

16:                                               ; preds = %22, %14
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 836, ptr noundef nonnull @__PRETTY_FUNCTION__.check_mec_mr3_dict) #2
  unreachable

17:                                               ; preds = %14, %7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 796
  br i1 %exitcond.not, label %1, label %18, !llvm.loop !12

18:                                               ; preds = %17
  %19 = getelementptr inbounds %struct.mec_mr3_dict, ptr @dict, i64 %indvars.iv.next
  %20 = load i8, ptr %19, align 8, !tbaa !5
  %21 = icmp eq i8 %20, %5
  br i1 %21, label %24, label %22

22:                                               ; preds = %18
  %23 = icmp ugt i8 %20, %5
  br i1 %23, label %30, label %16

24:                                               ; preds = %18
  %25 = getelementptr inbounds i8, ptr %19, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !11
  %27 = getelementptr inbounds i8, ptr %4, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !11
  %29 = icmp ugt i32 %26, %28
  br i1 %29, label %30, label %13

30:                                               ; preds = %24, %22
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  br label %2
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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 = { noreturn 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 = { noreturn 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 0}
!6 = !{!"mec_mr3_dict", !7, i64 0, !9, i64 4, !9, i64 8, !10, i64 16}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!6, !9, i64 4}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass