; LLVM IR from jdeokkim/ferox :: src (world)

; 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.stbds_array_header = type { i64, i64, ptr, i64 }
%struct.stbds_hash_index = type { ptr, i64, i64, i64, i64, i64, i64, i64, i64, %struct.stbds_string_arena, ptr }
%struct.stbds_string_arena = type { ptr, i64, i8, i8 }

; 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
declare void @free(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @stbds_hmfree_func(ptr noundef %0, i64 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  br label %57

9:                                                ; preds = %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.stbds_array_header, ptr %10, i64 -1
  %12 = getelementptr inbounds %struct.stbds_array_header, ptr %11, i32 0, i32 2
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %50

15:                                               ; preds = %9
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.stbds_array_header, ptr %16, i64 -1
  %18 = getelementptr inbounds %struct.stbds_array_header, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds %struct.stbds_hash_index, ptr %19, i32 0, i32 9
  %21 = getelementptr inbounds %struct.stbds_string_arena, ptr %20, i32 0, i32 3
  %22 = load i8, ptr %21, align 1, !tbaa !13
  %23 = zext i8 %22 to i32
  %24 = icmp eq i32 %23, 2
  br i1 %24, label %25, label %44

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

26:                                               ; preds = %40, %25
  %27 = load i64, ptr %5, align 8, !tbaa !9
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.stbds_array_header, ptr %28, i64 -1
  %30 = getelementptr inbounds %struct.stbds_array_header, ptr %29, i32 0, i32 0
  %31 = load i64, ptr %30, align 8, !tbaa !16
  %32 = icmp ult i64 %27, %31
  br i1 %32, label %33, label %43

33:                                               ; preds = %26
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = load i64, ptr %4, align 8, !tbaa !9
  %36 = load i64, ptr %5, align 8, !tbaa !9
  %37 = mul i64 %35, %36
  %38 = getelementptr inbounds i8, ptr %34, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  call void @free(ptr noundef %39) #3
  br label %40

40:                                               ; preds = %33
  %41 = load i64, ptr %5, align 8, !tbaa !9
  %42 = add i64 %41, 1
  store i64 %42, ptr %5, align 8, !tbaa !9
  br label %26, !llvm.loop !17

43:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %44

44:                                               ; preds = %43, %15
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.stbds_array_header, ptr %45, i64 -1
  %47 = getelementptr inbounds %struct.stbds_array_header, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  %49 = getelementptr inbounds %struct.stbds_hash_index, ptr %48, i32 0, i32 9
  call void @stbds_strreset(ptr noundef %49)
  br label %50

50:                                               ; preds = %44, %9
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.stbds_array_header, ptr %51, i64 -1
  %53 = getelementptr inbounds %struct.stbds_array_header, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  call void @free(ptr noundef %54) #3
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.stbds_array_header, ptr %55, i64 -1
  call void @free(ptr noundef %56) #3
  br label %57

57:                                               ; preds = %50, %8
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @stbds_strreset(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"", !10, i64 0, !10, i64 8, !6, i64 16, !10, i64 24}
!13 = !{!14, !7, i64 89}
!14 = !{!"", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !15, i64 72, !6, i64 96}
!15 = !{!"stbds_string_arena", !6, i64 0, !10, i64 8, !7, i64 16, !7, i64 17}
!16 = !{!12, !10, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @stbds_hmfree_func(ptr noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %24, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 -32
  %6 = getelementptr inbounds i8, ptr %0, i64 -16
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %22, label %8

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %7, i64 89
  %10 = load i8, ptr %9, align 1, !tbaa !11
  %11 = icmp eq i8 %10, 2
  br i1 %11, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %8
  %12 = load i64, ptr %5, align 8, !tbaa !14
  %13 = icmp ugt i64 %12, 1
  br i1 %13, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.013 = phi i64 [ %17, %.lr.ph ], [ 1, %.preheader ]
  %14 = mul i64 %.013, %1
  %15 = getelementptr inbounds i8, ptr %0, i64 %14
  %16 = load ptr, ptr %15, align 8, !tbaa !15
  tail call void @free(ptr noundef %16) #2
  %17 = add nuw i64 %.013, 1
  %18 = load i64, ptr %5, align 8, !tbaa !14
  %19 = icmp ult i64 %17, %18
  br i1 %19, label %.lr.ph, label %.loopexit.loopexit, !llvm.loop !16

.loopexit.loopexit:                               ; preds = %.lr.ph
  %.pre = load ptr, ptr %6, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.preheader, %8
  %20 = phi ptr [ %.pre, %.loopexit.loopexit ], [ %7, %.preheader ], [ %7, %8 ]
  %21 = getelementptr inbounds i8, ptr %20, i64 72
  tail call void @stbds_strreset(ptr noundef nonnull %21)
  %.pre14 = load ptr, ptr %6, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %.loopexit, %4
  %23 = phi ptr [ %.pre14, %.loopexit ], [ null, %4 ]
  tail call void @free(ptr noundef %23) #2
  tail call void @free(ptr noundef nonnull %5) #2
  br label %24

24:                                               ; preds = %2, %22
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @stbds_strreset(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #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, !10, i64 16}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !8, i64 89}
!12 = !{!"", !10, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !13, i64 72, !10, i64 96}
!13 = !{!"stbds_string_arena", !10, i64 0, !7, i64 8, !8, i64 16, !8, i64 17}
!14 = !{!6, !7, i64 0}
!15 = !{!10, !10, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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