; LLVM IR from thepowersgang/mrustc :: src/hir/serialise_lowlevel.ll (ZN3HIR9serialise11WriterInner5writeEPKvm)

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

%"class.HIR::serialise::WriterInner" = type { %"class.std::basic_ofstream", %struct.z_stream_s, %"class.std::vector", i32, i32 }
%"class.std::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon }
%union.anon = type { i32 }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%struct.z_stream_s = type { ptr, i32, i64, ptr, i32, i64, ptr, ptr, ptr, ptr, ptr, i32, i64, i64 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.4 = external hidden unnamed_addr constant [85 x i8], align 1
@_ZTISt13runtime_error = external constant ptr
@.str.11 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__._ZN3HIR9serialise11WriterInner5writeEPKvm = external hidden unnamed_addr constant [62 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [26 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3HIR9serialise11WriterInner5writeEPKvm(ptr noundef nonnull align 8 dereferenceable(656) %0, ptr noundef %1, i64 noundef %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %15 = load ptr, ptr %4, align 8
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = trunc i64 %16 to i32
  %18 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %19 = getelementptr inbounds %struct.z_stream_s, ptr %18, i32 0, i32 1
  store i32 %17, ptr %19, align 8, !tbaa !11
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %22 = getelementptr inbounds %struct.z_stream_s, ptr %21, i32 0, i32 0
  store ptr %20, ptr %22, align 8, !tbaa !28
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %23 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %24 = getelementptr inbounds %struct.z_stream_s, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = zext i32 %25 to i64
  store i64 %26, ptr %7, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %101, %3
  %28 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %29 = getelementptr inbounds %struct.z_stream_s, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = icmp ugt i32 %30, 0
  br i1 %31, label %32, label %102

32:                                               ; preds = %27
  %33 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %34 = getelementptr inbounds %struct.z_stream_s, ptr %33, i32 0, i32 4
  %35 = load i32, ptr %34, align 8, !tbaa !29
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %38

37:                                               ; preds = %32
  br label %40

38:                                               ; preds = %32
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.4, i32 noundef 146, ptr noundef @__PRETTY_FUNCTION__._ZN3HIR9serialise11WriterInner5writeEPKvm) #7
  unreachable

39:                                               ; No predecessors!
  br label %40

40:                                               ; preds = %39, %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %41 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %42 = call i32 @deflate(ptr noundef %41, i32 noundef 0)
  store i32 %42, ptr %8, align 4, !tbaa !30
  %43 = load i32, ptr %8, align 4, !tbaa !30
  %44 = icmp eq i32 %43, -2
  br i1 %44, label %45, label %52

45:                                               ; preds = %40
  %46 = call ptr @__cxa_allocate_exception(i64 16) #6
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %46, ptr noundef @.str.12)
          to label %47 unwind label %48

47:                                               ; preds = %45
  call void @__cxa_throw(ptr %46, ptr @_ZTISt13runtime_error, ptr @_ZNSt13runtime_errorD1Ev) #8
  unreachable

48:                                               ; preds = %45
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %9, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %10, align 4
  call void @__cxa_free_exception(ptr %46) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %149

52:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %53 = load i64, ptr %7, align 8, !tbaa !9
  %54 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %55 = getelementptr inbounds %struct.z_stream_s, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 8, !tbaa !11
  %57 = zext i32 %56 to i64
  %58 = sub i64 %53, %57
  store i64 %58, ptr %11, align 8, !tbaa !9
  %59 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %60 = getelementptr inbounds %struct.z_stream_s, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %60, align 8, !tbaa !11
  %62 = zext i32 %61 to i64
  store i64 %62, ptr %7, align 8, !tbaa !9
  %63 = load i64, ptr %11, align 8, !tbaa !9
  %64 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 4
  %65 = load i32, ptr %64, align 4, !tbaa !31
  %66 = zext i32 %65 to i64
  %67 = add i64 %66, %63
  %68 = trunc i64 %67 to i32
  store i32 %68, ptr %64, align 4, !tbaa !31
  %69 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %70 = getelementptr inbounds %struct.z_stream_s, ptr %69, i32 0, i32 1
  %71 = load i32, ptr %70, align 8, !tbaa !11
  %72 = icmp ugt i32 %71, 0
  br i1 %72, label %73, label %101

73:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %74 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 2
  %75 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %74) #6
  %76 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %77 = getelementptr inbounds %struct.z_stream_s, ptr %76, i32 0, i32 4
  %78 = load i32, ptr %77, align 8, !tbaa !29
  %79 = zext i32 %78 to i64
  %80 = sub i64 %75, %79
  store i64 %80, ptr %12, align 8, !tbaa !9
  %81 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 0
  %82 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 2
  %83 = call noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %82) #6
  %84 = load i64, ptr %12, align 8, !tbaa !9
  %85 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8) %81, ptr noundef %83, i64 noundef %84)
  %86 = load i64, ptr %12, align 8, !tbaa !9
  %87 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 3
  %88 = load i32, ptr %87, align 8, !tbaa !32
  %89 = zext i32 %88 to i64
  %90 = add i64 %89, %86
  %91 = trunc i64 %90 to i32
  store i32 %91, ptr %87, align 8, !tbaa !32
  %92 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 2
  %93 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %92) #6
  %94 = trunc i64 %93 to i32
  %95 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %96 = getelementptr inbounds %struct.z_stream_s, ptr %95, i32 0, i32 4
  store i32 %94, ptr %96, align 8, !tbaa !29
  %97 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 2
  %98 = call noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %97) #6
  %99 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %100 = getelementptr inbounds %struct.z_stream_s, ptr %99, i32 0, i32 3
  store ptr %98, ptr %100, align 8, !tbaa !33
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %101

101:                                              ; preds = %73, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %27, !llvm.loop !34

102:                                              ; preds = %27
  br label %103

103:                                              ; preds = %147, %102
  %104 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %105 = getelementptr inbounds %struct.z_stream_s, ptr %104, i32 0, i32 4
  %106 = load i32, ptr %105, align 8, !tbaa !29
  %107 = icmp eq i32 %106, 0
  br i1 %107, label %108, label %148

108:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %109 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 2
  %110 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %109) #6
  %111 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %112 = getelementptr inbounds %struct.z_stream_s, ptr %111, i32 0, i32 4
  %113 = load i32, ptr %112, align 8, !tbaa !29
  %114 = zext i32 %113 to i64
  %115 = sub i64 %110, %114
  store i64 %115, ptr %13, align 8, !tbaa !9
  %116 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 0
  %117 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 2
  %118 = call noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %117) #6
  %119 = load i64, ptr %13, align 8, !tbaa !9
  %120 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8) %116, ptr noundef %118, i64 noundef %119)
  %121 = load i64, ptr %13, align 8, !tbaa !9
  %122 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 3
  %123 = load i32, ptr %122, align 8, !tbaa !32
  %124 = zext i32 %123 to i64
  %125 = add i64 %124, %121
  %126 = trunc i64 %125 to i32
  store i32 %126, ptr %122, align 8, !tbaa !32
  %127 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 2
  %128 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %127) #6
  %129 = trunc i64 %128 to i32
  %130 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %131 = getelementptr inbounds %struct.z_stream_s, ptr %130, i32 0, i32 4
  store i32 %129, ptr %131, align 8, !tbaa !29
  %132 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 2
  %133 = call noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %132) #6
  %134 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %135 = getelementptr inbounds %struct.z_stream_s, ptr %134, i32 0, i32 3
  store ptr %133, ptr %135, align 8, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %136 = getelementptr inbounds %"class.HIR::serialise::WriterInner", ptr %15, i32 0, i32 1
  %137 = call i32 @deflate(ptr noundef %136, i32 noundef 0)
  store i32 %137, ptr %14, align 4, !tbaa !30
  %138 = load i32, ptr %14, align 4, !tbaa !30
  %139 = icmp eq i32 %138, -2
  br i1 %139, label %140, label %147

140:                                              ; preds = %108
  %141 = call ptr @__cxa_allocate_exception(i64 16) #6
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %141, ptr noundef @.str.12)
          to label %142 unwind label %143

142:                                              ; preds = %140
  call void @__cxa_throw(ptr %141, ptr @_ZTISt13runtime_error, ptr @_ZNSt13runtime_errorD1Ev) #8
  unreachable

143:                                              ; preds = %140
  %144 = landingpad { ptr, i32 }
          cleanup
  %145 = extractvalue { ptr, i32 } %144, 0
  store ptr %145, ptr %9, align 8
  %146 = extractvalue { ptr, i32 } %144, 1
  store i32 %146, ptr %10, align 4
  call void @__cxa_free_exception(ptr %141) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %149

147:                                              ; preds = %108
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %103, !llvm.loop !36

148:                                              ; preds = %103
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret void

149:                                              ; preds = %143, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %150

150:                                              ; preds = %149
  %151 = load ptr, ptr %9, align 8
  %152 = load i32, ptr %10, align 4
  %153 = insertvalue { ptr, i32 } poison, ptr %151, 0
  %154 = insertvalue { ptr, i32 } %153, i32 %152, 1
  resume { ptr, i32 } %154
}

declare ptr @__cxa_allocate_exception(i64)

declare void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #3

declare void @__cxa_free_exception(ptr)

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

declare void @__cxa_throw(ptr, ptr, ptr)

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

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

declare i32 @deflate(ptr noundef, i32 noundef) #3

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { "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 #4 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !22, i64 520}
!12 = !{!"_ZTSN3HIR9serialise11WriterInnerE", !13, i64 0, !23, i64 512, !24, i64 624, !22, i64 648, !22, i64 652}
!13 = !{!"_ZTSSt14basic_ofstreamIcSt11char_traitsIcEE", !14, i64 0, !15, i64 8}
!14 = !{!"_ZTSSo"}
!15 = !{!"_ZTSSt13basic_filebufIcSt11char_traitsIcEE", !16, i64 0, !7, i64 64, !18, i64 104, !20, i64 120, !21, i64 124, !21, i64 132, !21, i64 140, !6, i64 152, !10, i64 160, !19, i64 168, !19, i64 169, !19, i64 170, !7, i64 171, !6, i64 176, !6, i64 184, !19, i64 192, !6, i64 200, !6, i64 208, !10, i64 216, !6, i64 224, !6, i64 232}
!16 = !{!"_ZTSSt15basic_streambufIcSt11char_traitsIcEE", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !17, i64 56}
!17 = !{!"_ZTSSt6locale", !6, i64 0}
!18 = !{!"_ZTSSt12__basic_fileIcE", !6, i64 0, !19, i64 8}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"_ZTSSt13_Ios_Openmode", !7, i64 0}
!21 = !{!"_ZTS11__mbstate_t", !22, i64 0, !7, i64 4}
!22 = !{!"int", !7, i64 0}
!23 = !{!"_ZTS10z_stream_s", !6, i64 0, !22, i64 8, !10, i64 16, !6, i64 24, !22, i64 32, !10, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !22, i64 88, !10, i64 96, !10, i64 104}
!24 = !{!"_ZTSSt6vectorIhSaIhEE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!28 = !{!12, !6, i64 512}
!29 = !{!12, !22, i64 544}
!30 = !{!22, !22, i64 0}
!31 = !{!12, !22, i64 652}
!32 = !{!12, !22, i64 648}
!33 = !{!12, !6, i64 536}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}
!36 = distinct !{!36, !35}


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

@.str.4 = external hidden unnamed_addr constant [85 x i8], align 1
@_ZTISt13runtime_error = external constant ptr
@.str.11 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__._ZN3HIR9serialise11WriterInner5writeEPKvm = external hidden unnamed_addr constant [62 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [26 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3HIR9serialise11WriterInner5writeEPKvm(ptr noundef nonnull align 8 dereferenceable(656) %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = trunc i64 %2 to i32
  %5 = getelementptr inbounds i8, ptr %0, i64 512
  %6 = getelementptr inbounds i8, ptr %0, i64 520
  store i32 %4, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !26
  %.not17 = icmp eq i32 %4, 0
  br i1 %.not17, label %.preheader, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 544
  %8 = getelementptr inbounds i8, ptr %0, i64 652
  %9 = getelementptr inbounds i8, ptr %0, i64 624
  %10 = getelementptr inbounds i8, ptr %0, i64 648
  %11 = getelementptr inbounds i8, ptr %0, i64 536
  br label %16

.preheader:                                       ; preds = %27, %32, %3
  %12 = getelementptr inbounds i8, ptr %0, i64 544
  %13 = getelementptr inbounds i8, ptr %0, i64 624
  %14 = getelementptr inbounds i8, ptr %0, i64 648
  %15 = getelementptr inbounds i8, ptr %0, i64 536
  br label %45

16:                                               ; preds = %.lr.ph, %32
  %.018 = phi i32 [ %4, %.lr.ph ], [ %28, %32 ]
  %17 = load i32, ptr %7, align 8, !tbaa !27
  %.not14 = icmp eq i32 %17, 0
  br i1 %.not14, label %18, label %19

18:                                               ; preds = %16
  tail call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.4, i32 noundef 146, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN3HIR9serialise11WriterInner5writeEPKvm) #5
  unreachable

19:                                               ; preds = %16
  %20 = tail call i32 @deflate(ptr noundef nonnull %5, i32 noundef 0)
  %21 = icmp eq i32 %20, -2
  br i1 %21, label %22, label %27

22:                                               ; preds = %19
  %23 = tail call ptr @__cxa_allocate_exception(i64 16) #6
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull @.str.12)
          to label %24 unwind label %25

24:                                               ; preds = %22
  tail call void @__cxa_throw(ptr nonnull %23, ptr nonnull @_ZTISt13runtime_error, ptr nonnull @_ZNSt13runtime_errorD1Ev) #7
  unreachable

25:                                               ; preds = %22
  %26 = landingpad { ptr, i32 }
          cleanup
  br label %69

27:                                               ; preds = %19
  %28 = load i32, ptr %6, align 8, !tbaa !5
  %29 = load i32, ptr %8, align 4, !tbaa !28
  %30 = sub i32 %.018, %28
  %31 = add i32 %30, %29
  store i32 %31, ptr %8, align 4, !tbaa !28
  %.not15 = icmp eq i32 %28, 0
  br i1 %.not15, label %.preheader, label %32

32:                                               ; preds = %27
  %33 = tail call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #6
  %34 = load i32, ptr %7, align 8, !tbaa !27
  %35 = zext i32 %34 to i64
  %36 = sub i64 %33, %35
  %37 = tail call noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #6
  %38 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %37, i64 noundef %36)
  %39 = load i32, ptr %10, align 8, !tbaa !29
  %40 = trunc i64 %36 to i32
  %41 = add i32 %39, %40
  store i32 %41, ptr %10, align 8, !tbaa !29
  %42 = tail call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #6
  %43 = trunc i64 %42 to i32
  store i32 %43, ptr %7, align 8, !tbaa !27
  %44 = tail call noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #6
  store ptr %44, ptr %11, align 8, !tbaa !30
  %.pr.pre = load i32, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i32 %.pr.pre, 0
  br i1 %.not, label %.preheader, label %16, !llvm.loop !31

45:                                               ; preds = %.preheader, %48
  %46 = load i32, ptr %12, align 8, !tbaa !27
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %68

48:                                               ; preds = %45
  %49 = tail call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #6
  %50 = load i32, ptr %12, align 8, !tbaa !27
  %51 = zext i32 %50 to i64
  %52 = sub i64 %49, %51
  %53 = tail call noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #6
  %54 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %53, i64 noundef %52)
  %55 = load i32, ptr %14, align 8, !tbaa !29
  %56 = trunc i64 %52 to i32
  %57 = add i32 %55, %56
  store i32 %57, ptr %14, align 8, !tbaa !29
  %58 = tail call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #6
  %59 = trunc i64 %58 to i32
  store i32 %59, ptr %12, align 8, !tbaa !27
  %60 = tail call noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #6
  store ptr %60, ptr %15, align 8, !tbaa !30
  %61 = tail call i32 @deflate(ptr noundef nonnull %5, i32 noundef 0)
  %62 = icmp eq i32 %61, -2
  br i1 %62, label %63, label %45, !llvm.loop !33

63:                                               ; preds = %48
  %64 = tail call ptr @__cxa_allocate_exception(i64 16) #6
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %64, ptr noundef nonnull @.str.12)
          to label %65 unwind label %66

65:                                               ; preds = %63
  tail call void @__cxa_throw(ptr nonnull %64, ptr nonnull @_ZTISt13runtime_error, ptr nonnull @_ZNSt13runtime_errorD1Ev) #7
  unreachable

66:                                               ; preds = %63
  %67 = landingpad { ptr, i32 }
          cleanup
  br label %69

68:                                               ; preds = %45
  ret void

69:                                               ; preds = %66, %25
  %.sink = phi ptr [ %64, %66 ], [ %23, %25 ]
  %.pn = phi { ptr, i32 } [ %67, %66 ], [ %26, %25 ]
  tail call void @__cxa_free_exception(ptr %.sink) #6
  resume { ptr, i32 } %.pn
}

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #2

declare void @__cxa_free_exception(ptr) local_unnamed_addr

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

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

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

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

declare i32 @deflate(ptr noundef, i32 noundef) local_unnamed_addr #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { 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 #2 = { "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 "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 #4 = { 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 #5 = { noreturn nounwind }
attributes #6 = { nounwind }
attributes #7 = { 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, !19, i64 520}
!6 = !{!"_ZTSN3HIR9serialise11WriterInnerE", !7, i64 0, !21, i64 512, !22, i64 624, !19, i64 648, !19, i64 652}
!7 = !{!"_ZTSSt14basic_ofstreamIcSt11char_traitsIcEE", !8, i64 0, !9, i64 8}
!8 = !{!"_ZTSSo"}
!9 = !{!"_ZTSSt13basic_filebufIcSt11char_traitsIcEE", !10, i64 0, !12, i64 64, !15, i64 104, !17, i64 120, !18, i64 124, !18, i64 132, !18, i64 140, !11, i64 152, !20, i64 160, !16, i64 168, !16, i64 169, !16, i64 170, !12, i64 171, !11, i64 176, !11, i64 184, !16, i64 192, !11, i64 200, !11, i64 208, !20, i64 216, !11, i64 224, !11, i64 232}
!10 = !{!"_ZTSSt15basic_streambufIcSt11char_traitsIcEE", !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !14, i64 56}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"_ZTSSt6locale", !11, i64 0}
!15 = !{!"_ZTSSt12__basic_fileIcE", !11, i64 0, !16, i64 8}
!16 = !{!"bool", !12, i64 0}
!17 = !{!"_ZTSSt13_Ios_Openmode", !12, i64 0}
!18 = !{!"_ZTS11__mbstate_t", !19, i64 0, !12, i64 4}
!19 = !{!"int", !12, i64 0}
!20 = !{!"long", !12, i64 0}
!21 = !{!"_ZTS10z_stream_s", !11, i64 0, !19, i64 8, !20, i64 16, !11, i64 24, !19, i64 32, !20, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !19, i64 88, !20, i64 96, !20, i64 104}
!22 = !{!"_ZTSSt6vectorIhSaIhEE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!26 = !{!6, !11, i64 512}
!27 = !{!6, !19, i64 544}
!28 = !{!6, !19, i64 652}
!29 = !{!6, !19, i64 648}
!30 = !{!6, !11, i64 536}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}
!33 = distinct !{!33, !32}


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