; LLVM IR from tezc/sc :: map (map_test)

; 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.sc_map_ints = type { ptr, i32, i32, i32, i32, i8, i8, i8 }
%struct.sc_map_item_ints = type { i32, ptr }

@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [18 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 @printf(ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @example_int_to_str() #2 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca %struct.sc_map_ints, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %3) #3
  %6 = call zeroext i1 @sc_map_init_ints(ptr noundef %3, i32 noundef 0, i32 noundef 0)
  %7 = call ptr @sc_map_put_ints(ptr noundef %3, i32 noundef 100, ptr noundef @.str.1)
  %8 = call ptr @sc_map_put_ints(ptr noundef %3, i32 noundef 200, ptr noundef @.str.3)
  %9 = call ptr @sc_map_put_ints(ptr noundef %3, i32 noundef 300, ptr noundef @.str.5)
  %10 = call ptr @sc_map_get_ints(ptr noundef %3, i32 noundef 200)
  store ptr %10, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.sc_map_ints, ptr %3, i32 0, i32 7
  %12 = load i8, ptr %11, align 2, !tbaa !9, !range !13, !noundef !14
  %13 = trunc i8 %12 to i1
  br i1 %13, label %14, label %17

14:                                               ; preds = %0
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, ptr noundef %15)
  br label %17

17:                                               ; preds = %14, %0
  %18 = call ptr @sc_map_del_ints(ptr noundef %3, i32 noundef 100)
  store ptr %18, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.sc_map_ints, ptr %3, i32 0, i32 7
  %20 = load i8, ptr %19, align 2, !tbaa !9, !range !13, !noundef !14
  %21 = trunc i8 %20 to i1
  br i1 %21, label %22, label %25

22:                                               ; preds = %17
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, ptr noundef %23)
  br label %25

25:                                               ; preds = %22, %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 -1, ptr %4, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !15
  br label %26

26:                                               ; preds = %75, %25
  %27 = load i64, ptr %5, align 8, !tbaa !15
  %28 = icmp ne i64 %27, 0
  br i1 %28, label %35, label %29

29:                                               ; preds = %26
  %30 = load i64, ptr %4, align 8, !tbaa !15
  %31 = getelementptr inbounds %struct.sc_map_ints, ptr %3, i32 0, i32 1
  %32 = load i32, ptr %31, align 8, !tbaa !17
  %33 = zext i32 %32 to i64
  %34 = icmp slt i64 %30, %33
  br label %35

35:                                               ; preds = %29, %26
  %36 = phi i1 [ false, %26 ], [ %34, %29 ]
  br i1 %36, label %38, label %37

37:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %78

38:                                               ; preds = %35
  %39 = getelementptr inbounds %struct.sc_map_ints, ptr %3, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !18
  %41 = load i64, ptr %4, align 8, !tbaa !15
  %42 = getelementptr inbounds %struct.sc_map_item_ints, ptr %40, i64 %41
  %43 = getelementptr inbounds %struct.sc_map_item_ints, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !19
  store ptr %44, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.sc_map_ints, ptr %3, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !18
  %47 = load i64, ptr %4, align 8, !tbaa !15
  %48 = getelementptr inbounds %struct.sc_map_item_ints, ptr %46, i64 %47
  %49 = getelementptr inbounds %struct.sc_map_item_ints, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !21
  store i32 %50, ptr %1, align 4, !tbaa !22
  store i64 1, ptr %5, align 8, !tbaa !15
  br label %51

51:                                               ; preds = %73, %38
  %52 = load i64, ptr %5, align 8, !tbaa !15
  %53 = icmp ne i64 %52, 0
  br i1 %53, label %54, label %65

54:                                               ; preds = %51
  %55 = load i64, ptr %4, align 8, !tbaa !15
  %56 = icmp eq i64 %55, -1
  br i1 %56, label %57, label %61

57:                                               ; preds = %54
  %58 = getelementptr inbounds %struct.sc_map_ints, ptr %3, i32 0, i32 5
  %59 = load i8, ptr %58, align 8, !tbaa !23, !range !13, !noundef !14
  %60 = trunc i8 %59 to i1
  br i1 %60, label %64, label %61

61:                                               ; preds = %57, %54
  %62 = load i32, ptr %1, align 4, !tbaa !22
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %61, %57
  br label %66

65:                                               ; preds = %61, %51
  store i64 0, ptr %5, align 8, !tbaa !15
  br label %66

66:                                               ; preds = %65, %64
  %67 = phi i64 [ 1, %64 ], [ 0, %65 ]
  %68 = icmp ne i64 %67, 0
  br i1 %68, label %69, label %74

69:                                               ; preds = %66
  %70 = load i32, ptr %1, align 4, !tbaa !22
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i32 noundef %70, ptr noundef %71)
  br label %73

73:                                               ; preds = %69
  store i64 0, ptr %5, align 8, !tbaa !15
  br label %51, !llvm.loop !24

74:                                               ; preds = %66
  br label %75

75:                                               ; preds = %74
  %76 = load i64, ptr %4, align 8, !tbaa !15
  %77 = add nsw i64 %76, 1
  store i64 %77, ptr %4, align 8, !tbaa !15
  br label %26, !llvm.loop !26

78:                                               ; preds = %37
  %79 = call ptr @sc_map_del_ints(ptr noundef %3, i32 noundef 200)
  store ptr %79, ptr %2, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.sc_map_ints, ptr %3, i32 0, i32 7
  %81 = load i8, ptr %80, align 2, !tbaa !9, !range !13, !noundef !14
  %82 = trunc i8 %81 to i1
  br i1 %82, label %83, label %86

83:                                               ; preds = %78
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.10, ptr noundef %84)
  br label %86

86:                                               ; preds = %83, %78
  %87 = call ptr @sc_map_put_ints(ptr noundef %3, i32 noundef 300, ptr noundef @.str.11)
  store ptr %87, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.sc_map_ints, ptr %3, i32 0, i32 7
  %89 = load i8, ptr %88, align 2, !tbaa !9, !range !13, !noundef !14
  %90 = trunc i8 %89 to i1
  br i1 %90, label %91, label %94

91:                                               ; preds = %86
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, ptr noundef %92)
  br label %94

94:                                               ; preds = %91, %86
  call void @sc_map_term_ints(ptr noundef %3)
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

declare zeroext i1 @sc_map_init_ints(ptr noundef, i32 noundef, i32 noundef) #1

declare ptr @sc_map_put_ints(ptr noundef, i32 noundef, ptr noundef) #1

declare ptr @sc_map_get_ints(ptr noundef, i32 noundef) #1

declare ptr @sc_map_del_ints(ptr noundef, i32 noundef) #1

declare void @sc_map_term_ints(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #2 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !12, i64 26}
!10 = !{!"sc_map_ints", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !12, i64 24, !12, i64 25, !12, i64 26}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !6, i64 0}
!19 = !{!20, !6, i64 8}
!20 = !{!"sc_map_item_ints", !11, i64 0, !6, i64 8}
!21 = !{!20, !11, i64 0}
!22 = !{!11, !11, i64 0}
!23 = !{!10, !12, i64 24}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}


; 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.sc_map_ints = type { ptr, i32, i32, i32, i32, i8, i8, i8 }
%struct.sc_map_item_ints = type { i32, ptr }

@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [18 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @example_int_to_str() local_unnamed_addr #2 {
  %1 = alloca %struct.sc_map_ints, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #4
  %2 = call zeroext i1 @sc_map_init_ints(ptr noundef nonnull %1, i32 noundef 0, i32 noundef 0) #4
  %3 = call ptr @sc_map_put_ints(ptr noundef nonnull %1, i32 noundef 100, ptr noundef nonnull @.str.1) #4
  %4 = call ptr @sc_map_put_ints(ptr noundef nonnull %1, i32 noundef 200, ptr noundef nonnull @.str.3) #4
  %5 = call ptr @sc_map_put_ints(ptr noundef nonnull %1, i32 noundef 300, ptr noundef nonnull @.str.5) #4
  %6 = call ptr @sc_map_get_ints(ptr noundef nonnull %1, i32 noundef 200) #4
  %7 = getelementptr inbounds i8, ptr %1, i64 26
  %8 = load i8, ptr %7, align 2, !tbaa !5, !range !12, !noundef !13
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %10, label %12

10:                                               ; preds = %0
  %11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef %6)
  br label %12

12:                                               ; preds = %10, %0
  %13 = call ptr @sc_map_del_ints(ptr noundef nonnull %1, i32 noundef 100) #4
  %14 = load i8, ptr %7, align 2, !tbaa !5, !range !12, !noundef !13
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %16, label %18

16:                                               ; preds = %12
  %17 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, ptr noundef %13)
  br label %18

18:                                               ; preds = %12, %16
  %19 = getelementptr inbounds i8, ptr %1, i64 8
  %20 = load ptr, ptr %1, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %20, i64 -16
  %22 = load i32, ptr %21, align 8, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %1, i64 24
  %24 = load i8, ptr %23, align 8, !tbaa !17, !range !12, !noundef !13
  %25 = trunc nuw i8 %24 to i1
  %26 = icmp ne i32 %22, 0
  %or.cond.peel = select i1 %25, i1 true, i1 %26
  br i1 %or.cond.peel, label %.critedge, label %30

.critedge:                                        ; preds = %18
  %27 = getelementptr inbounds i8, ptr %20, i64 -8
  %28 = load ptr, ptr %27, align 8, !tbaa !18
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %22, ptr noundef %28)
  br label %30

30:                                               ; preds = %18, %.critedge
  %31 = load i32, ptr %19, align 8
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %.loopexit, label %.critedge.peel.next

.loopexit:                                        ; preds = %42, %30
  %32 = call ptr @sc_map_del_ints(ptr noundef nonnull %1, i32 noundef 200) #4
  %33 = load i8, ptr %7, align 2, !tbaa !5, !range !12, !noundef !13
  %34 = trunc nuw i8 %33 to i1
  br i1 %34, label %47, label %49

.critedge.peel.next:                              ; preds = %30, %42
  %.01518 = phi i64 [ %43, %42 ], [ 0, %30 ]
  %35 = load ptr, ptr %1, align 8, !tbaa !14
  %36 = getelementptr inbounds %struct.sc_map_item_ints, ptr %35, i64 %.01518
  %37 = load i32, ptr %36, align 8, !tbaa !15
  %.old1.not = icmp eq i32 %37, 0
  br i1 %.old1.not, label %42, label %38

38:                                               ; preds = %.critedge.peel.next
  %39 = getelementptr inbounds i8, ptr %36, i64 8
  %40 = load ptr, ptr %39, align 8, !tbaa !18
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %37, ptr noundef %40)
  br label %42

42:                                               ; preds = %.critedge.peel.next, %38
  %43 = add nuw nsw i64 %.01518, 1
  %44 = load i32, ptr %19, align 8
  %45 = zext i32 %44 to i64
  %46 = icmp ult i64 %43, %45
  br i1 %46, label %.critedge.peel.next, label %.loopexit, !llvm.loop !19

47:                                               ; preds = %.loopexit
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10, ptr noundef %32)
  br label %49

49:                                               ; preds = %47, %.loopexit
  %50 = call ptr @sc_map_put_ints(ptr noundef nonnull %1, i32 noundef 300, ptr noundef nonnull @.str.11) #4
  %51 = load i8, ptr %7, align 2, !tbaa !5, !range !12, !noundef !13
  %52 = trunc nuw i8 %51 to i1
  br i1 %52, label %53, label %55

53:                                               ; preds = %49
  %54 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %50)
  br label %55

55:                                               ; preds = %53, %49
  call void @sc_map_term_ints(ptr noundef nonnull %1) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #4
  ret void
}

declare zeroext i1 @sc_map_init_ints(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

declare ptr @sc_map_put_ints(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

declare ptr @sc_map_get_ints(ptr noundef, i32 noundef) local_unnamed_addr #3

declare ptr @sc_map_del_ints(ptr noundef, i32 noundef) local_unnamed_addr #3

declare void @sc_map_term_ints(ptr noundef) local_unnamed_addr #3

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

!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, !11, i64 26}
!6 = !{!"sc_map_ints", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !11, i64 24, !11, i64 25, !11, i64 26}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!6, !7, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"sc_map_item_ints", !10, i64 0, !7, i64 8}
!17 = !{!6, !11, i64 24}
!18 = !{!16, !7, i64 8}
!19 = distinct !{!19, !20, !21}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass