; LLVM IR from lzyrapx/Competitive-Programming :: BZOJ/3224（splay模板）.ll (Z6RotateRKiS0_)

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

@fa = external dso_local global [100005 x i32], align 16
@ch = external dso_local global [100005 x [2 x i32]], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z2upRKi(ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6RotateRKiS0_(ptr noundef nonnull align 4 dereferenceable(4) %0, ptr noundef nonnull align 4 dereferenceable(4) %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = 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 4, ptr %5) #2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %10, ptr %5, align 4, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %13
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [2 x i32], ptr %14, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %21
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load i32, ptr %23, align 4, !tbaa !9
  %25 = xor i32 %24, 1
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [2 x i32], ptr %22, i64 0, i64 %26
  store i32 %19, ptr %27, align 4, !tbaa !9
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %30
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [2 x i32], ptr %31, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %51

38:                                               ; preds = %2
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = load i32, ptr %40, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %42
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [2 x i32], ptr %43, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %49
  store i32 %39, ptr %50, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %38, %2
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %58
  store i32 %55, ptr %59, align 4, !tbaa !9
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = load i32, ptr %60, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !9
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %98

66:                                               ; preds = %51
  %67 = load i32, ptr %5, align 4, !tbaa !9
  %68 = load i32, ptr %5, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %72
  %74 = getelementptr inbounds [2 x i32], ptr %73, i64 0, i64 0
  %75 = load i32, ptr %74, align 8, !tbaa !9
  %76 = icmp eq i32 %67, %75
  br i1 %76, label %77, label %87

77:                                               ; preds = %66
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = load i32, ptr %78, align 4, !tbaa !9
  %80 = load i32, ptr %5, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %84
  %86 = getelementptr inbounds [2 x i32], ptr %85, i64 0, i64 0
  store i32 %79, ptr %86, align 8, !tbaa !9
  br label %97

87:                                               ; preds = %66
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = load i32, ptr %88, align 4, !tbaa !9
  %90 = load i32, ptr %5, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %94
  %96 = getelementptr inbounds [2 x i32], ptr %95, i64 0, i64 1
  store i32 %89, ptr %96, align 4, !tbaa !9
  br label %97

97:                                               ; preds = %87, %77
  br label %98

98:                                               ; preds = %97, %51
  %99 = load i32, ptr %5, align 4, !tbaa !9
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = load i32, ptr %100, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %102
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = load i32, ptr %104, align 4, !tbaa !9
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [2 x i32], ptr %103, i64 0, i64 %106
  store i32 %99, ptr %107, align 4, !tbaa !9
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = load i32, ptr %108, align 4, !tbaa !9
  %110 = load i32, ptr %5, align 4, !tbaa !9
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %111
  store i32 %109, ptr %112, align 4, !tbaa !9
  call void @_Z2upRKi(ptr noundef nonnull align 4 dereferenceable(4) %5)
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_Z2upRKi(ptr noundef nonnull align 4 dereferenceable(4) %113)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

; 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

attributes #0 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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

@fa = external dso_local local_unnamed_addr global [100005 x i32], align 16
@ch = external dso_local local_unnamed_addr global [100005 x [2 x i32]], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z2upRKi(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6RotateRKiS0_(ptr noundef nonnull align 4 dereferenceable(4) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(4) %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #2
  %4 = load i32, ptr %0, align 4, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %5
  %7 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %7, ptr %3, align 4, !tbaa !5
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %5, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = sext i32 %7 to i64
  %13 = xor i32 %8, 1
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %12, i64 %14
  store i32 %11, ptr %15, align 4, !tbaa !5
  %16 = load i32, ptr %0, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %17, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %.not = icmp eq i32 %21, 0
  br i1 %.not, label %25, label %22

22:                                               ; preds = %2
  %23 = sext i32 %21 to i64
  %24 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %23
  store i32 %7, ptr %24, align 4, !tbaa !5
  %.pre = load i32, ptr %0, align 4, !tbaa !5
  %.pre17 = sext i32 %.pre to i64
  br label %25

25:                                               ; preds = %22, %2
  %.pre-phi = phi i64 [ %.pre17, %22 ], [ %17, %2 ]
  %26 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %12
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %.pre-phi
  store i32 %27, ptr %28, align 4, !tbaa !5
  %29 = load i32, ptr %0, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100005 x i32], ptr @fa, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %.not16 = icmp eq i32 %32, 0
  br i1 %.not16, label %41, label %33

33:                                               ; preds = %25
  %34 = sext i32 %27 to i64
  %35 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %34
  %36 = load i32, ptr %35, align 8, !tbaa !5
  %37 = icmp eq i32 %7, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %33
  store i32 %29, ptr %35, align 8, !tbaa !5
  br label %41

39:                                               ; preds = %33
  %40 = getelementptr inbounds i8, ptr %35, i64 4
  store i32 %29, ptr %40, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %38, %39, %25
  %42 = load i32, ptr %0, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = load i32, ptr %1, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100005 x [2 x i32]], ptr @ch, i64 0, i64 %43, i64 %45
  store i32 %7, ptr %46, align 4, !tbaa !5
  %47 = load i32, ptr %0, align 4, !tbaa !5
  store i32 %47, ptr %26, align 4, !tbaa !5
  call void @_Z2upRKi(ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @_Z2upRKi(ptr noundef nonnull align 4 dereferenceable(4) %0)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #2
  ret void
}

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

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

attributes #0 = { mustprogress 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 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass