; LLVM IR from wuzhouhui/leetcode :: 12_int_to_roman (intToRoman)

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

@nums = external hidden global [13 x i32], align 16
@romans = external hidden global [13 x ptr], align 16

; Function Attrs: nounwind uwtable
define dso_local ptr @intToRoman(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %5 = call noalias ptr @calloc(i64 noundef 512, i64 noundef 1) #5
  store ptr %5, ptr %3, align 8, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %32, %1
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = icmp ult i64 %8, 13
  br i1 %9, label %10, label %35

10:                                               ; preds = %6
  br label %11

11:                                               ; preds = %18, %10
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [13 x i32], ptr @nums, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = icmp sge i32 %12, %16
  br i1 %17, label %18, label %31

18:                                               ; preds = %11
  %19 = load ptr, ptr %3, align 8, !tbaa !9
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [13 x ptr], ptr @romans, i64 0, i64 %21
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = call ptr @strcat(ptr noundef %19, ptr noundef %23) #4
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [13 x i32], ptr @nums, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sub nsw i32 %29, %28
  store i32 %30, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !11

31:                                               ; preds = %11
  br label %32

32:                                               ; preds = %31
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %4, align 4, !tbaa !5
  br label %6, !llvm.loop !13

35:                                               ; preds = %6
  %36 = load ptr, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret ptr %36
}

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

; Function Attrs: nounwind
declare ptr @strcat(ptr noundef, ptr noundef) #3

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

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

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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"

@nums = external hidden local_unnamed_addr global [13 x i32], align 16
@romans = external hidden local_unnamed_addr global [13 x ptr], align 16

; Function Attrs: nofree nounwind uwtable
define dso_local noundef ptr @intToRoman(i32 noundef %0) local_unnamed_addr #0 {
.preheader:
  %1 = tail call noalias dereferenceable_or_null(512) ptr @calloc(i64 noundef 512, i64 noundef 1) #3
  %2 = load i32, ptr @nums, align 16, !tbaa !5
  %.not9 = icmp sgt i32 %2, %0
  br i1 %.not9, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %3 = load ptr, ptr @romans, align 16, !tbaa !9
  br label %4

4:                                                ; preds = %.lr.ph, %4
  %.110 = phi i32 [ %0, %.lr.ph ], [ %6, %4 ]
  %5 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %3) #4
  %6 = sub nsw i32 %.110, %2
  %.not = icmp slt i32 %6, %2
  br i1 %.not, label %._crit_edge, label %4, !llvm.loop !11

._crit_edge:                                      ; preds = %4, %.preheader
  %.1.lcssa = phi i32 [ %0, %.preheader ], [ %6, %4 ]
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @nums, i64 4), align 4, !tbaa !5
  %.not9.1 = icmp slt i32 %.1.lcssa, %7
  br i1 %.not9.1, label %._crit_edge.1, label %.lr.ph.1

.lr.ph.1:                                         ; preds = %._crit_edge
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @romans, i64 8), align 8, !tbaa !9
  br label %9

9:                                                ; preds = %9, %.lr.ph.1
  %.110.1 = phi i32 [ %.1.lcssa, %.lr.ph.1 ], [ %11, %9 ]
  %10 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %8) #4
  %11 = sub nsw i32 %.110.1, %7
  %.not.1 = icmp slt i32 %11, %7
  br i1 %.not.1, label %._crit_edge.1, label %9, !llvm.loop !11

._crit_edge.1:                                    ; preds = %9, %._crit_edge
  %.1.lcssa.1 = phi i32 [ %.1.lcssa, %._crit_edge ], [ %11, %9 ]
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @nums, i64 8), align 8, !tbaa !5
  %.not9.2 = icmp slt i32 %.1.lcssa.1, %12
  br i1 %.not9.2, label %._crit_edge.2, label %.lr.ph.2

.lr.ph.2:                                         ; preds = %._crit_edge.1
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @romans, i64 16), align 16, !tbaa !9
  br label %14

14:                                               ; preds = %14, %.lr.ph.2
  %.110.2 = phi i32 [ %.1.lcssa.1, %.lr.ph.2 ], [ %16, %14 ]
  %15 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %13) #4
  %16 = sub nsw i32 %.110.2, %12
  %.not.2 = icmp slt i32 %16, %12
  br i1 %.not.2, label %._crit_edge.2, label %14, !llvm.loop !11

._crit_edge.2:                                    ; preds = %14, %._crit_edge.1
  %.1.lcssa.2 = phi i32 [ %.1.lcssa.1, %._crit_edge.1 ], [ %16, %14 ]
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @nums, i64 12), align 4, !tbaa !5
  %.not9.3 = icmp slt i32 %.1.lcssa.2, %17
  br i1 %.not9.3, label %._crit_edge.3, label %.lr.ph.3

.lr.ph.3:                                         ; preds = %._crit_edge.2
  %18 = load ptr, ptr getelementptr inbounds (i8, ptr @romans, i64 24), align 8, !tbaa !9
  br label %19

19:                                               ; preds = %19, %.lr.ph.3
  %.110.3 = phi i32 [ %.1.lcssa.2, %.lr.ph.3 ], [ %21, %19 ]
  %20 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %18) #4
  %21 = sub nsw i32 %.110.3, %17
  %.not.3 = icmp slt i32 %21, %17
  br i1 %.not.3, label %._crit_edge.3, label %19, !llvm.loop !11

._crit_edge.3:                                    ; preds = %19, %._crit_edge.2
  %.1.lcssa.3 = phi i32 [ %.1.lcssa.2, %._crit_edge.2 ], [ %21, %19 ]
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @nums, i64 16), align 16, !tbaa !5
  %.not9.4 = icmp slt i32 %.1.lcssa.3, %22
  br i1 %.not9.4, label %._crit_edge.4, label %.lr.ph.4

.lr.ph.4:                                         ; preds = %._crit_edge.3
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @romans, i64 32), align 16, !tbaa !9
  br label %24

24:                                               ; preds = %24, %.lr.ph.4
  %.110.4 = phi i32 [ %.1.lcssa.3, %.lr.ph.4 ], [ %26, %24 ]
  %25 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %23) #4
  %26 = sub nsw i32 %.110.4, %22
  %.not.4 = icmp slt i32 %26, %22
  br i1 %.not.4, label %._crit_edge.4, label %24, !llvm.loop !11

._crit_edge.4:                                    ; preds = %24, %._crit_edge.3
  %.1.lcssa.4 = phi i32 [ %.1.lcssa.3, %._crit_edge.3 ], [ %26, %24 ]
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @nums, i64 20), align 4, !tbaa !5
  %.not9.5 = icmp slt i32 %.1.lcssa.4, %27
  br i1 %.not9.5, label %._crit_edge.5, label %.lr.ph.5

.lr.ph.5:                                         ; preds = %._crit_edge.4
  %28 = load ptr, ptr getelementptr inbounds (i8, ptr @romans, i64 40), align 8, !tbaa !9
  br label %29

29:                                               ; preds = %29, %.lr.ph.5
  %.110.5 = phi i32 [ %.1.lcssa.4, %.lr.ph.5 ], [ %31, %29 ]
  %30 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %28) #4
  %31 = sub nsw i32 %.110.5, %27
  %.not.5 = icmp slt i32 %31, %27
  br i1 %.not.5, label %._crit_edge.5, label %29, !llvm.loop !11

._crit_edge.5:                                    ; preds = %29, %._crit_edge.4
  %.1.lcssa.5 = phi i32 [ %.1.lcssa.4, %._crit_edge.4 ], [ %31, %29 ]
  %32 = load i32, ptr getelementptr inbounds (i8, ptr @nums, i64 24), align 8, !tbaa !5
  %.not9.6 = icmp slt i32 %.1.lcssa.5, %32
  br i1 %.not9.6, label %._crit_edge.6, label %.lr.ph.6

