; LLVM IR from DionysiosB/CodeForces :: 0300-0399 (378A-PlayingWithDice)

; 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 [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %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
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %49, %0
  %10 = load i32, ptr %7, align 4, !tbaa !5
  %11 = icmp sle i32 %10, 6
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %52

13:                                               ; preds = %9
  %14 = load i32, ptr %7, align 4, !tbaa !5
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = call noundef i32 @_Z4distii(i32 noundef %14, i32 noundef %15)
  %17 = load i32, ptr %7, align 4, !tbaa !5
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = call noundef i32 @_Z4distii(i32 noundef %17, i32 noundef %18)
  %20 = icmp slt i32 %16, %19
  br i1 %20, label %21, label %24

21:                                               ; preds = %13
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %4, align 4, !tbaa !5
  br label %48

24:                                               ; preds = %13
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = call noundef i32 @_Z4distii(i32 noundef %25, i32 noundef %26)
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = call noundef i32 @_Z4distii(i32 noundef %28, i32 noundef %29)
  %31 = icmp eq i32 %27, %30
  br i1 %31, label %32, label %35

32:                                               ; preds = %24
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %5, align 4, !tbaa !5
  br label %47

35:                                               ; preds = %24
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = call noundef i32 @_Z4distii(i32 noundef %36, i32 noundef %37)
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = call noundef i32 @_Z4distii(i32 noundef %39, i32 noundef %40)
  %42 = icmp sgt i32 %38, %41
  br i1 %42, label %43, label %46

43:                                               ; preds = %35
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %6, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %43, %35
  br label %47

47:                                               ; preds = %46, %32
  br label %48

48:                                               ; preds = %47, %21
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %7, align 4, !tbaa !5
  br label %9, !llvm.loop !9

52:                                               ; preds = %12
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %53, i32 noundef %54, i32 noundef %55)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

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

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

; 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, ...) #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 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 #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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"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"

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1

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

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = call noundef i32 @_Z4distii(i32 noundef 1, i32 noundef %4)
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = call noundef i32 @_Z4distii(i32 noundef 1, i32 noundef %6)
  %8 = icmp slt i32 %5, %7
  br i1 %8, label %22, label %9

9:                                                ; preds = %0
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = call noundef i32 @_Z4distii(i32 noundef 1, i32 noundef %10)
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = call noundef i32 @_Z4distii(i32 noundef 1, i32 noundef %12)
  %14 = icmp eq i32 %11, %13
  br i1 %14, label %22, label %15

15:                                               ; preds = %9
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = call noundef i32 @_Z4distii(i32 noundef 1, i32 noundef %16)
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = call noundef i32 @_Z4distii(i32 noundef 1, i32 noundef %18)
  %20 = icmp sgt i32 %17, %19
  %21 = zext i1 %20 to i32
  br label %22

22:                                               ; preds = %9, %0, %15
  %.118 = phi i32 [ 0, %15 ], [ 1, %0 ], [ 0, %9 ]
  %.116 = phi i32 [ 0, %15 ], [ 0, %0 ], [ 1, %9 ]
  %.1 = phi i32 [ %21, %15 ], [ 0, %0 ], [ 0, %9 ]
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = call noundef i32 @_Z4distii(i32 noundef 2, i32 noundef %23)
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = call noundef i32 @_Z4distii(i32 noundef 2, i32 noundef %25)
  %27 = icmp slt i32 %24, %26
  br i1 %27, label %43, label %28

28:                                               ; preds = %22
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = call noundef i32 @_Z4distii(i32 noundef 2, i32 noundef %29)
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = call noundef i32 @_Z4distii(i32 noundef 2, i32 noundef %31)
  %33 = icmp eq i32 %30, %32
  br i1 %33, label %41, label %34

34:                                               ; preds = %28
  %35 = load i32, ptr %1, align 4, !tbaa !5
  %36 = call noundef i32 @_Z4distii(i32 noundef 2, i32 noundef %35)
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = call noundef i32 @_Z4distii(i32 noundef 2, i32 noundef %37)
  %39 = icmp sgt i32 %36, %38
  %40 = zext i1 %39 to i32
  %spec.select.1 = add nuw nsw i32 %.1, %40
  br label %45

41:                                               ; preds = %28
  %42 = add nuw nsw i32 %.116, 1
  br label %45

43:                                               ; preds = %22
  %44 = add nuw nsw i32 %.118, 1
  br label %45

45:                                               ; preds = %43, %41, %34
  %.118.1 = phi i32 [ %44, %43 ], [ %.118, %41 ], [ %.118, %34 ]
  %.116.1 = phi i32 [ %.116, %43 ], [ %42, %41 ], [ %.116, %34 ]
  %.1.1 = phi i32 [ %.1, %43 ], [ %.1, %41 ], [ %spec.select.1, %34 ]
  %46 = load i32, ptr %1, align 4, !tbaa !5
  %47 = call noundef i32 @_Z4distii(i32 noundef 3, i32 noundef %46)
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = call noundef i32 @_Z4distii(i32 noundef 3, i32 noundef %48)
  %50 = icmp slt i32 %47, %49
  br i1 %50, label %66, label %51

51:                                               ; preds = %45
  %52 = load i32, ptr %1, align 4, !tbaa !5
  %53 = call noundef i32 @_Z4distii(i32 noundef 3, i32 noundef %52)
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = call noundef i32 @_Z4distii(i32 noundef 3, i32 noundef %54)
  %56 = icmp eq i32 %53, %55
  br i1 %56, label %64, label %57

57:                                               ; preds = %51
  %58 = load i32, ptr %1, align 4, !tbaa !5
  %59 = call noundef i32 @_Z4distii(i32 noundef 3, i32 noundef %58)
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = call noundef i32 @_Z4distii(i32 noundef 3, i32 noundef %60)
  %62 = icmp sgt i32 %59, %61
  %63 = zext i1 %62 to i32
  %spec.select.2 = add nuw nsw i32 %.1.1, %63
  br label %68

64:                                               ; preds = %51
  %65 = add nuw nsw i32 %.116.1, 1
  br label %68

66:                                               ; preds = %45
  %67 = add nuw nsw i32 %.118.1, 1
  br label %68

68:                                               ; preds = %66, %64, %57
  %.118.2 = phi i32 [ %67, %66 ], [ %.118.1, %64 ], [ %.118.1, %57 ]
  %.116.2 = phi i32 [ %.116.1, %66 ], [ %65, %64 ], [ %.116.1, %57 ]
  %.1.2 = phi i32 [ %.1.1, %66 ], [ %.1.1, %64 ], [ %spec.select.2, %57 ]
  %69 = load i32, ptr %1, align 4, !tbaa !5
  %70 = call noundef i32 @_Z4distii(i32 noundef 4, i32 noundef %69)
  %71 = load i32, ptr %2, align 4, !tbaa !5
  %72 = call noundef i32 @_Z4distii(i32 noundef 4, i32 noundef %71)
  %73 = icmp slt i32 %70, %72
  br i1 %73, label %89, label %74

74:                                               ; preds = %68
  %75 = load i32, ptr %1, align 4, !tbaa !5
  %76 = call noundef i32 @_Z4distii(i32 noundef 4, i32 noundef %75)
  %77 = load i32, ptr %2, align 4, !tbaa !5
  %78 = call noundef i32 @_Z4distii(i32 noundef 4, i32 noundef %77)
  %79 = icmp eq i32 %76, %78
  br i1 %79, label %87, label %80

80:                                               ; preds = %74
  %81 = load i32, ptr %1, align 4, !tbaa !5
  %82 = call noundef i32 @_Z4distii(i32 noundef 4, i32 noundef %81)
  %83 = load i32, ptr %2, align 4, !tbaa !5
  %84 = call noundef i32 @_Z4distii(i32 noundef 4, i32 noundef %83)
  %85 = icmp sgt i32 %82, %84
  %86 = zext i1 %85 to i32
  %spec.select.3 = add nuw nsw i32 %.1.2, %86
  br label %91

87:                                               ; preds = %74
  %88 = add nuw nsw i32 %.116.2, 1
  br label %91

89:                                               ; preds = %68
  %90 = add nuw nsw i32 %.118.2, 1
  br label %91

91:                                               ; preds = %89, %87, %80
  %.118.3 = phi i32 [ %90, %89 ], [ %.118.2, %87 ], [ %.118.2, %80 ]
  %.116.3 = phi i32 [ %.116.2, %89 ], [ %88, %87 ], [ %.116.2, %80 ]
  %.1.3 = phi i32 [ %.1.2, %89 ], [ %.1.2, %87 ], [ %spec.select.3, %80 ]
  %92 = load i32, ptr %1, align 4, !tbaa !5
  %93 = call noundef i32 @_Z4distii(i32 noundef 5, i32 noundef %92)
  %94 = load i32, ptr %2, align 4, !tbaa !5
  %95 = call noundef i32 @_Z4distii(i32 noundef 5, i32 noundef %94)
  %96 = icmp slt i32 %93, %95
  br i1 %96, label %112, label %97

97:                                               ; preds = %91
  %98 = load i32, ptr %1, align 4, !tbaa !5
  %99 = call noundef i32 @_Z4distii(i32 noundef 5, i32 noundef %98)
  %100 = load i32, ptr %2, align 4, !tbaa !5
  %101 = call noundef i32 @_Z4distii(i32 noundef 5, i32 noundef %100)
  %102 = icmp eq i32 %99, %101
  br i1 %102, label %110, label %103

103:                                              ; preds = %97
  %104 = load i32, ptr %1, align 4, !tbaa !5
  %105 = call noundef i32 @_Z4distii(i32 noundef 5, i32 noundef %104)
  %106 = load i32, ptr %2, align 4, !tbaa !5
  %107 = call noundef i32 @_Z4distii(i32 noundef 5, i32 noundef %106)
  %108 = icmp sgt i32 %105, %107
  %109 = zext i1 %108 to i32
  %spec.select.4 = add nuw nsw i32 %.1.3, %109
  br label %114

110:                                              ; preds = %97
  %111 = add nuw nsw i32 %.116.3, 1
  br label %114

112:                                              ; preds = %91
  %113 = add nuw nsw i32 %.118.3, 1
  br label %114

114:                                              ; preds = %112, %110, %103
  %.118.4 = phi i32 [ %113, %112 ], [ %.118.3, %110 ], [ %.118.3, %103 ]
  %.116.4 = phi i32 [ %.116.3, %112 ], [ %111, %110 ], [ %.116.3, %103 ]
  %.1.4 = phi i32 [ %.1.3, %112 ], [ %.1.3, %110 ], [ %spec.select.4, %103 ]
  %115 = load i32, ptr %1, align 4, !tbaa !5
  %116 = call noundef i32 @_Z4distii(i32 noundef 6, i32 noundef %115)
  %117 = load i32, ptr %2, align 4, !tbaa !5
  %118 = call noundef i32 @_Z4distii(i32 noundef 6, i32 noundef %117)
  %119 = icmp slt i32 %116, %118
  br i1 %119, label %135, label %120

120:                                              ; preds = %114
  %121 = load i32, ptr %1, align 4, !tbaa !5
  %122 = call noundef i32 @_Z4distii(i32 noundef 6, i32 noundef %121)
  %123 = load i32, ptr %2, align 4, !tbaa !5
  %124 = call noundef i32 @_Z4distii(i32 noundef 6, i32 noundef %123)
  %125 = icmp eq i32 %122, %124
  br i1 %125, label %133, label %126

126:                                              ; preds = %120
  %127 = load i32, ptr %1, align 4, !tbaa !5
  %128 = call noundef i32 @_Z4distii(i32 noundef 6, i32 noundef %127)
  %129 = load i32, ptr %2, align 4, !tbaa !5
  %130 = call noundef i32 @_Z4distii(i32 noundef 6, i32 noundef %129)
  %131 = icmp sgt i32 %128, %130
  %132 = zext i1 %131 to i32
  %spec.select.5 = add nuw nsw i32 %.1.4, %132
  br label %137

133:                                              ; preds = %120
  %134 = add nuw nsw i32 %.116.4, 1
  br label %137

135:                                              ; preds = %114
  %136 = add nuw nsw i32 %.118.4, 1
  br label %137

137:                                              ; preds = %135, %133, %126
  %.118.5 = phi i32 [ %136, %135 ], [ %.118.4, %133 ], [ %.118.4, %126 ]
  %.116.5 = phi i32 [ %.116.4, %135 ], [ %134, %133 ], [ %.116.4, %126 ]
  %.1.5 = phi i32 [ %.1.4, %135 ], [ %.1.4, %133 ], [ %spec.select.5, %126 ]
  %138 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.118.5, i32 noundef %.116.5, i32 noundef %.1.5)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0
}

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass