; LLVM IR from cfeck/imagezero :: table.ll (ZN2IZ15initDecodeTableEv)

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

@_ZN2IZ12staticdCountE = external dso_local constant <{ [137 x i32], [119 x i32] }>, align 16
@_ZN2IZ11staticdBitsE = external dso_local global [256 x i32], align 16
@_ZN2IZ11decodeTableE = external dso_local global [16 x [64 x i8]], align 16

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2IZL13initBitsTableEv() #0

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

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

9:                                                ; preds = %6
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  br label %65

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %58, %10
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = icmp ult i32 %12, 64
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %61

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %53, %15
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = icmp ult i32 %17, 9
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  store i32 8, ptr %2, align 4
  br label %56

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %21 = load i32, ptr %1, align 4, !tbaa !5
  %22 = shl i32 %21, 4
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = add i32 %22, %23
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ12staticdCountE, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  store i32 %27, ptr %5, align 4, !tbaa !5
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = sub nsw i32 6, %29
  %31 = lshr i32 %28, %30
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = shl i32 %32, 4
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = add i32 %33, %34
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ11staticdBitsE, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = icmp eq i32 %31, %38
  br i1 %39, label %40, label %49

40:                                               ; preds = %20
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = trunc i32 %41 to i8
  %43 = load i32, ptr %1, align 4, !tbaa !5
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds [16 x [64 x i8]], ptr @_ZN2IZ11decodeTableE, i64 0, i64 %44
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds [64 x i8], ptr %45, i64 0, i64 %47
  store i8 %42, ptr %48, align 1, !tbaa !9
  store i32 8, ptr %2, align 4
  br label %50

49:                                               ; preds = %20
  store i32 0, ptr %2, align 4
  br label %50

50:                                               ; preds = %49, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  %51 = load i32, ptr %2, align 4
  switch i32 %51, label %56 [
    i32 0, label %52
  ]

52:                                               ; preds = %50
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = add i32 %54, 1
  store i32 %55, ptr %4, align 4, !tbaa !5
  br label %16, !llvm.loop !10

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

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = add i32 %59, 1
  store i32 %60, ptr %3, align 4, !tbaa !5
  br label %11, !llvm.loop !12

61:                                               ; preds = %14
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %1, align 4, !tbaa !5
  %64 = add i32 %63, 1
  store i32 %64, ptr %1, align 4, !tbaa !5
  br label %6, !llvm.loop !13

65:                                               ; preds = %9
  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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { mustprogress 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 }

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


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

@_ZN2IZ12staticdCountE = external dso_local local_unnamed_addr constant <{ [137 x i32], [119 x i32] }>, align 16
@_ZN2IZ11staticdBitsE = external dso_local local_unnamed_addr global [256 x i32], align 16
@_ZN2IZ11decodeTableE = external dso_local local_unnamed_addr global [16 x [64 x i8]], align 16

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2IZL13initBitsTableEv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2IZ15initDecodeTableEv() local_unnamed_addr #0 {
  tail call void @_ZN2IZL13initBitsTableEv()
  br label %.preheader19

.preheader19:                                     ; preds = %0, %30
  %indvars.iv27 = phi i64 [ 0, %0 ], [ %indvars.iv.next28, %30 ]
  %1 = shl nuw nsw i64 %indvars.iv27, 4
  %.phi.trans.insert = getelementptr inbounds [256 x i32], ptr @_ZN2IZ12staticdCountE, i64 0, i64 %1
  %.pre = load i32, ptr %.phi.trans.insert, align 16, !tbaa !5
  %.phi.trans.insert31 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ11staticdBitsE, i64 0, i64 %1
  %.pre32 = load i32, ptr %.phi.trans.insert31, align 16, !tbaa !5
  %2 = sub nsw i32 6, %.pre
  %3 = or disjoint i64 %1, 1
  %4 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ12staticdCountE, i64 0, i64 %3
  %5 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ11staticdBitsE, i64 0, i64 %3
  %6 = or disjoint i64 %1, 2
  %7 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ12staticdCountE, i64 0, i64 %6
  %8 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ11staticdBitsE, i64 0, i64 %6
  %9 = or disjoint i64 %1, 3
  %10 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ12staticdCountE, i64 0, i64 %9
  %11 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ11staticdBitsE, i64 0, i64 %9
  %12 = or disjoint i64 %1, 4
  %13 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ12staticdCountE, i64 0, i64 %12
  %14 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ11staticdBitsE, i64 0, i64 %12
  %15 = or disjoint i64 %1, 5
  %16 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ12staticdCountE, i64 0, i64 %15
  %17 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ11staticdBitsE, i64 0, i64 %15
  %18 = or disjoint i64 %1, 6
  %19 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ12staticdCountE, i64 0, i64 %18
  %20 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ11staticdBitsE, i64 0, i64 %18
  %21 = or disjoint i64 %1, 7
  %22 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ12staticdCountE, i64 0, i64 %21
  %23 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ11staticdBitsE, i64 0, i64 %21
  %24 = or disjoint i64 %1, 8
  %25 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ12staticdCountE, i64 0, i64 %24
  %26 = getelementptr inbounds [256 x i32], ptr @_ZN2IZ11staticdBitsE, i64 0, i64 %24
  br label %.preheader

27:                                               ; preds = %30
  ret void

.preheader:                                       ; preds = %.preheader19, %.loopexit
  %indvars.iv = phi i64 [ 0, %.preheader19 ], [ %indvars.iv.next, %.loopexit ]
  %28 = trunc nuw nsw i64 %indvars.iv to i32
  %29 = lshr i32 %28, %2
  %.not = icmp eq i32 %29, %.pre32
  br i1 %.not, label %31, label %.critedge

30:                                               ; preds = %.loopexit
  %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1
  %exitcond30.not = icmp eq i64 %indvars.iv.next28, 9
  br i1 %exitcond30.not, label %27, label %.preheader19, !llvm.loop !9

31:                                               ; preds = %.critedge.7, %.critedge.6, %.critedge.5, %.critedge.4, %.critedge.3, %.critedge.2, %.critedge.1, %.critedge, %.preheader
  %.01621.lcssa.wide = phi i8 [ 0, %.preheader ], [ 1, %.critedge ], [ 2, %.critedge.1 ], [ 3, %.critedge.2 ], [ 4, %.critedge.3 ], [ 5, %.critedge.4 ], [ 6, %.critedge.5 ], [ 7, %.critedge.6 ], [ 8, %.critedge.7 ]
  %32 = getelementptr inbounds [16 x [64 x i8]], ptr @_ZN2IZ11decodeTableE, i64 0, i64 %indvars.iv27, i64 %indvars.iv
  store i8 %.01621.lcssa.wide, ptr %32, align 1, !tbaa !11
  br label %.loopexit

.critedge:                                        ; preds = %.preheader
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sub nsw i32 6, %33
  %35 = lshr i32 %28, %34
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %.not.1 = icmp eq i32 %35, %36
  br i1 %.not.1, label %31, label %.critedge.1

.critedge.1:                                      ; preds = %.critedge
  %37 = load i32, ptr %7, align 8, !tbaa !5
  %38 = sub nsw i32 6, %37
  %39 = lshr i32 %28, %38
  %40 = load i32, ptr %8, align 8, !tbaa !5
  %.not.2 = icmp eq i32 %39, %40
  br i1 %.not.2, label %31, label %.critedge.2

.critedge.2:                                      ; preds = %.critedge.1
  %41 = load i32, ptr %10, align 4, !tbaa !5
  %42 = sub nsw i32 6, %41
  %43 = lshr i32 %28, %42
  %44 = load i32, ptr %11, align 4, !tbaa !5
  %.not.3 = icmp eq i32 %43, %44
  br i1 %.not.3, label %31, label %.critedge.3

.critedge.3:                                      ; preds = %.critedge.2
  %45 = load i32, ptr %13, align 16, !tbaa !5
  %46 = sub nsw i32 6, %45
  %47 = lshr i32 %28, %46
  %48 = load i32, ptr %14, align 16, !tbaa !5
  %.not.4 = icmp eq i32 %47, %48
  br i1 %.not.4, label %31, label %.critedge.4

.critedge.4:                                      ; preds = %.critedge.3
  %49 = load i32, ptr %16, align 4, !tbaa !5
  %50 = sub nsw i32 6, %49
  %51 = lshr i32 %28, %50
  %52 = load i32, ptr %17, align 4, !tbaa !5
  %.not.5 = icmp eq i32 %51, %52
  br i1 %.not.5, label %31, label %.critedge.5

.critedge.5:                                      ; preds = %.critedge.4
  %53 = load i32, ptr %19, align 8, !tbaa !5
  %54 = sub nsw i32 6, %53
  %55 = lshr i32 %28, %54
  %56 = load i32, ptr %20, align 8, !tbaa !5
  %.not.6 = icmp eq i32 %55, %56
  br i1 %.not.6, label %31, label %.critedge.6

.critedge.6:                                      ; preds = %.critedge.5
  %57 = load i32, ptr %22, align 4, !tbaa !5
  %58 = sub nsw i32 6, %57
  %59 = lshr i32 %28, %58
  %60 = load i32, ptr %23, align 4, !tbaa !5
  %.not.7 = icmp eq i32 %59, %60
  br i1 %.not.7, label %31, label %.critedge.7

.critedge.7:                                      ; preds = %.critedge.6
  %61 = load i32, ptr %25, align 16, !tbaa !5
  %62 = sub nsw i32 6, %61
  %63 = lshr i32 %28, %62
  %64 = load i32, ptr %26, align 16, !tbaa !5
  %.not.8 = icmp eq i32 %63, %64
  br i1 %.not.8, label %31, label %.loopexit

.loopexit:                                        ; preds = %.critedge.7, %31
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 64
  br i1 %exitcond.not, label %30, label %.preheader, !llvm.loop !12
}

attributes #0 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass