; LLVM IR from nickgildea/z3_codegen :: codegen.ll (Z10PrintModelR14CodeGenContexti)

; 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.Operands.5 = type <{ ptr, i32, i32, i32, [4 x i8] }>
%class.CodeGenContext = type { ptr, %"class.z3::solver", i32, i32, i32, %"class.z3::ast_vector_tpl", %"class.z3::ast_vector_tpl", %"class.z3::ast_vector_tpl", %"class.z3::ast_vector_tpl", %"class.std::vector", %class.ISASubset }
%"class.z3::solver" = type { %"class.z3::object", ptr }
%"class.z3::object" = type { ptr }
%"class.z3::ast_vector_tpl" = type { %"class.z3::object", ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<z3::ast_vector_tpl<z3::expr>, std::allocator<z3::ast_vector_tpl<z3::expr>>>::_Vector_impl" }
%"struct.std::_Vector_base<z3::ast_vector_tpl<z3::expr>, std::allocator<z3::ast_vector_tpl<z3::expr>>>::_Vector_impl" = type { %"struct.std::_Vector_base<z3::ast_vector_tpl<z3::expr>, std::allocator<z3::ast_vector_tpl<z3::expr>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<z3::ast_vector_tpl<z3::expr>, std::allocator<z3::ast_vector_tpl<z3::expr>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.ISASubset = type { %"class.std::vector.0" }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [2 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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z18CreateEvalOperandsR14CodeGenContextiRi(ptr dead_on_unwind noalias writable sret(%struct.Operands.5) align 8, ptr noundef nonnull align 8 dereferenceable(152), i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10PrintModelR14CodeGenContexti(ptr noundef nonnull align 8 dereferenceable(152) %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.Operands.5, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %9 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %18, %2
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = icmp slt i32 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %21

15:                                               ; preds = %10
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i32 noundef %16)
  br label %18

18:                                               ; preds = %15
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %5, align 4, !tbaa !9
  br label %10, !llvm.loop !11

21:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %22 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %22, ptr %6, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %37, %21
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %class.CodeGenContext, ptr %25, i32 0, i32 4
  %27 = load i32, ptr %26, align 8, !tbaa !13
  %28 = icmp slt i32 %24, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %40

30:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 -1, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #3
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = load i32, ptr %6, align 4, !tbaa !9
  call void @_Z18CreateEvalOperandsR14CodeGenContextiRi(ptr dead_on_unwind writable sret(%struct.Operands.5) align 8 %8, ptr noundef nonnull align 8 dereferenceable(152) %31, i32 noundef %32, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %class.CodeGenContext, ptr %33, i32 0, i32 10
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = load i32, ptr %6, align 4, !tbaa !9
  call void @_ZN9ISASubset8formatOpEiiRK8OperandsIiE(ptr noundef nonnull align 8 dereferenceable(24) %34, i32 noundef %35, i32 noundef %36, ptr noundef nonnull align 8 dereferenceable(20) %8)
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %37

37:                                               ; preds = %30
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %6, align 4, !tbaa !9
  br label %23, !llvm.loop !27

40:                                               ; preds = %29
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9ISASubset8formatOpEiiRK8OperandsIiE(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(20)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 32}
!14 = !{!"_ZTS14CodeGenContext", !6, i64 0, !15, i64 8, !10, i64 24, !10, i64 28, !10, i64 32, !17, i64 40, !17, i64 56, !17, i64 72, !17, i64 88, !18, i64 104, !22, i64 128}
!15 = !{!"_ZTSN2z36solverE", !16, i64 0, !6, i64 8}
!16 = !{!"_ZTSN2z36objectE", !6, i64 0}
!17 = !{!"_ZTSN2z314ast_vector_tplINS_4exprEEE", !16, i64 0, !6, i64 8}
!18 = !{!"_ZTSSt6vectorIN2z314ast_vector_tplINS0_4exprEEESaIS3_EE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseIN2z314ast_vector_tplINS0_4exprEEESaIS3_EE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN2z314ast_vector_tplINS0_4exprEEESaIS3_EE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN2z314ast_vector_tplINS0_4exprEEESaIS3_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!22 = !{!"_ZTS9ISASubset", !23, i64 0}
!23 = !{!"_ZTSSt6vectorIiSaIiEE", !24, i64 0}
!24 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!27 = distinct !{!27, !12}


; 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.Operands.5 = type <{ ptr, i32, i32, i32, [4 x i8] }>

@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z18CreateEvalOperandsR14CodeGenContextiRi(ptr dead_on_unwind noalias writable sret(%struct.Operands.5) align 8, ptr noundef nonnull align 8 dereferenceable(152), i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10PrintModelR14CodeGenContexti(ptr noundef nonnull align 8 dereferenceable(152) %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = alloca %struct.Operands.5, align 8
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %6 = icmp sgt i32 %1, 0
  br i1 %6, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %2
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = icmp sgt i32 %8, %1
  br i1 %9, label %.lr.ph15, label %._crit_edge

.lr.ph15:                                         ; preds = %.preheader
  %10 = getelementptr inbounds i8, ptr %0, i64 128
  br label %14

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.01113 = phi i32 [ %12, %.lr.ph ], [ 0, %2 ]
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %.01113)
  %12 = add nuw nsw i32 %.01113, 1
  %exitcond.not = icmp eq i32 %12, %1
  br i1 %exitcond.not, label %.preheader, label %.lr.ph, !llvm.loop !23

._crit_edge:                                      ; preds = %14, %.preheader
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  ret void

14:                                               ; preds = %.lr.ph15, %14
  %.014 = phi i32 [ %1, %.lr.ph15 ], [ %16, %14 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  store i32 -1, ptr %3, align 4, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #3
  call void @_Z18CreateEvalOperandsR14CodeGenContextiRi(ptr dead_on_unwind nonnull writable sret(%struct.Operands.5) align 8 %4, ptr noundef nonnull align 8 dereferenceable(152) %0, i32 noundef %.014, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %15 = load i32, ptr %3, align 4, !tbaa !25
  call void @_ZN9ISASubset8formatOpEiiRK8OperandsIiE(ptr noundef nonnull align 8 dereferenceable(24) %10, i32 noundef %15, i32 noundef %.014, ptr noundef nonnull align 8 dereferenceable(20) %4)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  %16 = add nsw i32 %.014, 1
  %17 = load i32, ptr %7, align 8, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %14, label %._crit_edge, !llvm.loop !26
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nofree 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 }

!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, !12, i64 32}
!6 = !{!"_ZTS14CodeGenContext", !7, i64 0, !10, i64 8, !12, i64 24, !12, i64 28, !12, i64 32, !13, i64 40, !13, i64 56, !13, i64 72, !13, i64 88, !14, i64 104, !18, i64 128}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN2z36solverE", !11, i64 0, !7, i64 8}
!11 = !{!"_ZTSN2z36objectE", !7, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"_ZTSN2z314ast_vector_tplINS_4exprEEE", !11, i64 0, !7, i64 8}
!14 = !{!"_ZTSSt6vectorIN2z314ast_vector_tplINS0_4exprEEESaIS3_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIN2z314ast_vector_tplINS0_4exprEEESaIS3_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN2z314ast_vector_tplINS0_4exprEEESaIS3_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN2z314ast_vector_tplINS0_4exprEEESaIS3_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!18 = !{!"_ZTS9ISASubset", !19, i64 0}
!19 = !{!"_ZTSSt6vectorIiSaIiEE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!12, !12, i64 0}
!26 = distinct !{!26, !24}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass