; LLVM IR from Izaron/ACM-ICPC :: Timus Online Judge/Volume 8/1712. Cipher Grille.ll (Z7povorotv)

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

@m = external dso_local global [16 x i8], align 16

; 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: mustprogress nounwind uwtable
define dso_local void @_Z7povorotv() #1 {
  %1 = alloca [16 x i8], align 16
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr %1) #2
  %3 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 3), align 1, !tbaa !5
  %4 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 0
  store i8 %3, ptr %4, align 16, !tbaa !5
  %5 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 7), align 1, !tbaa !5
  %6 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 1
  store i8 %5, ptr %6, align 1, !tbaa !5
  %7 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 11), align 1, !tbaa !5
  %8 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 2
  store i8 %7, ptr %8, align 2, !tbaa !5
  %9 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 15), align 1, !tbaa !5
  %10 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 3
  store i8 %9, ptr %10, align 1, !tbaa !5
  %11 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 2), align 2, !tbaa !5
  %12 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 4
  store i8 %11, ptr %12, align 4, !tbaa !5
  %13 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 6), align 2, !tbaa !5
  %14 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 5
  store i8 %13, ptr %14, align 1, !tbaa !5
  %15 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 10), align 2, !tbaa !5
  %16 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 6
  store i8 %15, ptr %16, align 2, !tbaa !5
  %17 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 14), align 2, !tbaa !5
  %18 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 7
  store i8 %17, ptr %18, align 1, !tbaa !5
  %19 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 1), align 1, !tbaa !5
  %20 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 8
  store i8 %19, ptr %20, align 8, !tbaa !5
  %21 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 5), align 1, !tbaa !5
  %22 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 9
  store i8 %21, ptr %22, align 1, !tbaa !5
  %23 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 9), align 1, !tbaa !5
  %24 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 10
  store i8 %23, ptr %24, align 2, !tbaa !5
  %25 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 13), align 1, !tbaa !5
  %26 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 11
  store i8 %25, ptr %26, align 1, !tbaa !5
  %27 = load i8, ptr @m, align 16, !tbaa !5
  %28 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 12
  store i8 %27, ptr %28, align 4, !tbaa !5
  %29 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 4), align 4, !tbaa !5
  %30 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 13
  store i8 %29, ptr %30, align 1, !tbaa !5
  %31 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 8), align 8, !tbaa !5
  %32 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 14
  store i8 %31, ptr %32, align 2, !tbaa !5
  %33 = load i8, ptr getelementptr inbounds ([16 x i8], ptr @m, i64 0, i64 12), align 4, !tbaa !5
  %34 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 15
  store i8 %33, ptr %34, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %35

35:                                               ; preds = %47, %0
  %36 = load i32, ptr %2, align 4, !tbaa !8
  %37 = icmp slt i32 %36, 16
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  br label %50

39:                                               ; preds = %35
  %40 = load i32, ptr %2, align 4, !tbaa !8
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [16 x i8], ptr %1, i64 0, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = load i32, ptr %2, align 4, !tbaa !8
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [16 x i8], ptr @m, i64 0, i64 %45
  store i8 %43, ptr %46, align 1, !tbaa !5
  br label %47

47:                                               ; preds = %39
  %48 = load i32, ptr %2, align 4, !tbaa !8
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %2, align 4, !tbaa !8
  br label %35, !llvm.loop !10

50:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 16, ptr %1) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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"

@m = external dso_local local_unnamed_addr global [16 x i8], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z7povorotv() local_unnamed_addr #0 {
  %1 = load <16 x i8>, ptr @m, align 16, !tbaa !5
  %2 = shufflevector <16 x i8> %1, <16 x i8> poison, <16 x i32> <i32 3, i32 7, i32 11, i32 15, i32 2, i32 6, i32 10, i32 14, i32 1, i32 5, i32 9, i32 13, i32 0, i32 4, i32 8, i32 12>
  store <16 x i8> %2, ptr @m, align 16, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass