; LLVM IR from humz2k/sugaryc :: ext/bdwgc (dbg_mlc)

; 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.oh = type { ptr, i64, i64, i64 }

@GC_all_interior_pointers = external global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @GC_has_other_debug_info(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.oh, ptr %7, i64 1
  store ptr %8, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call i64 @GC_size(ptr noundef %9)
  store i64 %10, ptr %5, align 8, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = ptrtoint ptr %11 to i64
  %13 = and i64 %12, -4096
  %14 = inttoptr i64 %13 to ptr
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = ptrtoint ptr %15 to i64
  %17 = and i64 %16, -4096
  %18 = inttoptr i64 %17 to ptr
  %19 = icmp ne ptr %14, %18
  br i1 %19, label %29, label %20

20:                                               ; preds = %1
  %21 = load i64, ptr %5, align 8, !tbaa !9
  %22 = load i32, ptr @GC_all_interior_pointers, align 4, !tbaa !11
  %23 = sext i32 %22 to i64
  %24 = sub i64 40, %23
  %25 = load i32, ptr @GC_all_interior_pointers, align 4, !tbaa !11
  %26 = sext i32 %25 to i64
  %27 = add i64 %24, %26
  %28 = icmp ult i64 %21, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %20, %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %58

30:                                               ; preds = %20
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.oh, ptr %31, i32 0, i32 3
  %33 = load i64, ptr %32, align 8, !tbaa !13
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = ptrtoint ptr %34 to i64
  %36 = xor i64 -81929232789475893, %35
  %37 = icmp ne i64 %33, %36
  br i1 %37, label %38, label %50

38:                                               ; preds = %30
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load i64, ptr %5, align 8, !tbaa !9
  %41 = lshr i64 %40, 3
  %42 = sub i64 %41, 1
  %43 = getelementptr inbounds i64, ptr %39, i64 %42
  %44 = load i64, ptr %43, align 8, !tbaa !9
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = ptrtoint ptr %45 to i64
  %47 = xor i64 -4837202520199737873, %46
  %48 = icmp ne i64 %44, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %38
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %58

50:                                               ; preds = %38, %30
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.oh, ptr %51, i32 0, i32 2
  %53 = load i64, ptr %52, align 8, !tbaa !15
  %54 = load i64, ptr %5, align 8, !tbaa !9
  %55 = icmp eq i64 %53, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %50
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %58

57:                                               ; preds = %50
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %58

58:                                               ; preds = %57, %56, %49, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %59 = load i32, ptr %2, align 4
  ret i32 %59
}

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

declare i64 @GC_size(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 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 24}
!14 = !{!"", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!15 = !{!14, !10, i64 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"

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @GC_has_other_debug_info(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = tail call i64 @GC_size(ptr noundef %0) #2
  %4 = ptrtoint ptr %0 to i64
  %5 = and i64 %4, -4096
  %6 = inttoptr i64 %5 to ptr
  %7 = ptrtoint ptr %2 to i64
  %8 = and i64 %7, -4096
  %9 = inttoptr i64 %8 to ptr
  %.not = icmp ne ptr %6, %9
  %10 = icmp ult i64 %3, 40
  %or.cond = select i1 %.not, i1 true, i1 %10
  br i1 %or.cond, label %25, label %11

11:                                               ; preds = %1
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = xor i64 %13, %7
  %.not13 = icmp eq i64 %14, -81929232789475893
  br i1 %.not13, label %21, label %15

15:                                               ; preds = %11
  %16 = lshr i64 %3, 3
  %17 = getelementptr i64, ptr %0, i64 %16
  %18 = getelementptr i8, ptr %17, i64 -8
  %19 = load i64, ptr %18, align 8, !tbaa !11
  %20 = xor i64 %19, %7
  %.not14 = icmp eq i64 %20, -4837202520199737873
  br i1 %.not14, label %21, label %25

21:                                               ; preds = %15, %11
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  %23 = load i64, ptr %22, align 8, !tbaa !12
  %24 = icmp eq i64 %23, %3
  %. = select i1 %24, i32 -1, i32 1
  br label %25

25:                                               ; preds = %21, %15, %1
  %.0 = phi i32 [ 0, %1 ], [ 0, %15 ], [ %., %21 ]
  ret i32 %.0
}

declare i64 @GC_size(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, !10, i64 24}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!6, !10, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass