; 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

; 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 ptr @get_mec_mr3_info_name(i8 noundef zeroext %0, i32 noundef %1) #1 {
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store i8 %0, ptr %3, align 1, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store ptr null, ptr %5, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !8
  br label %8

8:                                                ; preds = %34, %2
  %9 = load i32, ptr %6, align 4, !tbaa !8
  %10 = icmp ult i32 %9, 796
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %37

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

23:                                               ; preds = %12
  %24 = load i32, ptr %4, align 4, !tbaa !8
  %25 = load ptr, ptr %7, align 8, !tbaa !10
  %26 = getelementptr inbounds %struct.mec_mr3_dict, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !14
  %28 = icmp eq i32 %24, %27
  br i1 %28, label %29, label %33

29:                                               ; preds = %23
  %30 = load ptr, ptr %7, align 8, !tbaa !10
  %31 = getelementptr inbounds %struct.mec_mr3_dict, ptr %30, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  store ptr %32, ptr %5, align 8, !tbaa !10
  br label %33

33:                                               ; preds = %29, %23, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %6, align 4, !tbaa !8
  %36 = add i32 %35, 1
  store i32 %36, ptr %6, align 4, !tbaa !8
  br label %8, !llvm.loop !16

37:                                               ; preds = %11
  %38 = load ptr, ptr %5, align 8, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret ptr %38
}

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

; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local ptr @get_mec_mr3_info_name(i8 noundef zeroext %0, i32 noundef %1) local_unnamed_addr #0 {
  br label %4

3:                                                ; preds = %26
  ret ptr %.1.1

4:                                                ; preds = %26, %2
  %indvars.iv = phi i64 [ 0, %2 ], [ %indvars.iv.next.1, %26 ]
  %.010 = phi ptr [ null, %2 ], [ %.1.1, %26 ]
  %5 = getelementptr inbounds %struct.mec_mr3_dict, ptr @dict, i64 %indvars.iv
  %6 = load i8, ptr %5, align 16, !tbaa !5
  %7 = icmp eq i8 %6, %0
  br i1 %7, label %8, label %15

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %5, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = icmp eq i32 %10, %1
  br i1 %11, label %12, label %15

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %5, i64 16
  %14 = load ptr, ptr %13, align 16, !tbaa !12
  br label %15

15:                                               ; preds = %12, %8, %4
  %.1 = phi ptr [ %14, %12 ], [ %.010, %8 ], [ %.010, %4 ]
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %16 = getelementptr inbounds %struct.mec_mr3_dict, ptr @dict, i64 %indvars.iv.next
  %17 = load i8, ptr %16, align 8, !tbaa !5
  %18 = icmp eq i8 %17, %0
  br i1 %18, label %19, label %26

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %16, i64 4
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = icmp eq i32 %21, %1
  br i1 %22, label %23, label %26

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %16, i64 16
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  br label %26

26:                                               ; preds = %23, %19, %15
  %.1.1 = phi ptr [ %25, %23 ], [ %.1, %19 ], [ %.1, %15 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 796
  br i1 %exitcond.not.1, label %3, label %4, !llvm.loop !13
}

attributes #0 = { nofree norecurse nosync nounwind memory(none) 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, !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 = !{!6, !10, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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