; LLVM IR from hanzohasashi33/Competetive_programming :: CodeChef/Contest (The_Operations)

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @myXOR(i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %13

13:                                               ; preds = %72, %0
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %16, label %78

16:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3)
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = zext i32 %18 to i64
  %20 = call ptr @llvm.stacksave.p0()
  store ptr %20, ptr %4, align 8
  %21 = alloca i32, i64 %19, align 16
  store i64 %19, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %32, %16
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %35

27:                                               ; preds = %22
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i32, ptr %21, i64 %29
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %30)
  br label %32

32:                                               ; preds = %27
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %6, align 4, !tbaa !5
  br label %22, !llvm.loop !9

35:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %69, %35
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  store i32 7, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %72

41:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %42 = load i32, ptr %8, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %10, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %65, %41
  %45 = load i32, ptr %10, align 4, !tbaa !5
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  store i32 10, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %68

49:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %50 = load i32, ptr %8, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i32, ptr %21, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = load i32, ptr %10, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr %21, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = call i32 @myXOR(i32 noundef %53, i32 noundef %57)
  store i32 %58, ptr %11, align 4, !tbaa !5
  %59 = load i32, ptr %11, align 4, !tbaa !5
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = icmp sgt i32 %59, %60
  br i1 %61, label %62, label %64

62:                                               ; preds = %49
  %63 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %63, ptr %7, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %62, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %10, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %10, align 4, !tbaa !5
  br label %44, !llvm.loop !11

68:                                               ; preds = %48
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %8, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %8, align 4, !tbaa !5
  br label %36, !llvm.loop !12

72:                                               ; preds = %40
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %73)
  %75 = load i32, ptr %2, align 4, !tbaa !5
  %76 = add nsw i32 %75, -1
  store i32 %76, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %77 = load ptr, ptr %4, align 8
  call void @llvm.stackrestore.p0(ptr %77)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %13, !llvm.loop !13

78:                                               ; preds = %13
  store i32 0, ptr %1, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %79 = load i32, ptr %1, align 4
  ret i32 %79
}

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

declare i32 @__isoc99_scanf(ptr noundef, ...) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

attributes #0 = { 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 = { "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 #3 = { nocallback nofree nosync nounwind willreturn }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @myXOR(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph28, label %._crit_edge29

.lr.ph28:                                         ; preds = %0, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = zext i32 %7 to i64
  %9 = call ptr @llvm.stacksave.p0()
  %10 = alloca i32, i64 %8, align 16
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph, label %._crit_edge

.preheader:                                       ; preds = %.lr.ph
  %13 = icmp sgt i32 %16, 0
  br i1 %13, label %.lr.ph25, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph28, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph28 ]
  %14 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %14)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = icmp slt i64 %indvars.iv.next, %17
  br i1 %18, label %.lr.ph, label %.preheader, !llvm.loop !9

.loopexit.loopexit:                               ; preds = %30
  %.pre = sext i32 %35 to i64
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.lr.ph25
  %.pre-phi = phi i64 [ %.pre, %.loopexit.loopexit ], [ %27, %.lr.ph25 ]
  %19 = phi i32 [ %35, %.loopexit.loopexit ], [ %26, %.lr.ph25 ]
  %.1.lcssa = phi i32 [ %spec.select, %.loopexit.loopexit ], [ %.01623, %.lr.ph25 ]
  %20 = icmp slt i64 %indvars.iv.next37, %.pre-phi
  %indvars.iv.next32 = add nuw nsw i64 %indvars.iv31, 1
  br i1 %20, label %.lr.ph25, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.loopexit, %.lr.ph28, %.preheader
  %.016.lcssa = phi i32 [ 0, %.preheader ], [ 0, %.lr.ph28 ], [ %.1.lcssa, %.loopexit ]
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.016.lcssa)
  %22 = load i32, ptr %1, align 4, !tbaa !5
  %23 = add nsw i32 %22, -1
  store i32 %23, ptr %1, align 4, !tbaa !5
  call void @llvm.stackrestore.p0(ptr %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %.lr.ph28, label %._crit_edge29, !llvm.loop !12

.lr.ph25:                                         ; preds = %.preheader, %.loopexit
  %26 = phi i32 [ %19, %.loopexit ], [ %16, %.preheader ]
  %indvars.iv36 = phi i64 [ %indvars.iv.next37, %.loopexit ], [ 0, %.preheader ]
  %indvars.iv31 = phi i64 [ %indvars.iv.next32, %.loopexit ], [ 1, %.preheader ]
  %.01623 = phi i32 [ %.1.lcssa, %.loopexit ], [ 0, %.preheader ]
  %indvars.iv.next37 = add nuw nsw i64 %indvars.iv36, 1
  %27 = sext i32 %26 to i64
  %28 = icmp slt i64 %indvars.iv.next37, %27
  br i1 %28, label %.lr.ph22, label %.loopexit

.lr.ph22:                                         ; preds = %.lr.ph25
  %29 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv36
  br label %30

30:                                               ; preds = %.lr.ph22, %30
  %indvars.iv33 = phi i64 [ %indvars.iv31, %.lr.ph22 ], [ %indvars.iv.next34, %30 ]
  %.120 = phi i32 [ %.01623, %.lr.ph22 ], [ %spec.select, %30 ]
  %31 = load i32, ptr %29, align 4, !tbaa !5
  %32 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv33
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = call i32 @myXOR(i32 noundef %31, i32 noundef %33)
  %spec.select = call i32 @llvm.smax.i32(i32 %34, i32 %.120)
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = trunc nuw i64 %indvars.iv.next34 to i32
  %37 = icmp sgt i32 %35, %36
  br i1 %37, label %30, label %.loopexit.loopexit, !llvm.loop !13

._crit_edge29:                                    ; preds = %._crit_edge, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #4

attributes #0 = { 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 = { nofree nounwind "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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass