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

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

; 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: nounwind uwtable
declare dso_local zeroext i1 @sc_map_cmp_32(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @sc_map_assign_32(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @sc_map_hash_32(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @sc_map_put_32(ptr noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.sc_map_32, ptr %13, i32 0, i32 6
  store i8 0, ptr %14, align 1, !tbaa !11
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call zeroext i1 @sc_map_remap_32(ptr noundef %15)
  br i1 %16, label %20, label %17

17:                                               ; preds = %3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.sc_map_32, ptr %18, i32 0, i32 6
  store i8 1, ptr %19, align 1, !tbaa !11
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %145

20:                                               ; preds = %3
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %64

23:                                               ; preds = %20
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.sc_map_32, ptr %24, i32 0, i32 5
  %26 = load i8, ptr %25, align 8, !tbaa !14, !range !15, !noundef !16
  %27 = trunc i8 %26 to i1
  br i1 %27, label %28, label %35

28:                                               ; preds = %23
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.sc_map_32, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  %32 = getelementptr inbounds %struct.sc_map_item_32, ptr %31, i64 -1
  %33 = getelementptr inbounds %struct.sc_map_item_32, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !18
  br label %36

35:                                               ; preds = %23
  br label %36

36:                                               ; preds = %35, %28
  %37 = phi i32 [ %34, %28 ], [ 0, %35 ]
  store i32 %37, ptr %8, align 4, !tbaa !9
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.sc_map_32, ptr %38, i32 0, i32 5
  %40 = load i8, ptr %39, align 8, !tbaa !14, !range !15, !noundef !16
  %41 = trunc i8 %40 to i1
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.sc_map_32, ptr %42, i32 0, i32 7
  %44 = zext i1 %41 to i8
  store i8 %44, ptr %43, align 2, !tbaa !20
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.sc_map_32, ptr %45, i32 0, i32 5
  %47 = load i8, ptr %46, align 8, !tbaa !14, !range !15, !noundef !16
  %48 = trunc i8 %47 to i1
  %49 = xor i1 %48, true
  %50 = zext i1 %49 to i32
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.sc_map_32, ptr %51, i32 0, i32 2
  %53 = load i32, ptr %52, align 4, !tbaa !21
  %54 = add i32 %53, %50
  store i32 %54, ptr %52, align 4, !tbaa !21
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.sc_map_32, ptr %55, i32 0, i32 5
  store i8 1, ptr %56, align 8, !tbaa !14
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.sc_map_32, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !17
  %61 = getelementptr inbounds %struct.sc_map_item_32, ptr %60, i64 -1
  %62 = getelementptr inbounds %struct.sc_map_item_32, ptr %61, i32 0, i32 1
  store i32 %57, ptr %62, align 4, !tbaa !18
  %63 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %63, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %145

64:                                               ; preds = %20
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.sc_map_32, ptr %65, i32 0, i32 1
  %67 = load i32, ptr %66, align 8, !tbaa !22
  %68 = sub i32 %67, 1
  store i32 %68, ptr %10, align 4, !tbaa !9
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = call i32 @sc_map_hash_32(i32 noundef %69)
  store i32 %70, ptr %11, align 4, !tbaa !9
  %71 = load i32, ptr %11, align 4, !tbaa !9
  %72 = load i32, ptr %10, align 4, !tbaa !9
  %73 = and i32 %71, %72
  store i32 %73, ptr %9, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %100, %64
  br label %75

75:                                               ; preds = %74
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.sc_map_32, ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !17
  %79 = load i32, ptr %9, align 4, !tbaa !9
  %80 = zext i32 %79 to i64
  %81 = getelementptr inbounds %struct.sc_map_item_32, ptr %78, i64 %80
  %82 = getelementptr inbounds %struct.sc_map_item_32, ptr %81, i32 0, i32 0
  %83 = load i32, ptr %82, align 4, !tbaa !23
  %84 = icmp eq i32 %83, 0
  br i1 %84, label %85, label %90

85:                                               ; preds = %75
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.sc_map_32, ptr %86, i32 0, i32 2
  %88 = load i32, ptr %87, align 4, !tbaa !21
  %89 = add i32 %88, 1
  store i32 %89, ptr %87, align 4, !tbaa !21
  br label %106

90:                                               ; preds = %75
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.sc_map_32, ptr %91, i32 0, i32 0
  %93 = load ptr, ptr %92, align 8, !tbaa !17
  %94 = load i32, ptr %9, align 4, !tbaa !9
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds %struct.sc_map_item_32, ptr %93, i64 %95
  %97 = load i32, ptr %6, align 4, !tbaa !9
  %98 = load i32, ptr %11, align 4, !tbaa !9
  %99 = call zeroext i1 @sc_map_cmp_32(ptr noundef %96, i32 noundef %97, i32 noundef %98)
  br i1 %99, label %105, label %100

100:                                              ; preds = %90
  %101 = load i32, ptr %9, align 4, !tbaa !9
  %102 = add i32 %101, 1
  %103 = load i32, ptr %10, align 4, !tbaa !9
  %104 = and i32 %102, %103
  store i32 %104, ptr %9, align 4, !tbaa !9
  br label %74

105:                                              ; preds = %90
  br label %106

106:                                              ; preds = %105, %85
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.sc_map_32, ptr %107, i32 0, i32 0
  %109 = load ptr, ptr %108, align 8, !tbaa !17
  %110 = load i32, ptr %9, align 4, !tbaa !9
  %111 = zext i32 %110 to i64
  %112 = getelementptr inbounds %struct.sc_map_item_32, ptr %109, i64 %111
  %113 = getelementptr inbounds %struct.sc_map_item_32, ptr %112, i32 0, i32 0
  %114 = load i32, ptr %113, align 4, !tbaa !23
  %115 = icmp ne i32 %114, 0
  %116 = load ptr, ptr %5, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.sc_map_32, ptr %116, i32 0, i32 7
  %118 = zext i1 %115 to i8
  store i8 %118, ptr %117, align 2, !tbaa !20
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.sc_map_32, ptr %119, i32 0, i32 7
  %121 = load i8, ptr %120, align 2, !tbaa !20, !range !15, !noundef !16
  %122 = trunc i8 %121 to i1
  br i1 %122, label %123, label %132

123:                                              ; preds = %106
  %124 = load ptr, ptr %5, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.sc_map_32, ptr %124, i32 0, i32 0
  %126 = load ptr, ptr %125, align 8, !tbaa !17
  %127 = load i32, ptr %9, align 4, !tbaa !9
  %128 = zext i32 %127 to i64
  %129 = getelementptr inbounds %struct.sc_map_item_32, ptr %126, i64 %128
  %130 = getelementptr inbounds %struct.sc_map_item_32, ptr %129, i32 0, i32 1
  %131 = load i32, ptr %130, align 4, !tbaa !18
  br label %133

132:                                              ; preds = %106
  br label %133

133:                                              ; preds = %132, %123
  %134 = phi i32 [ %131, %123 ], [ 0, %132 ]
  store i32 %134, ptr %8, align 4, !tbaa !9
  %135 = load ptr, ptr %5, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.sc_map_32, ptr %135, i32 0, i32 0
  %137 = load ptr, ptr %136, align 8, !tbaa !17
  %138 = load i32, ptr %9, align 4, !tbaa !9
  %139 = zext i32 %138 to i64
  %140 = getelementptr inbounds %struct.sc_map_item_32, ptr %137, i64 %139
  %141 = load i32, ptr %6, align 4, !tbaa !9
  %142 = load i32, ptr %7, align 4, !tbaa !9
  %143 = load i32, ptr %11, align 4, !tbaa !9
  call void @sc_map_assign_32(ptr noundef %140, i32 noundef %141, i32 noundef %142, i32 noundef %143)
  %144 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %144, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %145

145:                                              ; preds = %133, %36, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %146 = load i32, ptr %4, align 4
  ret i32 %146
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @sc_map_remap_32(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 25}
!12 = !{!"sc_map_32", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !13, i64 24, !13, i64 25, !13, i64 26}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!12, !13, i64 24}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!12, !6, i64 0}
!18 = !{!19, !10, i64 4}
!19 = !{!"sc_map_item_32", !10, i64 0, !10, i64 4}
!20 = !{!12, !13, i64 26}
!21 = !{!12, !10, i64 12}
!22 = !{!12, !10, i64 8}
!23 = !{!19, !10, i64 0}


; 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_item_32 = type { i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @sc_map_cmp_32(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @sc_map_assign_32(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @sc_map_hash_32(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @sc_map_put_32(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 25
  store i8 0, ptr %4, align 1, !tbaa !5
  %5 = tail call zeroext i1 @sc_map_remap_32(ptr noundef %0)
  br i1 %5, label %7, label %6

6:                                                ; preds = %3
  store i8 1, ptr %4, align 1, !tbaa !5
  br label %59

7:                                                ; preds = %3
  %8 = icmp eq i32 %1, 0
  br i1 %8, label %9, label %25

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load i8, ptr %10, align 8, !tbaa !12, !range !13, !noundef !14
  %12 = trunc nuw i8 %11 to i1
  %.pre47 = load ptr, ptr %0, align 8, !tbaa !15
  br i1 %12, label %13, label %16

13:                                               ; preds = %9
  %14 = getelementptr inbounds i8, ptr %.pre47, i64 -4
  %15 = load i32, ptr %14, align 4, !tbaa !16
  br label %16

16:                                               ; preds = %9, %13
  %17 = phi i32 [ %15, %13 ], [ 0, %9 ]
  %18 = getelementptr inbounds i8, ptr %0, i64 26
  store i8 %11, ptr %18, align 2, !tbaa !18
  %19 = xor i8 %11, 1
  %20 = zext nneg i8 %19 to i32
  %21 = getelementptr inbounds i8, ptr %0, i64 12
  %22 = load i32, ptr %21, align 4, !tbaa !19
  %23 = add i32 %22, %20
  store i32 %23, ptr %21, align 4, !tbaa !19
  store i8 1, ptr %10, align 8, !tbaa !12
  %24 = getelementptr inbounds i8, ptr %.pre47, i64 -4
  store i32 %2, ptr %24, align 4, !tbaa !16
  br label %59

25:                                               ; preds = %7
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  %27 = load i32, ptr %26, align 8, !tbaa !20
  %28 = add i32 %27, -1
  %29 = tail call i32 @sc_map_hash_32(i32 noundef %1)
  %.03942 = and i32 %29, %28
  %30 = load ptr, ptr %0, align 8, !tbaa !15
  %31 = zext i32 %.03942 to i64
  %32 = getelementptr inbounds %struct.sc_map_item_32, ptr %30, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !21
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %25
  %35 = tail call zeroext i1 @sc_map_cmp_32(ptr noundef nonnull %32, i32 noundef %1, i32 noundef %29)
  br i1 %35, label %.loopexit.loopexit, label %.lr.ph57

.lr.ph57:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %.0394356 = phi i32 [ %.039, %.lr.ph ], [ %.03942, %.lr.ph.preheader ]
  %36 = add i32 %.0394356, 1
  %.039 = and i32 %36, %28
  %37 = load ptr, ptr %0, align 8, !tbaa !15
  %38 = zext i32 %.039 to i64
  %39 = getelementptr inbounds %struct.sc_map_item_32, ptr %37, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !21
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph57, %25
  %42 = phi ptr [ %30, %25 ], [ %37, %.lr.ph57 ]
  %.lcssa = phi i64 [ %31, %25 ], [ %38, %.lr.ph57 ]
  %43 = getelementptr inbounds i8, ptr %0, i64 12
  %44 = load i32, ptr %43, align 4, !tbaa !19
  %45 = add i32 %44, 1
  store i32 %45, ptr %43, align 4, !tbaa !19
  br label %.loopexit

.lr.ph:                                           ; preds = %.lr.ph57
  %46 = tail call zeroext i1 @sc_map_cmp_32(ptr noundef nonnull %39, i32 noundef %1, i32 noundef %29)
  br i1 %46, label %.loopexit.loopexit, label %.lr.ph57

.loopexit.loopexit:                               ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa52 = phi i64 [ %31, %.lr.ph.preheader ], [ %38, %.lr.ph ]
  %.pre = load ptr, ptr %0, align 8, !tbaa !15
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %._crit_edge
  %47 = phi ptr [ %42, %._crit_edge ], [ %.pre, %.loopexit.loopexit ]
  %48 = phi i64 [ %.lcssa, %._crit_edge ], [ %.lcssa52, %.loopexit.loopexit ]
  %49 = getelementptr inbounds %struct.sc_map_item_32, ptr %47, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !21
  %51 = icmp ne i32 %50, 0
  %52 = getelementptr inbounds i8, ptr %0, i64 26
  %53 = zext i1 %51 to i8
  store i8 %53, ptr %52, align 2, !tbaa !18
  br i1 %51, label %54, label %57

54:                                               ; preds = %.loopexit
  %55 = getelementptr inbounds %struct.sc_map_item_32, ptr %47, i64 %48, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !16
  br label %57

57:                                               ; preds = %.loopexit, %54
  %58 = phi i32 [ %56, %54 ], [ 0, %.loopexit ]
  tail call void @sc_map_assign_32(ptr noundef nonnull %49, i32 noundef %1, i32 noundef %2, i32 noundef %29)
  br label %59

59:                                               ; preds = %57, %16, %6
  %.0 = phi i32 [ %17, %16 ], [ %58, %57 ], [ 0, %6 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @sc_map_remap_32(ptr noundef) local_unnamed_addr #0

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

!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 25}
!6 = !{!"sc_map_32", !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 = !{!6, !11, i64 24}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !7, i64 0}
!16 = !{!17, !10, i64 4}
!17 = !{!"sc_map_item_32", !10, i64 0, !10, i64 4}
!18 = !{!6, !11, i64 26}
!19 = !{!6, !10, i64 12}
!20 = !{!6, !10, i64 8}
!21 = !{!17, !10, i64 0}


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