; LLVM IR from caryll/otfcc :: lib/bk (bkblock)

; 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.__caryll_bkblock = type { i32, i32, i32, i32, i32, i32, ptr }
%struct.bk_Cell = type { i32, %union.anon }
%union.anon = type { ptr }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @bk_cellIsPointer(ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @bk_printBlock(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr @stderr, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.__caryll_bkblock, ptr %5, i32 0, i32 4
  %7 = load i32, ptr %6, align 8, !tbaa !9
  %8 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef @.str, i32 noundef %7) #3
  %9 = load ptr, ptr @stderr, align 8, !tbaa !5
  %10 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef @.str.1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !12
  br label %11

11:                                               ; preds = %97, %1
  %12 = load i32, ptr %3, align 4, !tbaa !12
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.__caryll_bkblock, ptr %13, i32 0, i32 4
  %15 = load i32, ptr %14, align 8, !tbaa !9
  %16 = icmp ult i32 %12, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %100

18:                                               ; preds = %11
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.__caryll_bkblock, ptr %19, i32 0, i32 6
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = load i32, ptr %3, align 4, !tbaa !12
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds %struct.bk_Cell, ptr %21, i64 %23
  %25 = call zeroext i1 @bk_cellIsPointer(ptr noundef %24)
  br i1 %25, label %26, label %77

26:                                               ; preds = %18
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.__caryll_bkblock, ptr %27, i32 0, i32 6
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = load i32, ptr %3, align 4, !tbaa !12
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds %struct.bk_Cell, ptr %29, i64 %31
  %33 = getelementptr inbounds %struct.bk_Cell, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %65

36:                                               ; preds = %26
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.__caryll_bkblock, ptr %38, i32 0, i32 6
  %40 = load ptr, ptr %39, align 8, !tbaa !13
  %41 = load i32, ptr %3, align 4, !tbaa !12
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds %struct.bk_Cell, ptr %40, i64 %42
  %44 = getelementptr inbounds %struct.bk_Cell, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 8, !tbaa !15
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.__caryll_bkblock, ptr %46, i32 0, i32 6
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  %49 = load i32, ptr %3, align 4, !tbaa !12
  %50 = zext i32 %49 to i64
  %51 = getelementptr inbounds %struct.bk_Cell, ptr %48, i64 %50
  %52 = getelementptr inbounds %struct.bk_Cell, ptr %51, i32 0, i32 1
  %53 = load ptr, ptr %52, align 8, !tbaa !14
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.__caryll_bkblock, ptr %54, i32 0, i32 6
  %56 = load ptr, ptr %55, align 8, !tbaa !13
  %57 = load i32, ptr %3, align 4, !tbaa !12
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds %struct.bk_Cell, ptr %56, i64 %58
  %60 = getelementptr inbounds %struct.bk_Cell, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !14
  %62 = getelementptr inbounds %struct.__caryll_bkblock, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !17
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef @.str.2, i32 noundef %45, ptr noundef %53, i32 noundef %63) #3
  br label %76

65:                                               ; preds = %26
  %66 = load ptr, ptr @stderr, align 8, !tbaa !5
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.__caryll_bkblock, ptr %67, i32 0, i32 6
  %69 = load ptr, ptr %68, align 8, !tbaa !13
  %70 = load i32, ptr %3, align 4, !tbaa !12
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds %struct.bk_Cell, ptr %69, i64 %71
  %73 = getelementptr inbounds %struct.bk_Cell, ptr %72, i32 0, i32 0
  %74 = load i32, ptr %73, align 8, !tbaa !15
  %75 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef @.str.3, i32 noundef %74) #3
  br label %76

76:                                               ; preds = %65, %36
  br label %96

77:                                               ; preds = %18
  %78 = load ptr, ptr @stderr, align 8, !tbaa !5
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.__caryll_bkblock, ptr %79, i32 0, i32 6
  %81 = load ptr, ptr %80, align 8, !tbaa !13
  %82 = load i32, ptr %3, align 4, !tbaa !12
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds %struct.bk_Cell, ptr %81, i64 %83
  %85 = getelementptr inbounds %struct.bk_Cell, ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 8, !tbaa !15
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.__caryll_bkblock, ptr %87, i32 0, i32 6
  %89 = load ptr, ptr %88, align 8, !tbaa !13
  %90 = load i32, ptr %3, align 4, !tbaa !12
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds %struct.bk_Cell, ptr %89, i64 %91
  %93 = getelementptr inbounds %struct.bk_Cell, ptr %92, i32 0, i32 1
  %94 = load i32, ptr %93, align 8, !tbaa !14
  %95 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %78, ptr noundef @.str.4, i32 noundef %86, i32 noundef %94) #3
  br label %96

96:                                               ; preds = %77, %76
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %3, align 4, !tbaa !12
  %99 = add i32 %98, 1
  store i32 %99, ptr %3, align 4, !tbaa !12
  br label %11, !llvm.loop !18

100:                                              ; preds = %17
  %101 = load ptr, ptr @stderr, align 8, !tbaa !5
  %102 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef @.str.1) #3
  ret void
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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 = { 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 #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, !11, i64 16}
!10 = !{!"__caryll_bkblock", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !6, i64 24}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !11, i64 0}
!16 = !{!"", !11, i64 0, !7, i64 8}
!17 = !{!10, !11, i64 4}
!18 = distinct !{!18, !19}
!19 = !{!"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"

%struct.bk_Cell = type { i32, %union.anon }
%union.anon = type { ptr }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [10 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @bk_printBlock(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr @stderr, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load i32, ptr %3, align 8, !tbaa !9
  %5 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str, i32 noundef %4) #2
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str.1) #2
  %8 = load i32, ptr %3, align 8, !tbaa !9
  %.not21 = icmp eq i32 %8, 0
  br i1 %.not21, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  br label %12

._crit_edge:                                      ; preds = %37, %1
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.1) #2
  ret void

12:                                               ; preds = %.lr.ph, %37
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %37 ]
  %13 = load ptr, ptr %9, align 8, !tbaa !12
  %14 = getelementptr inbounds %struct.bk_Cell, ptr %13, i64 %indvars.iv
  %15 = tail call zeroext i1 @bk_cellIsPointer(ptr noundef %14)
  br i1 %15, label %16, label %29

16:                                               ; preds = %12
  %17 = load ptr, ptr %9, align 8, !tbaa !12
  %18 = getelementptr inbounds %struct.bk_Cell, ptr %17, i64 %indvars.iv
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %.not = icmp eq ptr %20, null
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = load i32, ptr %18, align 8, !tbaa !14
  br i1 %.not, label %27, label %23

23:                                               ; preds = %16
  %24 = getelementptr inbounds i8, ptr %20, i64 4
  %25 = load i32, ptr %24, align 4, !tbaa !16
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.2, i32 noundef %22, ptr noundef nonnull %20, i32 noundef %25) #2
  br label %37

27:                                               ; preds = %16
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.3, i32 noundef %22) #2
  br label %37

29:                                               ; preds = %12
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = load ptr, ptr %9, align 8, !tbaa !12
  %32 = getelementptr inbounds %struct.bk_Cell, ptr %31, i64 %indvars.iv
  %33 = load i32, ptr %32, align 8, !tbaa !14
  %34 = getelementptr inbounds i8, ptr %32, i64 8
  %35 = load i32, ptr %34, align 8, !tbaa !13
  %36 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.4, i32 noundef %33, i32 noundef %35) #2
  br label %37

37:                                               ; preds = %29, %27, %23
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %38 = load i32, ptr %3, align 8, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = icmp ult i64 %indvars.iv.next, %39
  br i1 %40, label %12, label %._crit_edge, !llvm.loop !17
}

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) 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 = { 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 = { cold 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, !11, i64 16}
!10 = !{!"__caryll_bkblock", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !11, i64 0}
!15 = !{!"", !11, i64 0, !7, i64 8}
!16 = !{!10, !11, i64 4}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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