; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/373 Division 1/Problem C/brute.ll (Z4fastPA2_xx)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3mulPA2_xS0_(ptr noundef, 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: mustprogress nounwind uwtable
define dso_local void @_Z4fastPA2_xx(ptr noundef %0, i64 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca [2 x [2 x i64]], align 16
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #2
  %9 = getelementptr inbounds [2 x [2 x i64]], ptr %5, i64 0, i64 1
  %10 = getelementptr inbounds [2 x i64], ptr %9, i64 0, i64 1
  store i64 1, ptr %10, align 8, !tbaa !9
  %11 = getelementptr inbounds [2 x [2 x i64]], ptr %5, i64 0, i64 0
  %12 = getelementptr inbounds [2 x i64], ptr %11, i64 0, i64 0
  store i64 1, ptr %12, align 16, !tbaa !9
  %13 = getelementptr inbounds [2 x [2 x i64]], ptr %5, i64 0, i64 0
  %14 = getelementptr inbounds [2 x i64], ptr %13, i64 0, i64 1
  store i64 0, ptr %14, align 8, !tbaa !9
  %15 = getelementptr inbounds [2 x [2 x i64]], ptr %5, i64 0, i64 1
  %16 = getelementptr inbounds [2 x i64], ptr %15, i64 0, i64 0
  store i64 0, ptr %16, align 16, !tbaa !9
  br label %17

17:                                               ; preds = %27, %2
  %18 = load i64, ptr %4, align 8, !tbaa !9
  %19 = icmp ne i64 %18, 0
  br i1 %19, label %20, label %32

20:                                               ; preds = %17
  %21 = load i64, ptr %4, align 8, !tbaa !9
  %22 = and i64 %21, 1
  %23 = icmp ne i64 %22, 0
  br i1 %23, label %24, label %27

24:                                               ; preds = %20
  %25 = getelementptr inbounds [2 x [2 x i64]], ptr %5, i64 0, i64 0
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_Z3mulPA2_xS0_(ptr noundef %25, ptr noundef %26)
  br label %27

27:                                               ; preds = %24, %20
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_Z3mulPA2_xS0_(ptr noundef %28, ptr noundef %29)
  %30 = load i64, ptr %4, align 8, !tbaa !9
  %31 = ashr i64 %30, 1
  store i64 %31, ptr %4, align 8, !tbaa !9
  br label %17, !llvm.loop !11

32:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !13
  br label %33

33:                                               ; preds = %61, %32
  %34 = load i32, ptr %6, align 4, !tbaa !13
  %35 = icmp slt i32 %34, 2
  br i1 %35, label %37, label %36

36:                                               ; preds = %33
  store i32 4, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %64

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !13
  br label %38

38:                                               ; preds = %57, %37
  %39 = load i32, ptr %8, align 4, !tbaa !13
  %40 = icmp slt i32 %39, 2
  br i1 %40, label %42, label %41

41:                                               ; preds = %38
  store i32 7, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %60

42:                                               ; preds = %38
  %43 = load i32, ptr %6, align 4, !tbaa !13
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [2 x [2 x i64]], ptr %5, i64 0, i64 %44
  %46 = load i32, ptr %8, align 4, !tbaa !13
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [2 x i64], ptr %45, i64 0, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = load i32, ptr %6, align 4, !tbaa !13
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [2 x i64], ptr %50, i64 %52
  %54 = load i32, ptr %8, align 4, !tbaa !13
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [2 x i64], ptr %53, i64 0, i64 %55
  store i64 %49, ptr %56, align 8, !tbaa !9
  br label %57

57:                                               ; preds = %42
  %58 = load i32, ptr %8, align 4, !tbaa !13
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %8, align 4, !tbaa !13
  br label %38, !llvm.loop !15

60:                                               ; preds = %41
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %6, align 4, !tbaa !13
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %6, align 4, !tbaa !13
  br label %33, !llvm.loop !16

64:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #2
  ret void
}

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 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


; 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: mustprogress nounwind uwtable
declare dso_local void @_Z3mulPA2_xS0_(ptr noundef, ptr noundef) local_unnamed_addr #0

; 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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z4fastPA2_xx(ptr noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = alloca [2 x [2 x i64]], align 16
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #4
  %4 = getelementptr inbounds i8, ptr %3, i64 24
  store i64 1, ptr %4, align 8, !tbaa !5
  store i64 1, ptr %3, align 16, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  %.not18 = icmp eq i64 %1, 0
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  br i1 %.not18, label %.preheader17, label %.lr.ph

.preheader17:                                     ; preds = %8, %2
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 16 dereferenceable(32) %3, i64 32, i1 false), !tbaa !5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #4
  ret void

.lr.ph:                                           ; preds = %2, %8
  %.01519 = phi i64 [ %9, %8 ], [ %1, %2 ]
  %6 = and i64 %.01519, 1
  %.not16 = icmp eq i64 %6, 0
  br i1 %.not16, label %8, label %7

7:                                                ; preds = %.lr.ph
  call void @_Z3mulPA2_xS0_(ptr noundef nonnull %3, ptr noundef %0)
  br label %8

8:                                                ; preds = %7, %.lr.ph
  call void @_Z3mulPA2_xS0_(ptr noundef %0, ptr noundef %0)
  %9 = ashr i64 %.01519, 1
  %.not = icmp ult i64 %.01519, 2
  br i1 %.not, label %.preheader17, label %.lr.ph, !llvm.loop !9
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,SROAPass,SimplifyCFGPass