; LLVM IR from humz2k/sugaryc :: ext/bdwgc (obj_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._GC_arrays = type { i64, i64, i64, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i64, i64, i64, ptr, ptr, i64, i32, i64, i64, i64, %struct.dl_hashtbl_s, %struct.dl_hashtbl_s, %struct.fnlz_roots_s, i32, ptr, i64, i64, i32, i64, i64, i64, ptr, [64 x ptr], [8 x i8], [64 x ptr], [129 x ptr], [129 x ptr], [129 x ptr], [2049 x i64], [129 x ptr], [4096 x i8], [4096 x i64], [4096 x i64], ptr, [2048 x %struct.roots], [512 x %struct.exclusion], [2048 x ptr] }
%struct.dl_hashtbl_s = type { ptr, i64, i32 }
%struct.fnlz_roots_s = type { ptr, ptr }
%struct.roots = type { ptr, ptr, ptr, i32 }
%struct.exclusion = type { ptr, ptr }

@GC_arrays = external global %struct._GC_arrays, align 8
@GC_print_stats = external global i32, align 4
@.str.1 = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @GC_add_map_entry(i64 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store i64 %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %7 = load i64, ptr %3, align 8, !tbaa !5
  %8 = icmp ugt i64 %7, 128
  br i1 %8, label %9, label %10

9:                                                ; preds = %1
  store i64 0, ptr %3, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %9, %1
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds [129 x ptr], ptr getelementptr inbounds (%struct._GC_arrays, ptr @GC_arrays, i32 0, i32 54), i64 0, i64 %11
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %10
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %80

16:                                               ; preds = %10
  %17 = call ptr @GC_scratch_alloc(i64 noundef 512)
  store ptr %17, ptr %5, align 8, !tbaa !9
  %18 = load ptr, ptr %5, align 8, !tbaa !9
  %19 = icmp eq ptr null, %18
  %20 = zext i1 %19 to i32
  %21 = sext i32 %20 to i64
  %22 = call i64 @llvm.expect.i64(i64 %21, i64 0)
  %23 = icmp ne i64 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %16
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %80

25:                                               ; preds = %16
  %26 = load i32, ptr @GC_print_stats, align 4, !tbaa !11
  %27 = icmp ne i32 %26, 0
  %28 = xor i1 %27, true
  %29 = zext i1 %28 to i32
  %30 = sext i32 %29 to i64
  %31 = call i64 @llvm.expect.i64(i64 %30, i64 1)
  %32 = icmp ne i64 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %25
  br label %40

34:                                               ; preds = %25
  %35 = load i64, ptr %3, align 8, !tbaa !5
  %36 = trunc i64 %35 to i32
  %37 = load i64, ptr %3, align 8, !tbaa !5
  %38 = shl i64 %37, 4
  %39 = trunc i64 %38 to i32
  call void (ptr, ...) @GC_log_printf(ptr noundef @.str.1, i32 noundef %36, i32 noundef %39)
  br label %40

40:                                               ; preds = %34, %33
  %41 = load i64, ptr %3, align 8, !tbaa !5
  %42 = icmp eq i64 %41, 0
  br i1 %42, label %43, label %57

43:                                               ; preds = %40
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %44

44:                                               ; preds = %53, %43
  %45 = load i32, ptr %4, align 4, !tbaa !11
  %46 = zext i32 %45 to i64
  %47 = icmp ult i64 %46, 256
  br i1 %47, label %48, label %56

48:                                               ; preds = %44
  %49 = load ptr, ptr %5, align 8, !tbaa !9
  %50 = load i32, ptr %4, align 4, !tbaa !11
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds i16, ptr %49, i64 %51
  store i16 1, ptr %52, align 2, !tbaa !13
  br label %53

53:                                               ; preds = %48
  %54 = load i32, ptr %4, align 4, !tbaa !11
  %55 = add i32 %54, 1
  store i32 %55, ptr %4, align 4, !tbaa !11
  br label %44, !llvm.loop !15

56:                                               ; preds = %44
  br label %76

57:                                               ; preds = %40
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %58

58:                                               ; preds = %72, %57
  %59 = load i32, ptr %4, align 4, !tbaa !11
  %60 = zext i32 %59 to i64
  %61 = icmp ult i64 %60, 256
  br i1 %61, label %62, label %75

62:                                               ; preds = %58
  %63 = load i32, ptr %4, align 4, !tbaa !11
  %64 = zext i32 %63 to i64
  %65 = load i64, ptr %3, align 8, !tbaa !5
  %66 = urem i64 %64, %65
  %67 = trunc i64 %66 to i16
  %68 = load ptr, ptr %5, align 8, !tbaa !9
  %69 = load i32, ptr %4, align 4, !tbaa !11
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds i16, ptr %68, i64 %70
  store i16 %67, ptr %71, align 2, !tbaa !13
  br label %72

72:                                               ; preds = %62
  %73 = load i32, ptr %4, align 4, !tbaa !11
  %74 = add i32 %73, 1
  store i32 %74, ptr %4, align 4, !tbaa !11
  br label %58, !llvm.loop !17

75:                                               ; preds = %58
  br label %76

76:                                               ; preds = %75, %56
  %77 = load ptr, ptr %5, align 8, !tbaa !9
  %78 = load i64, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds [129 x ptr], ptr getelementptr inbounds (%struct._GC_arrays, ptr @GC_arrays, i32 0, i32 54), i64 0, i64 %78
  store ptr %77, ptr %79, align 8, !tbaa !9
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %80

80:                                               ; preds = %76, %24, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %81 = load i32, ptr %2, align 4
  ret i32 %81
}

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

declare ptr @GC_scratch_alloc(i64 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #3

declare void @GC_log_printf(ptr noundef, ...) #2

; 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = !{!"long", !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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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._GC_arrays = type { i64, i64, i64, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i64, i64, i64, ptr, ptr, i64, i32, i64, i64, i64, %struct.dl_hashtbl_s, %struct.dl_hashtbl_s, %struct.fnlz_roots_s, i32, ptr, i64, i64, i32, i64, i64, i64, ptr, [64 x ptr], [8 x i8], [64 x ptr], [129 x ptr], [129 x ptr], [129 x ptr], [2049 x i64], [129 x ptr], [4096 x i8], [4096 x i64], [4096 x i64], ptr, [2048 x %struct.roots], [512 x %struct.exclusion], [2048 x ptr] }
%struct.dl_hashtbl_s = type { ptr, i64, i32 }
%struct.fnlz_roots_s = type { ptr, ptr }
%struct.roots = type { ptr, ptr, ptr, i32 }
%struct.exclusion = type { ptr, ptr }

@GC_arrays = external local_unnamed_addr global %struct._GC_arrays, align 8
@GC_print_stats = external local_unnamed_addr global i32, align 4
@.str.1 = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @GC_add_map_entry(i64 noundef %0) local_unnamed_addr #0 {
  %2 = icmp ugt i64 %0, 128
  %spec.store.select = select i1 %2, i64 0, i64 %0
  %3 = getelementptr inbounds [129 x ptr], ptr getelementptr inbounds (i8, ptr @GC_arrays, i64 20928), i64 0, i64 %spec.store.select
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %52

5:                                                ; preds = %1
  %6 = tail call ptr @GC_scratch_alloc(i64 noundef 512) #2
  %7 = icmp eq ptr %6, null
  br i1 %7, label %52, label %8, !prof !9

8:                                                ; preds = %5
  %9 = load i32, ptr @GC_print_stats, align 4, !tbaa !10
  %.not22 = icmp eq i32 %9, 0
  br i1 %.not22, label %13, label %10, !prof !12

10:                                               ; preds = %8
  %11 = trunc nuw i64 %spec.store.select to i32
  %12 = shl nuw nsw i32 %11, 4
  tail call void (ptr, ...) @GC_log_printf(ptr noundef nonnull @.str.1, i32 noundef %11, i32 noundef %12) #2
  br label %13

13:                                               ; preds = %8, %10
  %14 = icmp eq i64 %spec.store.select, 0
  br i1 %14, label %vector.body, label %.preheader23

vector.body:                                      ; preds = %13
  %15 = getelementptr inbounds i8, ptr %6, i64 16
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %6, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %15, align 2, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %6, i64 32
  %17 = getelementptr inbounds i8, ptr %6, i64 48
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %16, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %17, align 2, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %6, i64 64
  %19 = getelementptr inbounds i8, ptr %6, i64 80
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %18, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %19, align 2, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %6, i64 96
  %21 = getelementptr inbounds i8, ptr %6, i64 112
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %20, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %21, align 2, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %6, i64 128
  %23 = getelementptr inbounds i8, ptr %6, i64 144
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %22, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %23, align 2, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %6, i64 160
  %25 = getelementptr inbounds i8, ptr %6, i64 176
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %24, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %25, align 2, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %6, i64 192
  %27 = getelementptr inbounds i8, ptr %6, i64 208
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %26, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %27, align 2, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %6, i64 224
  %29 = getelementptr inbounds i8, ptr %6, i64 240
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %28, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %29, align 2, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %6, i64 256
  %31 = getelementptr inbounds i8, ptr %6, i64 272
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %30, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %31, align 2, !tbaa !13
  %32 = getelementptr inbounds i8, ptr %6, i64 288
  %33 = getelementptr inbounds i8, ptr %6, i64 304
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %32, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %33, align 2, !tbaa !13
  %34 = getelementptr inbounds i8, ptr %6, i64 320
  %35 = getelementptr inbounds i8, ptr %6, i64 336
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %34, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %35, align 2, !tbaa !13
  %36 = getelementptr inbounds i8, ptr %6, i64 352
  %37 = getelementptr inbounds i8, ptr %6, i64 368
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %36, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %37, align 2, !tbaa !13
  %38 = getelementptr inbounds i8, ptr %6, i64 384
  %39 = getelementptr inbounds i8, ptr %6, i64 400
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %38, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %39, align 2, !tbaa !13
  %40 = getelementptr inbounds i8, ptr %6, i64 416
  %41 = getelementptr inbounds i8, ptr %6, i64 432
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %40, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %41, align 2, !tbaa !13
  %42 = getelementptr inbounds i8, ptr %6, i64 448
  %43 = getelementptr inbounds i8, ptr %6, i64 464
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %42, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %43, align 2, !tbaa !13
  %44 = getelementptr inbounds i8, ptr %6, i64 480
  %45 = getelementptr inbounds i8, ptr %6, i64 496
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %44, align 2, !tbaa !13
  store <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, ptr %45, align 2, !tbaa !13
  br label %.loopexit

.preheader23:                                     ; preds = %13, %.preheader23
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.preheader23 ], [ 0, %13 ]
  %46 = urem i64 %indvars.iv, %0
  %47 = trunc nuw nsw i64 %46 to i16
  %48 = getelementptr inbounds i16, ptr %6, i64 %indvars.iv
  store i16 %47, ptr %48, align 2, !tbaa !13
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %49 = urem i64 %indvars.iv.next, %0
  %50 = trunc nuw nsw i64 %49 to i16
  %51 = getelementptr inbounds i16, ptr %6, i64 %indvars.iv.next
  store i16 %50, ptr %51, align 2, !tbaa !13
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 256
  br i1 %exitcond.not.1, label %.loopexit, label %.preheader23, !llvm.loop !15

.loopexit:                                        ; preds = %.preheader23, %vector.body
  store ptr %6, ptr %3, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %5, %1, %.loopexit
  %.0 = phi i32 [ 1, %.loopexit ], [ 1, %1 ], [ 0, %5 ]
  ret i32 %.0
}

declare ptr @GC_scratch_alloc(i64 noundef) local_unnamed_addr #1

declare void @GC_log_printf(ptr noundef, ...) local_unnamed_addr #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 = { "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 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,LowerExpectIntrinsicPass,SROAPass,SimplifyCFGPass,TailCallElimPass