; LLVM IR from DanEngelbrecht/longtail :: lib/bikeshed (longtail_bikeshed)

; 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.Bikeshed_Shed_private = type { %struct.AtomicIndex, %struct.AtomicIndex, %struct.AtomicIndex, %struct.AtomicIndex, %struct.AtomicIndex, %struct.AtomicIndex, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.AtomicIndex = type { i32 }

; Function Attrs: nounwind uwtable
define dso_local ptr @Bikeshed_Create(ptr noundef %0, i32 noundef %1, i32 noundef %2, i8 noundef zeroext %3, ptr noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i8 %3, ptr %9, align 1, !tbaa !11
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %14, ptr %11, align 8, !tbaa !5
  %15 = load ptr, ptr %11, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %15, i32 0, i32 5
  %17 = getelementptr inbounds %struct.AtomicIndex, ptr %16, i32 0, i32 0
  store volatile i32 1, ptr %17, align 4, !tbaa !12
  %18 = load ptr, ptr %10, align 8, !tbaa !5
  %19 = load ptr, ptr %11, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %19, i32 0, i32 12
  store ptr %18, ptr %20, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %21, ptr %12, align 8, !tbaa !5
  %22 = load ptr, ptr %12, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 80
  store ptr %23, ptr %12, align 8, !tbaa !5
  %24 = load ptr, ptr %12, align 8, !tbaa !5
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %25, i32 0, i32 6
  store ptr %24, ptr %26, align 8, !tbaa !16
  %27 = load i8, ptr %9, align 1, !tbaa !11
  %28 = zext i8 %27 to i32
  %29 = sub nsw i32 %28, 1
  %30 = sext i32 %29 to i64
  %31 = mul i64 4, %30
  %32 = add i64 %31, 4
  %33 = trunc i64 %32 to i32
  %34 = add i32 %33, 3
  %35 = and i32 %34, -4
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  %37 = zext i32 %35 to i64
  %38 = getelementptr inbounds i8, ptr %36, i64 %37
  store ptr %38, ptr %12, align 8, !tbaa !5
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %40, i32 0, i32 7
  store ptr %39, ptr %41, align 8, !tbaa !17
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = zext i32 %42 to i64
  %44 = mul i64 4, %43
  %45 = trunc i64 %44 to i32
  %46 = add i32 %45, 3
  %47 = and i32 %46, -4
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = zext i32 %47 to i64
  %50 = getelementptr inbounds i8, ptr %48, i64 %49
  store ptr %50, ptr %12, align 8, !tbaa !5
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %52, i32 0, i32 8
  store ptr %51, ptr %53, align 8, !tbaa !18
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = zext i32 %54 to i64
  %56 = mul i64 4, %55
  %57 = trunc i64 %56 to i32
  %58 = add i32 %57, 3
  %59 = and i32 %58, -4
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = zext i32 %59 to i64
  %62 = getelementptr inbounds i8, ptr %60, i64 %61
  store ptr %62, ptr %12, align 8, !tbaa !5
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %64, i32 0, i32 9
  store ptr %63, ptr %65, align 8, !tbaa !19
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = mul i64 4, %67
  %69 = trunc i64 %68 to i32
  %70 = add i32 %69, 3
  %71 = and i32 %70, -4
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = zext i32 %71 to i64
  %74 = getelementptr inbounds i8, ptr %72, i64 %73
  store ptr %74, ptr %12, align 8, !tbaa !5
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %76, i32 0, i32 10
  store ptr %75, ptr %77, align 8, !tbaa !20
  %78 = load i32, ptr %7, align 4, !tbaa !9
  %79 = zext i32 %78 to i64
  %80 = mul i64 32, %79
  %81 = trunc i64 %80 to i32
  %82 = add i32 %81, 7
  %83 = and i32 %82, -8
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = zext i32 %83 to i64
  %86 = getelementptr inbounds i8, ptr %84, i64 %85
  store ptr %86, ptr %12, align 8, !tbaa !5
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %88, i32 0, i32 11
  store ptr %87, ptr %89, align 8, !tbaa !21
  %90 = load ptr, ptr %11, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %90, i32 0, i32 4
  %92 = getelementptr inbounds %struct.AtomicIndex, ptr %91, i32 0, i32 0
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %93, i32 0, i32 1
  %95 = getelementptr inbounds %struct.AtomicIndex, ptr %94, i32 0, i32 0
  %96 = load ptr, ptr %11, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %96, i32 0, i32 8
  %98 = load ptr, ptr %97, align 8, !tbaa !18
  %99 = load i32, ptr %7, align 4, !tbaa !9
  call void @Bikeshed_PoolInitialize_private(ptr noundef %92, ptr noundef %95, ptr noundef %98, i32 noundef %99)
  %100 = load ptr, ptr %11, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %100, i32 0, i32 3
  %102 = getelementptr inbounds %struct.AtomicIndex, ptr %101, i32 0, i32 0
  %103 = load ptr, ptr %11, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %103, i32 0, i32 2
  %105 = getelementptr inbounds %struct.AtomicIndex, ptr %104, i32 0, i32 0
  %106 = load ptr, ptr %11, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %106, i32 0, i32 9
  %108 = load ptr, ptr %107, align 8, !tbaa !19
  %109 = load i32, ptr %8, align 4, !tbaa !9
  call void @Bikeshed_PoolInitialize_private(ptr noundef %102, ptr noundef %105, ptr noundef %108, i32 noundef %109)
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #2
  store i8 0, ptr %13, align 1, !tbaa !11
  br label %110

110:                                              ; preds = %125, %5
  %111 = load i8, ptr %13, align 1, !tbaa !11
  %112 = zext i8 %111 to i32
  %113 = load i8, ptr %9, align 1, !tbaa !11
  %114 = zext i8 %113 to i32
  %115 = icmp slt i32 %112, %114
  br i1 %115, label %117, label %116

116:                                              ; preds = %110
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #2
  br label %128

117:                                              ; preds = %110
  %118 = load ptr, ptr %11, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.Bikeshed_Shed_private, ptr %118, i32 0, i32 6
  %120 = load ptr, ptr %119, align 8, !tbaa !16
  %121 = load i8, ptr %13, align 1, !tbaa !11
  %122 = zext i8 %121 to i64
  %123 = getelementptr inbounds %struct.AtomicIndex, ptr %120, i64 %122
  %124 = getelementptr inbounds %struct.AtomicIndex, ptr %123, i32 0, i32 0
  store volatile i32 0, ptr %124, align 4, !tbaa !22
  br label %125

125:                                              ; preds = %117
  %126 = load i8, ptr %13, align 1, !tbaa !11
  %127 = add i8 %126, 1
  store i8 %127, ptr %13, align 1, !tbaa !11
  br label %110, !llvm.loop !23

128:                                              ; preds = %116
  %129 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  ret ptr %129
}

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

; Function Attrs: nounwind uwtable
declare hidden void @Bikeshed_PoolInitialize_private(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #0

; 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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 20}
!13 = !{!"Bikeshed_Shed_private", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72}
!14 = !{!"AtomicIndex", !10, i64 0}
!15 = !{!13, !6, i64 72}
!16 = !{!13, !6, i64 24}
!17 = !{!13, !6, i64 32}
!18 = !{!13, !6, i64 40}
!19 = !{!13, !6, i64 48}
!20 = !{!13, !6, i64 56}
!21 = !{!13, !6, i64 64}
!22 = !{!14, !10, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"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.AtomicIndex = type { i32 }

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @Bikeshed_Create(ptr noundef returned %0, i32 noundef %1, i32 noundef %2, i8 noundef zeroext %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 20
  store volatile i32 1, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 72
  store ptr %4, ptr %7, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 80
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %8, ptr %9, align 8, !tbaa !13
  %10 = zext i8 %3 to i64
  %11 = shl nuw nsw i64 %10, 2
  %12 = getelementptr inbounds i8, ptr %8, i64 %11
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %12, ptr %13, align 8, !tbaa !14
  %14 = shl i32 %1, 2
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds i8, ptr %12, i64 %15
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %16, ptr %17, align 8, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %16, i64 %15
  %19 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr %18, ptr %19, align 8, !tbaa !16
  %20 = shl i32 %2, 2
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds i8, ptr %18, i64 %21
  %23 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %22, ptr %23, align 8, !tbaa !17
  %24 = shl i32 %1, 5
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %22, i64 %25
  %27 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr %26, ptr %27, align 8, !tbaa !18
  %28 = getelementptr inbounds i8, ptr %0, i64 16
  %29 = getelementptr inbounds i8, ptr %0, i64 4
  tail call void @Bikeshed_PoolInitialize_private(ptr noundef nonnull %28, ptr noundef nonnull %29, ptr noundef nonnull %16, i32 noundef %1)
  %30 = getelementptr inbounds i8, ptr %0, i64 12
  %31 = getelementptr inbounds i8, ptr %0, i64 8
  %32 = load ptr, ptr %19, align 8, !tbaa !16
  tail call void @Bikeshed_PoolInitialize_private(ptr noundef nonnull %30, ptr noundef nonnull %31, ptr noundef %32, i32 noundef %2)
  %.not = icmp eq i8 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %33 = load ptr, ptr %9, align 8, !tbaa !13
  %xtraiter = and i64 %10, 7
  %34 = icmp ult i8 %3, 8
  br i1 %34, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %10, 248
  br label %36

._crit_edge.loopexit.unr-lcssa:                   ; preds = %36, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.7, %36 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %35 = getelementptr inbounds %struct.AtomicIndex, ptr %33, i64 %indvars.iv.epil
  store volatile i32 0, ptr %35, align 4, !tbaa !19
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !20

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %5
  ret ptr %0

36:                                               ; preds = %36, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.7, %36 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.7, %36 ]
  %37 = getelementptr inbounds %struct.AtomicIndex, ptr %33, i64 %indvars.iv
  store volatile i32 0, ptr %37, align 4, !tbaa !19
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %38 = getelementptr inbounds %struct.AtomicIndex, ptr %33, i64 %indvars.iv.next
  store volatile i32 0, ptr %38, align 4, !tbaa !19
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %39 = getelementptr inbounds %struct.AtomicIndex, ptr %33, i64 %indvars.iv.next.1
  store volatile i32 0, ptr %39, align 4, !tbaa !19
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %40 = getelementptr inbounds %struct.AtomicIndex, ptr %33, i64 %indvars.iv.next.2
  store volatile i32 0, ptr %40, align 4, !tbaa !19
  %indvars.iv.next.3 = or disjoint i64 %indvars.iv, 4
  %41 = getelementptr inbounds %struct.AtomicIndex, ptr %33, i64 %indvars.iv.next.3
  store volatile i32 0, ptr %41, align 4, !tbaa !19
  %indvars.iv.next.4 = or disjoint i64 %indvars.iv, 5
  %42 = getelementptr inbounds %struct.AtomicIndex, ptr %33, i64 %indvars.iv.next.4
  store volatile i32 0, ptr %42, align 4, !tbaa !19
  %indvars.iv.next.5 = or disjoint i64 %indvars.iv, 6
  %43 = getelementptr inbounds %struct.AtomicIndex, ptr %33, i64 %indvars.iv.next.5
  store volatile i32 0, ptr %43, align 4, !tbaa !19
  %indvars.iv.next.6 = or disjoint i64 %indvars.iv, 7
  %44 = getelementptr inbounds %struct.AtomicIndex, ptr %33, i64 %indvars.iv.next.6
  store volatile i32 0, ptr %44, align 4, !tbaa !19
  %indvars.iv.next.7 = add nuw nsw i64 %indvars.iv, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %._crit_edge.loopexit.unr-lcssa, label %36, !llvm.loop !22
}

; Function Attrs: nounwind uwtable
declare hidden void @Bikeshed_PoolInitialize_private(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

!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, !8, i64 20}
!6 = !{!"Bikeshed_Shed_private", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72}
!7 = !{!"AtomicIndex", !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!6, !11, i64 72}
!13 = !{!6, !11, i64 24}
!14 = !{!6, !11, i64 32}
!15 = !{!6, !11, i64 40}
!16 = !{!6, !11, i64 48}
!17 = !{!6, !11, i64 56}
!18 = !{!6, !11, i64 64}
!19 = !{!7, !8, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.unroll.disable"}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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