.lr.ph.6:                                         ; preds = %._crit_edge.5
  %33 = load ptr, ptr getelementptr inbounds (i8, ptr @romans, i64 48), align 16, !tbaa !9
  br label %34

34:                                               ; preds = %34, %.lr.ph.6
  %.110.6 = phi i32 [ %.1.lcssa.5, %.lr.ph.6 ], [ %36, %34 ]
  %35 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %33) #4
  %36 = sub nsw i32 %.110.6, %32
  %.not.6 = icmp slt i32 %36, %32
  br i1 %.not.6, label %._crit_edge.6, label %34, !llvm.loop !11

._crit_edge.6:                                    ; preds = %34, %._crit_edge.5
  %.1.lcssa.6 = phi i32 [ %.1.lcssa.5, %._crit_edge.5 ], [ %36, %34 ]
  %37 = load i32, ptr getelementptr inbounds (i8, ptr @nums, i64 28), align 4, !tbaa !5
  %.not9.7 = icmp slt i32 %.1.lcssa.6, %37
  br i1 %.not9.7, label %._crit_edge.7, label %.lr.ph.7

.lr.ph.7:                                         ; preds = %._crit_edge.6
  %38 = load ptr, ptr getelementptr inbounds (i8, ptr @romans, i64 56), align 8, !tbaa !9
  br label %39

39:                                               ; preds = %39, %.lr.ph.7
  %.110.7 = phi i32 [ %.1.lcssa.6, %.lr.ph.7 ], [ %41, %39 ]
  %40 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %38) #4
  %41 = sub nsw i32 %.110.7, %37
  %.not.7 = icmp slt i32 %41, %37
  br i1 %.not.7, label %._crit_edge.7, label %39, !llvm.loop !11

._crit_edge.7:                                    ; preds = %39, %._crit_edge.6
  %.1.lcssa.7 = phi i32 [ %.1.lcssa.6, %._crit_edge.6 ], [ %41, %39 ]
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @nums, i64 32), align 16, !tbaa !5
  %.not9.8 = icmp slt i32 %.1.lcssa.7, %42
  br i1 %.not9.8, label %._crit_edge.8, label %.lr.ph.8

.lr.ph.8:                                         ; preds = %._crit_edge.7
  %43 = load ptr, ptr getelementptr inbounds (i8, ptr @romans, i64 64), align 16, !tbaa !9
  br label %44

44:                                               ; preds = %44, %.lr.ph.8
  %.110.8 = phi i32 [ %.1.lcssa.7, %.lr.ph.8 ], [ %46, %44 ]
  %45 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %43) #4
  %46 = sub nsw i32 %.110.8, %42
  %.not.8 = icmp slt i32 %46, %42
  br i1 %.not.8, label %._crit_edge.8, label %44, !llvm.loop !11

._crit_edge.8:                                    ; preds = %44, %._crit_edge.7
  %.1.lcssa.8 = phi i32 [ %.1.lcssa.7, %._crit_edge.7 ], [ %46, %44 ]
  %47 = load i32, ptr getelementptr inbounds (i8, ptr @nums, i64 36), align 4, !tbaa !5
  %.not9.9 = icmp slt i32 %.1.lcssa.8, %47
  br i1 %.not9.9, label %._crit_edge.9, label %.lr.ph.9

.lr.ph.9:                                         ; preds = %._crit_edge.8
  %48 = load ptr, ptr getelementptr inbounds (i8, ptr @romans, i64 72), align 8, !tbaa !9
  br label %49

49:                                               ; preds = %49, %.lr.ph.9
  %.110.9 = phi i32 [ %.1.lcssa.8, %.lr.ph.9 ], [ %51, %49 ]
  %50 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %48) #4
  %51 = sub nsw i32 %.110.9, %47
  %.not.9 = icmp slt i32 %51, %47
  br i1 %.not.9, label %._crit_edge.9, label %49, !llvm.loop !11

._crit_edge.9:                                    ; preds = %49, %._crit_edge.8
  %.1.lcssa.9 = phi i32 [ %.1.lcssa.8, %._crit_edge.8 ], [ %51, %49 ]
  %52 = load i32, ptr getelementptr inbounds (i8, ptr @nums, i64 40), align 8, !tbaa !5
  %.not9.10 = icmp slt i32 %.1.lcssa.9, %52
  br i1 %.not9.10, label %._crit_edge.10, label %.lr.ph.10

.lr.ph.10:                                        ; preds = %._crit_edge.9
  %53 = load ptr, ptr getelementptr inbounds (i8, ptr @romans, i64 80), align 16, !tbaa !9
  br label %54

54:                                               ; preds = %54, %.lr.ph.10
  %.110.10 = phi i32 [ %.1.lcssa.9, %.lr.ph.10 ], [ %56, %54 ]
  %55 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %53) #4
  %56 = sub nsw i32 %.110.10, %52
  %.not.10 = icmp slt i32 %56, %52
  br i1 %.not.10, label %._crit_edge.10, label %54, !llvm.loop !11

._crit_edge.10:                                   ; preds = %54, %._crit_edge.9
  %.1.lcssa.10 = phi i32 [ %.1.lcssa.9, %._crit_edge.9 ], [ %56, %54 ]
  %57 = load i32, ptr getelementptr inbounds (i8, ptr @nums, i64 44), align 4, !tbaa !5
  %.not9.11 = icmp slt i32 %.1.lcssa.10, %57
  br i1 %.not9.11, label %._crit_edge.11, label %.lr.ph.11

.lr.ph.11:                                        ; preds = %._crit_edge.10
  %58 = load ptr, ptr getelementptr inbounds (i8, ptr @romans, i64 88), align 8, !tbaa !9
  br label %59

59:                                               ; preds = %59, %.lr.ph.11
  %.110.11 = phi i32 [ %.1.lcssa.10, %.lr.ph.11 ], [ %61, %59 ]
  %60 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %58) #4
  %61 = sub nsw i32 %.110.11, %57
  %.not.11 = icmp slt i32 %61, %57
  br i1 %.not.11, label %._crit_edge.11, label %59, !llvm.loop !11

._crit_edge.11:                                   ; preds = %59, %._crit_edge.10
  %.1.lcssa.11 = phi i32 [ %.1.lcssa.10, %._crit_edge.10 ], [ %61, %59 ]
  %62 = load i32, ptr getelementptr inbounds (i8, ptr @nums, i64 48), align 16, !tbaa !5
  %.not9.12 = icmp slt i32 %.1.lcssa.11, %62
  br i1 %.not9.12, label %._crit_edge.12, label %.lr.ph.12

.lr.ph.12:                                        ; preds = %._crit_edge.11
  %63 = load ptr, ptr getelementptr inbounds (i8, ptr @romans, i64 96), align 16, !tbaa !9
  br label %64

64:                                               ; preds = %64, %.lr.ph.12
  %.110.12 = phi i32 [ %.1.lcssa.11, %.lr.ph.12 ], [ %66, %64 ]
  %65 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %63) #4
  %66 = sub nsw i32 %.110.12, %62
  %.not.12 = icmp slt i32 %66, %62
  br i1 %.not.12, label %._crit_edge.12, label %64, !llvm.loop !11

._crit_edge.12:                                   ; preds = %64, %._crit_edge.11
  ret ptr %1
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcat(ptr noalias noundef returned, ptr noalias nocapture noundef readonly) local_unnamed_addr #2

attributes #0 = { nofree 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 #1 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nofree nounwind willreturn memory(argmem: readwrite) "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 allocsize(0,1) }
attributes #4 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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