; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/LONG/JULY15/ADDMUL/A.ll (Z5shiftiii)

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

@lazy1 = external dso_local global [262144 x i64], align 16
@lazy2 = external dso_local global [262144 x i64], align 16
@lazy3 = external dso_local global [262144 x i64], 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 uwtable
declare dso_local void @_Z4upd1iiix(i32 noundef, i32 noundef, i32 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4upd2iiix(i32 noundef, i32 noundef, i32 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4upd3iiix(i32 noundef, i32 noundef, i32 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5shiftiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %8 = load i32, ptr %5, align 4, !tbaa !5
  %9 = load i32, ptr %6, align 4, !tbaa !5
  %10 = add nsw i32 %8, %9
  %11 = sdiv i32 %10, 2
  store i32 %11, ptr %7, align 4, !tbaa !5
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [262144 x i64], ptr @lazy3, i64 0, i64 %13
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = icmp sgt i64 %15, 0
  br i1 %16, label %17, label %38

17:                                               ; preds = %3
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = mul nsw i32 %18, 2
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [262144 x i64], ptr @lazy3, i64 0, i64 %23
  %25 = load i64, ptr %24, align 8, !tbaa !9
  call void @_Z4upd3iiix(i32 noundef %19, i32 noundef %20, i32 noundef %21, i64 noundef %25)
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = mul nsw i32 %26, 2
  %28 = add nsw i32 %27, 1
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [262144 x i64], ptr @lazy3, i64 0, i64 %32
  %34 = load i64, ptr %33, align 8, !tbaa !9
  call void @_Z4upd3iiix(i32 noundef %28, i32 noundef %29, i32 noundef %30, i64 noundef %34)
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [262144 x i64], ptr @lazy3, i64 0, i64 %36
  store i64 0, ptr %37, align 8, !tbaa !9
  br label %38

38:                                               ; preds = %17, %3
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [262144 x i64], ptr @lazy2, i64 0, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !9
  %43 = icmp sgt i64 %42, 0
  br i1 %43, label %44, label %65

44:                                               ; preds = %38
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = mul nsw i32 %45, 2
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [262144 x i64], ptr @lazy2, i64 0, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !9
  call void @_Z4upd2iiix(i32 noundef %46, i32 noundef %47, i32 noundef %48, i64 noundef %52)
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = mul nsw i32 %53, 2
  %55 = add nsw i32 %54, 1
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [262144 x i64], ptr @lazy2, i64 0, i64 %59
  %61 = load i64, ptr %60, align 8, !tbaa !9
  call void @_Z4upd2iiix(i32 noundef %55, i32 noundef %56, i32 noundef %57, i64 noundef %61)
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [262144 x i64], ptr @lazy2, i64 0, i64 %63
  store i64 1, ptr %64, align 8, !tbaa !9
  br label %65

65:                                               ; preds = %44, %38
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = mul nsw i32 %66, 2
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [262144 x i64], ptr @lazy1, i64 0, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !9
  call void @_Z4upd1iiix(i32 noundef %67, i32 noundef %68, i32 noundef %69, i64 noundef %73)
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = mul nsw i32 %74, 2
  %76 = add nsw i32 %75, 1
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = load i32, ptr %4, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [262144 x i64], ptr @lazy1, i64 0, i64 %80
  %82 = load i64, ptr %81, align 8, !tbaa !9
  call void @_Z4upd1iiix(i32 noundef %76, i32 noundef %77, i32 noundef %78, i64 noundef %82)
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [262144 x i64], ptr @lazy1, i64 0, i64 %84
  store i64 0, ptr %85, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret void
}

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

@lazy1 = external dso_local local_unnamed_addr global [262144 x i64], align 16
@lazy2 = external dso_local local_unnamed_addr global [262144 x i64], align 16
@lazy3 = external dso_local local_unnamed_addr global [262144 x i64], align 16

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4upd1iiix(i32 noundef, i32 noundef, i32 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4upd2iiix(i32 noundef, i32 noundef, i32 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4upd3iiix(i32 noundef, i32 noundef, i32 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5shiftiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = add nsw i32 %2, %1
  %5 = sdiv i32 %4, 2
  %6 = sext i32 %0 to i64
  %7 = getelementptr inbounds [262144 x i64], ptr @lazy3, i64 0, i64 %6
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %9 = icmp sgt i64 %8, 0
  br i1 %9, label %10, label %14

10:                                               ; preds = %3
  %11 = shl nsw i32 %0, 1
  tail call void @_Z4upd3iiix(i32 noundef %11, i32 noundef %1, i32 noundef %5, i64 noundef %8)
  %12 = or disjoint i32 %11, 1
  %13 = load i64, ptr %7, align 8, !tbaa !5
  tail call void @_Z4upd3iiix(i32 noundef %12, i32 noundef %5, i32 noundef %2, i64 noundef %13)
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %10, %3
  %15 = getelementptr inbounds [262144 x i64], ptr @lazy2, i64 0, i64 %6
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = icmp sgt i64 %16, 0
  %18 = shl nsw i32 %0, 1
  br i1 %17, label %19, label %._crit_edge

._crit_edge:                                      ; preds = %14
  %.pre32 = or disjoint i32 %18, 1
  br label %22

19:                                               ; preds = %14
  tail call void @_Z4upd2iiix(i32 noundef %18, i32 noundef %1, i32 noundef %5, i64 noundef %16)
  %20 = or disjoint i32 %18, 1
  %21 = load i64, ptr %15, align 8, !tbaa !5
  tail call void @_Z4upd2iiix(i32 noundef %20, i32 noundef %5, i32 noundef %2, i64 noundef %21)
  store i64 1, ptr %15, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %._crit_edge, %19
  %.pre-phi33 = phi i32 [ %.pre32, %._crit_edge ], [ %20, %19 ]
  %23 = getelementptr inbounds [262144 x i64], ptr @lazy1, i64 0, i64 %6
  %24 = load i64, ptr %23, align 8, !tbaa !5
  tail call void @_Z4upd1iiix(i32 noundef %18, i32 noundef %1, i32 noundef %5, i64 noundef %24)
  %25 = load i64, ptr %23, align 8, !tbaa !5
  tail call void @_Z4upd1iiix(i32 noundef %.pre-phi33, i32 noundef %5, i32 noundef %2, i64 noundef %25)
  store i64 0, ptr %23, align 8, !tbaa !5
  ret void
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass