; LLVM IR from rweather/lightweight-crypto :: src/genavr/code.ll (ZN4Code11bit_permuteERK3RegPKhib)

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

@_ZTISt16invalid_argument = external constant ptr
@.str.12 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [25 x i8], align 1

declare ptr @__cxa_allocate_exception(i64)

declare void @_ZNSt16invalid_argumentC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr)

; Function Attrs: nounwind
declare void @_ZNSt16invalid_argumentD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3Reg4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Code7bit_getERK3Regi(ptr noundef nonnull align 8 dereferenceable(200), ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Code5bitopEN4Insn4TypeEhh(ptr noundef nonnull align 8 dereferenceable(200), i32 noundef, i8 noundef zeroext, i8 noundef zeroext) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Code7bit_putERK3Regi(ptr noundef nonnull align 8 dereferenceable(200), ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #5 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Code11bit_permuteERK3RegPKhib(ptr noundef nonnull align 8 dereferenceable(200) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef %2, i32 noundef %3, i1 noundef zeroext %4) #5 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca i64, align 8
  %20 = alloca i8, align 1
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  %23 = zext i1 %4 to i8
  store i8 %23, ptr %10, align 1, !tbaa !11
  %24 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %25 = load i32, ptr %9, align 4, !tbaa !9
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %36, label %27

27:                                               ; preds = %5
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = call noundef i32 @_ZNK3Reg4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %29)
  %31 = mul nsw i32 %30, 8
  %32 = icmp sgt i32 %28, %31
  br i1 %32, label %36, label %33

33:                                               ; preds = %27
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = icmp sgt i32 %34, 240
  br i1 %35, label %36, label %43

36:                                               ; preds = %33, %27, %5
  %37 = call ptr @__cxa_allocate_exception(i64 16) #8
  invoke void @_ZNSt16invalid_argumentC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %37, ptr noundef @.str.12)
          to label %38 unwind label %39

38:                                               ; preds = %36
  call void @__cxa_throw(ptr %37, ptr @_ZTISt16invalid_argument, ptr @_ZNSt16invalid_argumentD1Ev) #9
  unreachable

39:                                               ; preds = %36
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %14, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %15, align 4
  call void @__cxa_free_exception(ptr %37) #8
  br label %173

43:                                               ; preds = %33
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = call ptr @llvm.stacksave.p0()
  store ptr %46, ptr %16, align 8
  %47 = alloca i8, i64 %45, align 16
  store i64 %45, ptr %17, align 8
  %48 = load i8, ptr %10, align 1, !tbaa !11, !range !13, !noundef !14
  %49 = trunc i8 %48 to i1
  br i1 %49, label %91, label %50

50:                                               ; preds = %43
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  call void @llvm.memset.p0.i64(ptr align 16 %47, i8 -1, i64 %52, i1 false)
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %87, %50
  %54 = load i32, ptr %11, align 4, !tbaa !9
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = icmp slt i32 %54, %55
  br i1 %56, label %57, label %90

57:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #8
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds i8, ptr %58, i64 %60
  %62 = load i8, ptr %61, align 1, !tbaa !15
  %63 = zext i8 %62 to i32
  store i32 %63, ptr %18, align 4, !tbaa !9
  %64 = load i32, ptr %18, align 4, !tbaa !9
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = icmp sge i32 %64, %65
  br i1 %66, label %74, label %67

67:                                               ; preds = %57
  %68 = load i32, ptr %18, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i8, ptr %47, i64 %69
  %71 = load i8, ptr %70, align 1, !tbaa !15
  %72 = zext i8 %71 to i32
  %73 = icmp ne i32 %72, 255
  br i1 %73, label %74, label %81

74:                                               ; preds = %67, %57
  %75 = call ptr @__cxa_allocate_exception(i64 16) #8
  invoke void @_ZNSt16invalid_argumentC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %75, ptr noundef @.str.13)
          to label %76 unwind label %77

76:                                               ; preds = %74
  call void @__cxa_throw(ptr %75, ptr @_ZTISt16invalid_argument, ptr @_ZNSt16invalid_argumentD1Ev) #9
  unreachable

77:                                               ; preds = %74
  %78 = landingpad { ptr, i32 }
          cleanup
  %79 = extractvalue { ptr, i32 } %78, 0
  store ptr %79, ptr %14, align 8
  %80 = extractvalue { ptr, i32 } %78, 1
  store i32 %80, ptr %15, align 4
  call void @__cxa_free_exception(ptr %75) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  br label %173

81:                                               ; preds = %67
  %82 = load i32, ptr %11, align 4, !tbaa !9
  %83 = trunc i32 %82 to i8
  %84 = load i32, ptr %18, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds i8, ptr %47, i64 %85
  store i8 %83, ptr %86, align 1, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  br label %87

87:                                               ; preds = %81
  %88 = load i32, ptr %11, align 4, !tbaa !9
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %11, align 4, !tbaa !9
  br label %53, !llvm.loop !16

90:                                               ; preds = %53
  br label %95

91:                                               ; preds = %43
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = load i32, ptr %9, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %47, ptr align 1 %92, i64 %94, i1 false)
  br label %95

95:                                               ; preds = %91, %90
  %96 = load i32, ptr %9, align 4, !tbaa !9
  %97 = zext i32 %96 to i64
  %98 = alloca i8, i64 %97, align 16
  store i64 %97, ptr %19, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %20) #8
  %99 = call noundef zeroext i8 @_ZN4Code7tempregEv(ptr noundef nonnull align 8 dereferenceable(200) %24)
  store i8 %99, ptr %20, align 1, !tbaa !15
  %100 = load i32, ptr %9, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  call void @llvm.memset.p0.i64(ptr align 16 %98, i8 0, i64 %101, i1 false)
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %102

102:                                              ; preds = %168, %95
  %103 = load i32, ptr %11, align 4, !tbaa !9
  %104 = load i32, ptr %9, align 4, !tbaa !9
  %105 = icmp slt i32 %103, %104
  br i1 %105, label %106, label %171

106:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #8
  %107 = load i32, ptr %11, align 4, !tbaa !9
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds i8, ptr %47, i64 %108
  %110 = load i8, ptr %109, align 1, !tbaa !15
  %111 = zext i8 %110 to i32
  store i32 %111, ptr %21, align 4, !tbaa !9
  %112 = load i32, ptr %11, align 4, !tbaa !9
  %113 = load i32, ptr %21, align 4, !tbaa !9
  %114 = icmp eq i32 %112, %113
  br i1 %114, label %115, label %119

115:                                              ; preds = %106
  %116 = load i32, ptr %11, align 4, !tbaa !9
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds i8, ptr %98, i64 %117
  store i8 1, ptr %118, align 1, !tbaa !15
  store i32 7, ptr %22, align 4
  br label %165

119:                                              ; preds = %106
  %120 = load i32, ptr %11, align 4, !tbaa !9
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds i8, ptr %98, i64 %121
  %123 = load i8, ptr %122, align 1, !tbaa !15
  %124 = icmp ne i8 %123, 0
  br i1 %124, label %125, label %126

125:                                              ; preds = %119
  store i32 7, ptr %22, align 4
  br label %165

126:                                              ; preds = %119
  br label %127

127:                                              ; preds = %126
  %128 = load ptr, ptr %7, align 8, !tbaa !5
  %129 = load i32, ptr %11, align 4, !tbaa !9
  call void @_ZN4Code7bit_getERK3Regi(ptr noundef nonnull align 8 dereferenceable(200) %24, ptr noundef nonnull align 8 dereferenceable(24) %128, i32 noundef %129)
  %130 = load i8, ptr %20, align 1, !tbaa !15
  call void @_ZN4Code5bitopEN4Insn4TypeEhh(ptr noundef nonnull align 8 dereferenceable(200) %24, i32 noundef 6, i8 noundef zeroext %130, i8 noundef zeroext 0)
  %131 = load i32, ptr %11, align 4, !tbaa !9
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds i8, ptr %98, i64 %132
  store i8 1, ptr %133, align 1, !tbaa !15
  %134 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %134, ptr %12, align 4, !tbaa !9
  %135 = load i32, ptr %11, align 4, !tbaa !9
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds i8, ptr %47, i64 %136
  %138 = load i8, ptr %137, align 1, !tbaa !15
  %139 = zext i8 %138 to i32
  store i32 %139, ptr %13, align 4, !tbaa !9
  br label %140

140:                                              ; preds = %147, %127
  %141 = load i32, ptr %13, align 4, !tbaa !9
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds i8, ptr %98, i64 %142
  %144 = load i8, ptr %143, align 1, !tbaa !15
  %145 = icmp ne i8 %144, 0
  %146 = xor i1 %145, true
  br i1 %146, label %147, label %161

147:                                              ; preds = %140
  %148 = load ptr, ptr %7, align 8, !tbaa !5
  %149 = load i32, ptr %13, align 4, !tbaa !9
  call void @_ZN4Code7bit_getERK3Regi(ptr noundef nonnull align 8 dereferenceable(200) %24, ptr noundef nonnull align 8 dereferenceable(24) %148, i32 noundef %149)
  %150 = load ptr, ptr %7, align 8, !tbaa !5
  %151 = load i32, ptr %12, align 4, !tbaa !9
  call void @_ZN4Code7bit_putERK3Regi(ptr noundef nonnull align 8 dereferenceable(200) %24, ptr noundef nonnull align 8 dereferenceable(24) %150, i32 noundef %151)
  %152 = load i32, ptr %13, align 4, !tbaa !9
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds i8, ptr %98, i64 %153
  store i8 1, ptr %154, align 1, !tbaa !15
  %155 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %155, ptr %12, align 4, !tbaa !9
  %156 = load i32, ptr %12, align 4, !tbaa !9
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds i8, ptr %47, i64 %157
  %159 = load i8, ptr %158, align 1, !tbaa !15
  %160 = zext i8 %159 to i32
  store i32 %160, ptr %13, align 4, !tbaa !9
  br label %140, !llvm.loop !18

161:                                              ; preds = %140
  %162 = load i8, ptr %20, align 1, !tbaa !15
  call void @_ZN4Code5bitopEN4Insn4TypeEhh(ptr noundef nonnull align 8 dereferenceable(200) %24, i32 noundef 7, i8 noundef zeroext %162, i8 noundef zeroext 0)
  %163 = load ptr, ptr %7, align 8, !tbaa !5
  %164 = load i32, ptr %12, align 4, !tbaa !9
  call void @_ZN4Code7bit_putERK3Regi(ptr noundef nonnull align 8 dereferenceable(200) %24, ptr noundef nonnull align 8 dereferenceable(24) %163, i32 noundef %164)
  store i32 0, ptr %22, align 4
  br label %165

165:                                              ; preds = %161, %125, %115
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #8
  %166 = load i32, ptr %22, align 4
  switch i32 %166, label %179 [
    i32 0, label %167
    i32 7, label %168
  ]

167:                                              ; preds = %165
  br label %168

168:                                              ; preds = %167, %165
  %169 = load i32, ptr %11, align 4, !tbaa !9
  %170 = add nsw i32 %169, 1
  store i32 %170, ptr %11, align 4, !tbaa !9
  br label %102, !llvm.loop !19

171:                                              ; preds = %102
  call void @llvm.lifetime.end.p0(i64 1, ptr %20) #8
  %172 = load ptr, ptr %16, align 8
  call void @llvm.stackrestore.p0(ptr %172)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  ret void

173:                                              ; preds = %77, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  br label %174

174:                                              ; preds = %173
  %175 = load ptr, ptr %14, align 8
  %176 = load i32, ptr %15, align 4
  %177 = insertvalue { ptr, i32 } poison, ptr %175, 0
  %178 = insertvalue { ptr, i32 } %177, i32 %176, 1
  resume { ptr, i32 } %178

179:                                              ; preds = %165
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #6

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #7

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN4Code7tempregEv(ptr noundef nonnull align 8 dereferenceable(200)) #5 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #6

attributes #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 = { 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 = { mustprogress 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { nocallback nofree nosync nounwind willreturn }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #8 = { nounwind }
attributes #9 = { noreturn }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}


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

@_ZTISt16invalid_argument = external constant ptr
@.str.12 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [25 x i8], align 1

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @_ZNSt16invalid_argumentC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: nounwind
declare void @_ZNSt16invalid_argumentD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3Reg4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Code7bit_getERK3Regi(ptr noundef nonnull align 8 dereferenceable(200), ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Code5bitopEN4Insn4TypeEhh(ptr noundef nonnull align 8 dereferenceable(200), i32 noundef, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Code7bit_putERK3Regi(ptr noundef nonnull align 8 dereferenceable(200), ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Code11bit_permuteERK3RegPKhib(ptr noundef nonnull align 8 dereferenceable(200) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr nocapture noundef readonly %2, i32 noundef %3, i1 noundef zeroext %4) local_unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %6 = icmp slt i32 %3, 0
  br i1 %6, label %12, label %7

7:                                                ; preds = %5
  %8 = tail call noundef i32 @_ZNK3Reg4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %9 = shl nsw i32 %8, 3
  %10 = icmp slt i32 %9, %3
  %11 = icmp ugt i32 %3, 240
  %or.cond = or i1 %11, %10
  br i1 %or.cond, label %12, label %17

12:                                               ; preds = %7, %5
  %13 = tail call ptr @__cxa_allocate_exception(i64 16) #7
  invoke void @_ZNSt16invalid_argumentC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull @.str.12)
          to label %14 unwind label %15

14:                                               ; preds = %12
  tail call void @__cxa_throw(ptr nonnull %13, ptr nonnull @_ZTISt16invalid_argument, ptr nonnull @_ZNSt16invalid_argumentD1Ev) #8
  unreachable

15:                                               ; preds = %12
  %16 = landingpad { ptr, i32 }
          cleanup
  br label %58

17:                                               ; preds = %7
  %18 = zext nneg i32 %3 to i64
  %19 = alloca i8, i64 %18, align 16
  br i1 %4, label %35, label %20

20:                                               ; preds = %17
  call void @llvm.memset.p0.i64(ptr nonnull align 16 %19, i8 -1, i64 %18, i1 false)
  %.not71 = icmp eq i32 %3, 0
  br i1 %.not71, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %20
  %21 = trunc nuw i32 %3 to i8
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %33
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %33 ]
  %22 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %.not = icmp ult i8 %23, %21
  br i1 %.not, label %24, label %28

24:                                               ; preds = %.lr.ph
  %25 = zext i8 %23 to i64
  %26 = getelementptr inbounds i8, ptr %19, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %.not56 = icmp eq i8 %27, -1
  br i1 %.not56, label %33, label %28

28:                                               ; preds = %24, %.lr.ph
  %29 = tail call ptr @__cxa_allocate_exception(i64 16) #7
  invoke void @_ZNSt16invalid_argumentC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %29, ptr noundef nonnull @.str.13)
          to label %30 unwind label %31

30:                                               ; preds = %28
  tail call void @__cxa_throw(ptr nonnull %29, ptr nonnull @_ZTISt16invalid_argument, ptr nonnull @_ZNSt16invalid_argumentD1Ev) #8
  unreachable

31:                                               ; preds = %28
  %32 = landingpad { ptr, i32 }
          cleanup
  br label %58

33:                                               ; preds = %24
  %34 = trunc i64 %indvars.iv to i8
  store i8 %34, ptr %26, align 1, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %18
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !8

35:                                               ; preds = %17
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %19, ptr align 1 %2, i64 %18, i1 false)
  br label %.loopexit

.loopexit:                                        ; preds = %33, %20, %35
  %36 = alloca i8, i64 %18, align 16
  %37 = tail call noundef zeroext i8 @_ZN4Code7tempregEv(ptr noundef nonnull align 8 dereferenceable(200) %0)
  call void @llvm.memset.p0.i64(ptr nonnull align 16 %36, i8 0, i64 %18, i1 false)
  %.not72 = icmp eq i32 %3, 0
  br i1 %.not72, label %._crit_edge70, label %.lr.ph69.preheader

.lr.ph69.preheader:                               ; preds = %.loopexit
  %smax = tail call i32 @llvm.smax.i32(i32 %3, i32 1)
  %wide.trip.count77 = zext nneg i32 %smax to i64
  br label %.lr.ph69

.lr.ph69:                                         ; preds = %.lr.ph69.preheader, %57
  %indvars.iv74 = phi i64 [ 0, %.lr.ph69.preheader ], [ %indvars.iv.next75, %57 ]
  %38 = getelementptr inbounds i8, ptr %19, i64 %indvars.iv74
  %39 = load i8, ptr %38, align 1, !tbaa !5
  %40 = zext i8 %39 to i64
  %41 = icmp eq i64 %indvars.iv74, %40
  %42 = getelementptr inbounds i8, ptr %36, i64 %indvars.iv74
  br i1 %41, label %43, label %44

43:                                               ; preds = %.lr.ph69
  store i8 1, ptr %42, align 1, !tbaa !5
  br label %57

44:                                               ; preds = %.lr.ph69
  %45 = load i8, ptr %42, align 1, !tbaa !5
  %.not57 = icmp eq i8 %45, 0
  br i1 %.not57, label %46, label %57

46:                                               ; preds = %44
  %47 = trunc nuw nsw i64 %indvars.iv74 to i32
  tail call void @_ZN4Code7bit_getERK3Regi(ptr noundef nonnull align 8 dereferenceable(200) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %47)
  tail call void @_ZN4Code5bitopEN4Insn4TypeEhh(ptr noundef nonnull align 8 dereferenceable(200) %0, i32 noundef 6, i8 noundef zeroext %37, i8 noundef zeroext 0)
  store i8 1, ptr %42, align 1, !tbaa !5
  %48 = zext i8 %39 to i64
  %49 = getelementptr inbounds i8, ptr %36, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !5
  %.not5862 = icmp eq i8 %50, 0
  br i1 %.not5862, label %.lr.ph65, label %._crit_edge

.lr.ph65:                                         ; preds = %46, %.lr.ph65
  %51 = phi ptr [ %55, %.lr.ph65 ], [ %49, %46 ]
  %52 = phi i64 [ %54, %.lr.ph65 ], [ %48, %46 ]
  %.051.in64 = phi i8 [ %.051.in, %.lr.ph65 ], [ %39, %46 ]
  %.05063 = phi i32 [ %.051, %.lr.ph65 ], [ %47, %46 ]
  %.051 = zext i8 %.051.in64 to i32
  tail call void @_ZN4Code7bit_getERK3Regi(ptr noundef nonnull align 8 dereferenceable(200) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %.051)
  tail call void @_ZN4Code7bit_putERK3Regi(ptr noundef nonnull align 8 dereferenceable(200) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %.05063)
  store i8 1, ptr %51, align 1, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %19, i64 %52
  %.051.in = load i8, ptr %53, align 1, !tbaa !5
  %54 = zext i8 %.051.in to i64
  %55 = getelementptr inbounds i8, ptr %36, i64 %54
  %56 = load i8, ptr %55, align 1, !tbaa !5
  %.not58 = icmp eq i8 %56, 0
  br i1 %.not58, label %.lr.ph65, label %._crit_edge, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph65, %46
  %.050.lcssa = phi i32 [ %47, %46 ], [ %.051, %.lr.ph65 ]
  tail call void @_ZN4Code5bitopEN4Insn4TypeEhh(ptr noundef nonnull align 8 dereferenceable(200) %0, i32 noundef 7, i8 noundef zeroext %37, i8 noundef zeroext 0)
  tail call void @_ZN4Code7bit_putERK3Regi(ptr noundef nonnull align 8 dereferenceable(200) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %.050.lcssa)
  br label %57

57:                                               ; preds = %44, %._crit_edge, %43
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %exitcond78.not = icmp eq i64 %indvars.iv.next75, %wide.trip.count77
  br i1 %exitcond78.not, label %._crit_edge70, label %.lr.ph69, !llvm.loop !11

._crit_edge70:                                    ; preds = %57, %.loopexit
  ret void

58:                                               ; preds = %31, %15
  %.sink = phi ptr [ %29, %31 ], [ %13, %15 ]
  %.pn = phi { ptr, i32 } [ %32, %31 ], [ %16, %15 ]
  tail call void @__cxa_free_exception(ptr %.sink) #7
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN4Code7tempregEv(ptr noundef nonnull align 8 dereferenceable(200)) local_unnamed_addr #4 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #6

attributes #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 = { 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 = { mustprogress 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { noreturn }

!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++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = distinct !{!11, !9}


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