; LLVM IR from avaxar/ccgc :: ccgc (ccgc_dumpPage)

; 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.Block = type { i64, i8, i8, [6 x i8], [0 x i8] }

@page = external hidden global [65536 x i8], align 16
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [3 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

; 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 @ccgc_dumpPage() #1 {
  %1 = alloca i64, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i8, align 1
  %6 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %7 = load i64, ptr @page, align 16, !tbaa !5
  %8 = icmp eq i64 %7, 0
  br i1 %8, label %9, label %11

9:                                                ; preds = %0
  %10 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %106

11:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  store i64 0, ptr %1, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  store ptr @page, ptr %2, align 8, !tbaa !12
  br label %12

12:                                               ; preds = %94, %11
  %13 = load ptr, ptr %2, align 8, !tbaa !12
  %14 = icmp ult ptr %13, getelementptr inbounds (i8, ptr @page, i64 65536)
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  br label %104

16:                                               ; preds = %12
  %17 = load i64, ptr %1, align 8, !tbaa !11
  %18 = load ptr, ptr %2, align 8, !tbaa !12
  %19 = getelementptr inbounds %struct.Block, ptr %18, i32 0, i32 0
  %20 = load i64, ptr %19, align 8, !tbaa !5
  %21 = load ptr, ptr %2, align 8, !tbaa !12
  %22 = getelementptr inbounds %struct.Block, ptr %21, i32 0, i32 1
  %23 = load i8, ptr %22, align 8, !tbaa !14, !range !15, !noundef !16
  %24 = trunc i8 %23 to i1
  %25 = zext i1 %24 to i64
  %26 = select i1 %24, ptr @.str.7, ptr @.str.8
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i64 noundef %17, i64 noundef 16, i64 noundef %20, ptr noundef %26)
  %28 = load ptr, ptr %2, align 8, !tbaa !12
  %29 = getelementptr inbounds %struct.Block, ptr %28, i32 0, i32 1
  %30 = load i8, ptr %29, align 8, !tbaa !14, !range !15, !noundef !16
  %31 = trunc i8 %30 to i1
  br i1 %31, label %33, label %32

32:                                               ; preds = %16
  br label %94

33:                                               ; preds = %16
  %34 = call i32 @putchar(i32 noundef 9)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 0, ptr %4, align 8, !tbaa !11
  br label %35

35:                                               ; preds = %89, %33
  %36 = load i64, ptr %4, align 8, !tbaa !11
  %37 = load ptr, ptr %2, align 8, !tbaa !12
  %38 = getelementptr inbounds %struct.Block, ptr %37, i32 0, i32 0
  %39 = load i64, ptr %38, align 8, !tbaa !5
  %40 = icmp ult i64 %36, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %35
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %92

42:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #5
  %43 = load ptr, ptr %2, align 8, !tbaa !12
  %44 = getelementptr inbounds %struct.Block, ptr %43, i32 0, i32 4
  %45 = load i64, ptr %4, align 8, !tbaa !11
  %46 = getelementptr inbounds [0 x i8], ptr %44, i64 0, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !17
  store i8 %47, ptr %5, align 1, !tbaa !17
  %48 = load i8, ptr %5, align 1, !tbaa !17
  %49 = sext i8 %48 to i32
  switch i32 %49, label %50 [
    i32 0, label %70
    i32 10, label %72
    i32 13, label %74
    i32 9, label %76
    i32 11, label %78
    i32 8, label %80
    i32 7, label %82
    i32 12, label %84
    i32 92, label %86
  ]

50:                                               ; preds = %42
  %51 = call ptr @__ctype_b_loc() #6
  %52 = load ptr, ptr %51, align 8, !tbaa !12
  %53 = load i8, ptr %5, align 1, !tbaa !17
  %54 = sext i8 %53 to i32
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i16, ptr %52, i64 %55
  %57 = load i16, ptr %56, align 2, !tbaa !18
  %58 = zext i16 %57 to i32
  %59 = and i32 %58, 16384
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %65

61:                                               ; preds = %50
  %62 = load i8, ptr %5, align 1, !tbaa !17
  %63 = sext i8 %62 to i32
  %64 = call i32 @putchar(i32 noundef %63)
  br label %69

65:                                               ; preds = %50
  %66 = load i8, ptr %5, align 1, !tbaa !17
  %67 = sext i8 %66 to i32
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i32 noundef %67)
  br label %69

69:                                               ; preds = %65, %61
  br label %88

70:                                               ; preds = %42
  %71 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  br label %88

72:                                               ; preds = %42
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  br label %88

74:                                               ; preds = %42
  %75 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  br label %88

76:                                               ; preds = %42
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  br label %88

78:                                               ; preds = %42
  %79 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  br label %88

80:                                               ; preds = %42
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  br label %88

82:                                               ; preds = %42
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  br label %88

84:                                               ; preds = %42
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  br label %88

86:                                               ; preds = %42
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  br label %88

88:                                               ; preds = %86, %84, %82, %80, %78, %76, %74, %72, %70, %69
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #5
  br label %89

89:                                               ; preds = %88
  %90 = load i64, ptr %4, align 8, !tbaa !11
  %91 = add i64 %90, 1
  store i64 %91, ptr %4, align 8, !tbaa !11
  br label %35, !llvm.loop !20

92:                                               ; preds = %41
  %93 = call i32 @putchar(i32 noundef 10)
  br label %94

94:                                               ; preds = %92, %32
  %95 = load ptr, ptr %2, align 8, !tbaa !12
  %96 = getelementptr inbounds %struct.Block, ptr %95, i32 0, i32 4
  %97 = getelementptr inbounds [0 x i8], ptr %96, i64 0, i64 0
  %98 = load ptr, ptr %2, align 8, !tbaa !12
  %99 = getelementptr inbounds %struct.Block, ptr %98, i32 0, i32 0
  %100 = load i64, ptr %99, align 8, !tbaa !5
  %101 = getelementptr inbounds i8, ptr %97, i64 %100
  store ptr %101, ptr %2, align 8, !tbaa !12
  %102 = load i64, ptr %1, align 8, !tbaa !11
  %103 = add i64 %102, 1
  store i64 %103, ptr %1, align 8, !tbaa !11
  br label %12, !llvm.loop !22

104:                                              ; preds = %15
  %105 = call i32 @putchar(i32 noundef 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  br label %106

106:                                              ; preds = %104, %9
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: inlinehint nounwind uwtable
declare i32 @putchar(i32 noundef) #3

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #4

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 = { "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 = { inlinehint 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 #4 = { nounwind willreturn memory(none) "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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(none) }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 9, !8, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!6, !10, i64 8}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!8, !8, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !8, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


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

@page = external hidden local_unnamed_addr global [65536 x i8], align 16
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @ccgc_dumpPage() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %2 = load i64, ptr @page, align 16, !tbaa !5
  %3 = icmp eq i64 %2, 0
  br i1 %3, label %4, label %.preheader

4:                                                ; preds = %0
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %62

6:                                                ; preds = %58
  %7 = tail call i32 @putchar(i32 noundef 10)
  br label %62

.preheader:                                       ; preds = %0, %58
  %.017.ptr22 = phi ptr [ %.017.ptr, %58 ], [ @page, %0 ]
  %.021 = phi i64 [ %60, %58 ], [ 0, %0 ]
  %.017.idx20 = phi i64 [ %.add, %58 ], [ 0, %0 ]
  %8 = load i64, ptr %.017.ptr22, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %.017.ptr22, i64 8
  %10 = load i8, ptr %9, align 8, !tbaa !11, !range !12, !noundef !13
  %11 = trunc nuw i8 %10 to i1
  %12 = select i1 %11, ptr @.str.7, ptr @.str.8
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i64 noundef %.021, i64 noundef 16, i64 noundef %8, ptr noundef nonnull %12)
  %14 = load i8, ptr %9, align 8, !tbaa !11, !range !12, !noundef !13
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %16, label %58

16:                                               ; preds = %.preheader
  %17 = tail call i32 @putchar(i32 noundef 9)
  %18 = load i64, ptr %.017.ptr22, align 8, !tbaa !5
  %.not24 = icmp eq i64 %18, 0
  br i1 %.not24, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %16
  %19 = getelementptr inbounds i8, ptr %.017.ptr22, i64 16
  br label %21

._crit_edge:                                      ; preds = %54, %16
  %20 = tail call i32 @putchar(i32 noundef 10)
  br label %58

21:                                               ; preds = %.lr.ph, %54
  %.01619 = phi i64 [ 0, %.lr.ph ], [ %55, %54 ]
  %22 = getelementptr inbounds [0 x i8], ptr %19, i64 0, i64 %.01619
  %23 = load i8, ptr %22, align 1, !tbaa !14
  %24 = sext i8 %23 to i32
  switch i8 %23, label %25 [
    i8 0, label %36
    i8 10, label %38
    i8 13, label %40
    i8 9, label %42
    i8 11, label %44
    i8 8, label %46
    i8 7, label %48
    i8 12, label %50
    i8 92, label %52
  ]

25:                                               ; preds = %21
  %26 = tail call ptr @__ctype_b_loc() #4
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %28 = sext i8 %23 to i64
  %29 = getelementptr inbounds i16, ptr %27, i64 %28
  %30 = load i16, ptr %29, align 2, !tbaa !17
  %31 = and i16 %30, 16384
  %.not = icmp eq i16 %31, 0
  br i1 %.not, label %34, label %32

32:                                               ; preds = %25
  %33 = tail call i32 @putchar(i32 noundef %24)
  br label %54

34:                                               ; preds = %25
  %35 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %24)
  br label %54

36:                                               ; preds = %21
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  br label %54

38:                                               ; preds = %21
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  br label %54

40:                                               ; preds = %21
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  br label %54

42:                                               ; preds = %21
  %43 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  br label %54

44:                                               ; preds = %21
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  br label %54

46:                                               ; preds = %21
  %47 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15)
  br label %54

48:                                               ; preds = %21
  %49 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  br label %54

50:                                               ; preds = %21
  %51 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17)
  br label %54

52:                                               ; preds = %21
  %53 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.18)
  br label %54

54:                                               ; preds = %32, %34, %52, %50, %48, %46, %44, %42, %40, %38, %36
  %55 = add nuw i64 %.01619, 1
  %56 = load i64, ptr %.017.ptr22, align 8, !tbaa !5
  %57 = icmp ult i64 %55, %56
  br i1 %57, label %21, label %._crit_edge, !llvm.loop !19

58:                                               ; preds = %.preheader, %._crit_edge
  %.017.add = add nsw i64 %.017.idx20, 16
  %59 = load i64, ptr %.017.ptr22, align 8, !tbaa !5
  %.add = add nsw i64 %.017.add, %59
  %60 = add i64 %.021, 1
  %.017.ptr = getelementptr inbounds i8, ptr @page, i64 %.add
  %61 = icmp slt i64 %.add, 65536
  br i1 %61, label %.preheader, label %6, !llvm.loop !21

62:                                               ; preds = %6, %4
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #3

attributes #0 = { nofree 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 = { 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 = { inlinehint nofree 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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 willreturn memory(none) }

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass