; LLVM IR from zisisvakras/crossw :: src (maps)

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

; 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 @remove_map(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.Map, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %10, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.Map, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %13, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.Map, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !12
  store i32 %16, ptr %7, align 4, !tbaa !13
  br label %17

17:                                               ; preds = %21, %2
  %18 = load i32, ptr %7, align 4, !tbaa !13
  %19 = add nsw i32 %18, -1
  store i32 %19, ptr %7, align 4, !tbaa !13
  %20 = icmp ne i32 %18, 0
  br i1 %20, label %21, label %30

21:                                               ; preds = %17
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds i64, ptr %22, i32 1
  store ptr %23, ptr %6, align 8, !tbaa !5
  %24 = load i64, ptr %22, align 8, !tbaa !14
  %25 = xor i64 %24, -1
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds i64, ptr %26, i32 1
  store ptr %27, ptr %5, align 8, !tbaa !5
  %28 = load i64, ptr %26, align 8, !tbaa !14
  %29 = and i64 %28, %25
  store i64 %29, ptr %26, align 8, !tbaa !14
  br label %17, !llvm.loop !16

30:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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 = { 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, !6, i64 0}
!10 = !{!"Map", !6, i64 0, !11, i64 8, !11, i64 12}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @remove_map(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not7 = icmp eq i32 %4, 0
  br i1 %.not7, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %5 = load ptr, ptr %1, align 8, !tbaa !11
  %6 = load ptr, ptr %0, align 8, !tbaa !11
  %7 = zext i32 %4 to i64
  %min.iters.check = icmp ult i32 %4, 10
  br i1 %min.iters.check, label %.lr.ph.preheader23, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %8 = add i32 %4, -1
  %9 = zext i32 %8 to i64
  %10 = shl nuw nsw i64 %9, 3
  %11 = add nuw nsw i64 %10, 8
  %scevgep = getelementptr i8, ptr %6, i64 %11
  %scevgep11 = getelementptr i8, ptr %5, i64 %11
  %bound0 = icmp ult ptr %6, %scevgep11
  %bound1 = icmp ult ptr %5, %scevgep
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %.lr.ph.preheader23, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %7, 4294967292
  %.cast = trunc nuw i64 %n.vec to i32
  %ind.end = sub i32 %4, %.cast
  %12 = shl nuw nsw i64 %n.vec, 3
  %ind.end12 = getelementptr i8, ptr %5, i64 %12
  %13 = shl nuw nsw i64 %n.vec, 3
  %ind.end14 = getelementptr i8, ptr %6, i64 %13
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 3
  %next.gep = getelementptr i8, ptr %5, i64 %offset.idx
  %offset.idx17 = shl i64 %index, 3
  %next.gep18 = getelementptr i8, ptr %6, i64 %offset.idx17
  %14 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load = load <2 x i64>, ptr %next.gep, align 8, !tbaa !12, !alias.scope !14
  %wide.load20 = load <2 x i64>, ptr %14, align 8, !tbaa !12, !alias.scope !14
  %15 = xor <2 x i64> %wide.load, <i64 -1, i64 -1>
  %16 = xor <2 x i64> %wide.load20, <i64 -1, i64 -1>
  %17 = getelementptr i8, ptr %next.gep18, i64 16
  %wide.load21 = load <2 x i64>, ptr %next.gep18, align 8, !tbaa !12, !alias.scope !17, !noalias !14
  %wide.load22 = load <2 x i64>, ptr %17, align 8, !tbaa !12, !alias.scope !17, !noalias !14
  %18 = and <2 x i64> %wide.load21, %15
  %19 = and <2 x i64> %wide.load22, %16
  store <2 x i64> %18, ptr %next.gep18, align 8, !tbaa !12, !alias.scope !17, !noalias !14
  store <2 x i64> %19, ptr %17, align 8, !tbaa !12, !alias.scope !17, !noalias !14
  %index.next = add nuw i64 %index, 4
  %20 = icmp eq i64 %index.next, %n.vec
  br i1 %20, label %middle.block, label %vector.body, !llvm.loop !19

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %7
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader23

.lr.ph.preheader23:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %.010.ph = phi i32 [ %4, %vector.memcheck ], [ %4, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.059.ph = phi ptr [ %5, %vector.memcheck ], [ %5, %.lr.ph.preheader ], [ %ind.end12, %middle.block ]
  %.068.ph = phi ptr [ %6, %vector.memcheck ], [ %6, %.lr.ph.preheader ], [ %ind.end14, %middle.block ]
  %21 = add nsw i32 %.010.ph, -1
  %xtraiter = and i32 %.010.ph, 3
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader23, %.lr.ph.prol
  %.010.prol = phi i32 [ %22, %.lr.ph.prol ], [ %.010.ph, %.lr.ph.preheader23 ]
  %.059.prol = phi ptr [ %23, %.lr.ph.prol ], [ %.059.ph, %.lr.ph.preheader23 ]
  %.068.prol = phi ptr [ %26, %.lr.ph.prol ], [ %.068.ph, %.lr.ph.preheader23 ]
  %prol.iter = phi i32 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader23 ]
  %22 = add nsw i32 %.010.prol, -1
  %23 = getelementptr inbounds i8, ptr %.059.prol, i64 8
  %24 = load i64, ptr %.059.prol, align 8, !tbaa !12
  %25 = xor i64 %24, -1
  %26 = getelementptr inbounds i8, ptr %.068.prol, i64 8
  %27 = load i64, ptr %.068.prol, align 8, !tbaa !12
  %28 = and i64 %27, %25
  store i64 %28, ptr %.068.prol, align 8, !tbaa !12
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !23

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader23
  %.010.unr = phi i32 [ %.010.ph, %.lr.ph.preheader23 ], [ %22, %.lr.ph.prol ]
  %.059.unr = phi ptr [ %.059.ph, %.lr.ph.preheader23 ], [ %23, %.lr.ph.prol ]
  %.068.unr = phi ptr [ %.068.ph, %.lr.ph.preheader23 ], [ %26, %.lr.ph.prol ]
  %29 = icmp ult i32 %21, 3
  br i1 %29, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.010 = phi i32 [ %48, %.lr.ph ], [ %.010.unr, %.lr.ph.prol.loopexit ]
  %.059 = phi ptr [ %49, %.lr.ph ], [ %.059.unr, %.lr.ph.prol.loopexit ]
  %.068 = phi ptr [ %52, %.lr.ph ], [ %.068.unr, %.lr.ph.prol.loopexit ]
  %30 = getelementptr inbounds i8, ptr %.059, i64 8
  %31 = load i64, ptr %.059, align 8, !tbaa !12
  %32 = xor i64 %31, -1
  %33 = getelementptr inbounds i8, ptr %.068, i64 8
  %34 = load i64, ptr %.068, align 8, !tbaa !12
  %35 = and i64 %34, %32
  store i64 %35, ptr %.068, align 8, !tbaa !12
  %36 = getelementptr inbounds i8, ptr %.059, i64 16
  %37 = load i64, ptr %30, align 8, !tbaa !12
  %38 = xor i64 %37, -1
  %39 = getelementptr inbounds i8, ptr %.068, i64 16
  %40 = load i64, ptr %33, align 8, !tbaa !12
  %41 = and i64 %40, %38
  store i64 %41, ptr %33, align 8, !tbaa !12
  %42 = getelementptr inbounds i8, ptr %.059, i64 24
  %43 = load i64, ptr %36, align 8, !tbaa !12
  %44 = xor i64 %43, -1
  %45 = getelementptr inbounds i8, ptr %.068, i64 24
  %46 = load i64, ptr %39, align 8, !tbaa !12
  %47 = and i64 %46, %44
  store i64 %47, ptr %39, align 8, !tbaa !12
  %48 = add nsw i32 %.010, -4
  %49 = getelementptr inbounds i8, ptr %.059, i64 32
  %50 = load i64, ptr %42, align 8, !tbaa !12
  %51 = xor i64 %50, -1
  %52 = getelementptr inbounds i8, ptr %.068, i64 32
  %53 = load i64, ptr %45, align 8, !tbaa !12
  %54 = and i64 %53, %51
  store i64 %54, ptr %45, align 8, !tbaa !12
  %.not.3 = icmp eq i32 %48, 0
  br i1 %.not.3, label %._crit_edge, label %.lr.ph, !llvm.loop !25

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %2
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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, !10, i64 8}
!6 = !{!"Map", !7, i64 0, !10, i64 8, !10, i64 12}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !8, i64 0}
!14 = !{!15}
!15 = distinct !{!15, !16}
!16 = distinct !{!16, !"LVerDomain"}
!17 = !{!18}
!18 = distinct !{!18, !16}
!19 = distinct !{!19, !20, !21, !22}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"llvm.loop.isvectorized", i32 1}
!22 = !{!"llvm.loop.unroll.runtime.disable"}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.unroll.disable"}
!25 = distinct !{!25, !20, !21}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass