; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/Random/DIVSUBS (A)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@a = external dso_local global [100100 x i32], align 16
@s = external dso_local global [100100 x i32], align 16
@f = external dso_local global [100100 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %8

8:                                                ; preds = %127, %0
  %9 = load i32, ptr @t, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr @t, align 4, !tbaa !5
  %11 = icmp ne i32 %9, 0
  br i1 %11, label %12, label %128

12:                                               ; preds = %8
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %27, %12
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = icmp sle i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %30

19:                                               ; preds = %14
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [100100 x i32], ptr @a, i64 0, i64 %21
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %22)
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100100 x i32], ptr @f, i64 0, i64 %25
  store i32 0, ptr %26, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %19
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

30:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %123, %30
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %34 = icmp sle i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  store i32 7, ptr %4, align 4
  br label %126

36:                                               ; preds = %31
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sub nsw i32 %37, 1
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100100 x i32], ptr @a, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = add nsw i32 %41, %45
  %47 = load i32, ptr @n, align 4, !tbaa !5
  %48 = srem i32 %46, %47
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %50
  store i32 %48, ptr %51, align 4, !tbaa !5
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %73

57:                                               ; preds = %36
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %58)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %68, %57
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = load i32, ptr %3, align 4, !tbaa !5
  %63 = icmp sle i32 %61, %62
  br i1 %63, label %65, label %64

64:                                               ; preds = %60
  store i32 10, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %71

65:                                               ; preds = %60
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %66)
  br label %68

68:                                               ; preds = %65
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %5, align 4, !tbaa !5
  br label %60, !llvm.loop !11

71:                                               ; preds = %64
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  store i32 7, ptr %4, align 4
  br label %126

73:                                               ; preds = %36
  %74 = load i32, ptr %3, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [100100 x i32], ptr @f, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = icmp sgt i32 %80, 0
  br i1 %81, label %82, label %114

82:                                               ; preds = %73
  %83 = load i32, ptr %3, align 4, !tbaa !5
  %84 = load i32, ptr %3, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [100100 x i32], ptr @f, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = sub nsw i32 %83, %90
  %92 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %91)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %93 = load i32, ptr %3, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [100100 x i32], ptr @f, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %6, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %109, %82
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = load i32, ptr %3, align 4, !tbaa !5
  %104 = icmp sle i32 %102, %103
  br i1 %104, label %106, label %105

105:                                              ; preds = %101
  store i32 13, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %112

106:                                              ; preds = %101
  %107 = load i32, ptr %6, align 4, !tbaa !5
  %108 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %107)
  br label %109

109:                                              ; preds = %106
  %110 = load i32, ptr %6, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %6, align 4, !tbaa !5
  br label %101, !llvm.loop !12

112:                                              ; preds = %105
  %113 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  store i32 7, ptr %4, align 4
  br label %126

114:                                              ; preds = %73
  br label %115

115:                                              ; preds = %114
  %116 = load i32, ptr %3, align 4, !tbaa !5
  %117 = load i32, ptr %3, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [100100 x i32], ptr @f, i64 0, i64 %121
  store i32 %116, ptr %122, align 4, !tbaa !5
  br label %123

123:                                              ; preds = %115
  %124 = load i32, ptr %3, align 4, !tbaa !5
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %3, align 4, !tbaa !5
  br label %31, !llvm.loop !13

126:                                              ; preds = %112, %71, %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %127

127:                                              ; preds = %126
  br label %8, !llvm.loop !14

128:                                              ; preds = %8
  ret i32 0
}

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

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

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

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

attributes #0 = { mustprogress norecurse 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !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"

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@a = external dso_local global [100100 x i32], align 16
@s = external dso_local local_unnamed_addr global [100100 x i32], align 16
@f = external dso_local local_unnamed_addr global [100100 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not50 = icmp eq i32 %2, 0
  br i1 %.not50, label %._crit_edge53, label %.lr.ph52

.lr.ph52:                                         ; preds = %0, %.loopexit
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not3140 = icmp slt i32 %5, 1
  br i1 %.not3140, label %.loopexit, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph
  %.not3243 = icmp slt i32 %10, 1
  br i1 %.not3243, label %.loopexit, label %.lr.ph45.preheader

.lr.ph45.preheader:                               ; preds = %.preheader
  %6 = add nuw i32 %10, 1
  %wide.trip.count = zext i32 %6 to i64
  %.pre = load i32, ptr @s, align 16, !tbaa !5
  br label %.lr.ph45

.lr.ph:                                           ; preds = %.lr.ph52, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph52 ]
  %7 = getelementptr inbounds [100100 x i32], ptr @a, i64 0, i64 %indvars.iv
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %7)
  %9 = getelementptr inbounds [100100 x i32], ptr @f, i64 0, i64 %indvars.iv
  store i32 0, ptr %9, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %.not31.not = icmp slt i64 %indvars.iv, %11
  br i1 %.not31.not, label %.lr.ph, label %.preheader, !llvm.loop !9

.lr.ph45:                                         ; preds = %.lr.ph45.preheader, %40
  %12 = phi i32 [ %.pre, %.lr.ph45.preheader ], [ %16, %40 ]
  %indvars.iv71 = phi i32 [ 2, %.lr.ph45.preheader ], [ %indvars.iv.next72, %40 ]
  %indvars.iv66 = phi i32 [ 1, %.lr.ph45.preheader ], [ %indvars.iv.next67, %40 ]
  %indvars.iv63 = phi i64 [ 1, %.lr.ph45.preheader ], [ %indvars.iv.next64, %40 ]
  %13 = getelementptr inbounds [100100 x i32], ptr @a, i64 0, i64 %indvars.iv63
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = add nsw i32 %14, %12
  %16 = srem i32 %15, %10
  %17 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %indvars.iv63
  store i32 %16, ptr %17, align 4, !tbaa !5
  %18 = icmp eq i32 %16, 0
  br i1 %18, label %19, label %25

19:                                               ; preds = %.lr.ph45
  %20 = trunc nuw nsw i64 %indvars.iv63 to i32
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %20)
  br label %22

22:                                               ; preds = %19, %22
  %.02549 = phi i32 [ 1, %19 ], [ %24, %22 ]
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.02549)
  %24 = add nuw i32 %.02549, 1
  %exitcond75.not = icmp eq i32 %24, %indvars.iv71
  br i1 %exitcond75.not, label %.loopexit.sink.split, label %22, !llvm.loop !11

25:                                               ; preds = %.lr.ph45
  %26 = sext i32 %16 to i64
  %27 = getelementptr inbounds [100100 x i32], ptr @f, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %30, label %40

30:                                               ; preds = %25
  %31 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %indvars.iv63
  %32 = trunc nuw nsw i64 %indvars.iv63 to i32
  %33 = sub nsw i32 %32, %28
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %33)
  %35 = load i32, ptr %31, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100100 x i32], ptr @f, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %.not33.not46 = icmp slt i32 %38, %32
  br i1 %.not33.not46, label %.lr.ph48, label %.loopexit.sink.split

.lr.ph48:                                         ; preds = %30, %.lr.ph48
  %.0.in47 = phi i32 [ %.0, %.lr.ph48 ], [ %38, %30 ]
  %.0 = add nsw i32 %.0.in47, 1
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.0)
  %exitcond70.not = icmp eq i32 %.0, %indvars.iv66
  br i1 %exitcond70.not, label %.loopexit.sink.split, label %.lr.ph48, !llvm.loop !12

40:                                               ; preds = %25
  %41 = trunc nuw nsw i64 %indvars.iv63 to i32
  store i32 %41, ptr %27, align 4, !tbaa !5
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next64, %wide.trip.count
  %indvars.iv.next67 = add nuw i32 %indvars.iv66, 1
  %indvars.iv.next72 = add nuw i32 %indvars.iv71, 1
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph45, !llvm.loop !13

.loopexit.sink.split:                             ; preds = %.lr.ph48, %22, %30
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %.loopexit

.loopexit:                                        ; preds = %40, %.loopexit.sink.split, %.lr.ph52, %.preheader
  %43 = load i32, ptr @t, align 4, !tbaa !5
  %44 = add nsw i32 %43, -1
  store i32 %44, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %43, 0
  br i1 %.not, label %._crit_edge53, label %.lr.ph52, !llvm.loop !14

._crit_edge53:                                    ; preds = %.loopexit, %0
  ret i32 0
}

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

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

attributes #0 = { mustprogress nofree norecurse 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 = { 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" }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


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