; LLVM IR from DionysiosB/CodeForces :: 0900-0999 (907A-MashaAndBears)

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i8, align 1
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #3
  store i8 1, ptr %12, align 1, !tbaa !5
  %17 = load i64, ptr %2, align 8, !tbaa !9
  store i64 %17, ptr %6, align 8, !tbaa !9
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = mul nsw i64 2, %19
  %21 = icmp sle i64 %18, %20
  br i1 %21, label %22, label %26

22:                                               ; preds = %0
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = mul nsw i64 2, %23
  %25 = add nsw i64 %24, 1
  store i64 %25, ptr %6, align 8, !tbaa !9
  br label %26

26:                                               ; preds = %22, %0
  %27 = load i64, ptr %2, align 8, !tbaa !9
  %28 = mul nsw i64 2, %27
  store i64 %28, ptr %9, align 8, !tbaa !9
  %29 = load i64, ptr %4, align 8, !tbaa !9
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = icmp sgt i64 %29, %30
  br i1 %31, label %32, label %34

32:                                               ; preds = %26
  %33 = load i64, ptr %4, align 8, !tbaa !9
  br label %36

34:                                               ; preds = %26
  %35 = load i64, ptr %5, align 8, !tbaa !9
  br label %36

36:                                               ; preds = %34, %32
  %37 = phi i64 [ %33, %32 ], [ %35, %34 ]
  store i64 %37, ptr %8, align 8, !tbaa !9
  %38 = load i64, ptr %4, align 8, !tbaa !9
  %39 = load i64, ptr %5, align 8, !tbaa !9
  %40 = icmp slt i64 %38, %39
  br i1 %40, label %41, label %43

41:                                               ; preds = %36
  %42 = load i64, ptr %4, align 8, !tbaa !9
  br label %45

43:                                               ; preds = %36
  %44 = load i64, ptr %5, align 8, !tbaa !9
  br label %45

45:                                               ; preds = %43, %41
  %46 = phi i64 [ %42, %41 ], [ %44, %43 ]
  %47 = mul nsw i64 2, %46
  store i64 %47, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %48 = load i64, ptr %6, align 8, !tbaa !9
  %49 = load i64, ptr %9, align 8, !tbaa !9
  %50 = icmp sgt i64 %48, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %45
  store i8 0, ptr %12, align 1, !tbaa !5
  br label %54

52:                                               ; preds = %45
  %53 = load i64, ptr %9, align 8, !tbaa !9
  store i64 %53, ptr %13, align 8, !tbaa !9
  br label %54

54:                                               ; preds = %52, %51
  %55 = load i64, ptr %8, align 8, !tbaa !9
  %56 = load i64, ptr %11, align 8, !tbaa !9
  %57 = icmp sgt i64 %55, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %54
  store i8 0, ptr %12, align 1, !tbaa !5
  br label %61

59:                                               ; preds = %54
  %60 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %60, ptr %15, align 8, !tbaa !9
  br label %61

61:                                               ; preds = %59, %58
  %62 = load i64, ptr %3, align 8, !tbaa !9
  store i64 %62, ptr %7, align 8, !tbaa !9
  %63 = load i64, ptr %7, align 8, !tbaa !9
  %64 = load i64, ptr %5, align 8, !tbaa !9
  %65 = mul nsw i64 2, %64
  %66 = icmp sle i64 %63, %65
  br i1 %66, label %67, label %71

67:                                               ; preds = %61
  %68 = load i64, ptr %5, align 8, !tbaa !9
  %69 = mul nsw i64 2, %68
  %70 = add nsw i64 %69, 1
  store i64 %70, ptr %7, align 8, !tbaa !9
  br label %71

71:                                               ; preds = %67, %61
  %72 = load i64, ptr %7, align 8, !tbaa !9
  %73 = load i64, ptr %15, align 8, !tbaa !9
  %74 = add nsw i64 %73, 1
  %75 = icmp sge i64 %72, %74
  br i1 %75, label %76, label %78

76:                                               ; preds = %71
  %77 = load i64, ptr %7, align 8, !tbaa !9
  br label %81

78:                                               ; preds = %71
  %79 = load i64, ptr %15, align 8, !tbaa !9
  %80 = add nsw i64 %79, 1
  br label %81

81:                                               ; preds = %78, %76
  %82 = phi i64 [ %77, %76 ], [ %80, %78 ]
  store i64 %82, ptr %7, align 8, !tbaa !9
  %83 = load i64, ptr %3, align 8, !tbaa !9
  %84 = mul nsw i64 2, %83
  store i64 %84, ptr %10, align 8, !tbaa !9
  %85 = load i64, ptr %10, align 8, !tbaa !9
  %86 = load i64, ptr %13, align 8, !tbaa !9
  %87 = sub nsw i64 %86, 1
  %88 = icmp sle i64 %85, %87
  br i1 %88, label %89, label %91

89:                                               ; preds = %81
  %90 = load i64, ptr %10, align 8, !tbaa !9
  br label %94

91:                                               ; preds = %81
  %92 = load i64, ptr %13, align 8, !tbaa !9
  %93 = sub nsw i64 %92, 1
  br label %94

94:                                               ; preds = %91, %89
  %95 = phi i64 [ %90, %89 ], [ %93, %91 ]
  store i64 %95, ptr %10, align 8, !tbaa !9
  %96 = load i64, ptr %7, align 8, !tbaa !9
  %97 = load i64, ptr %10, align 8, !tbaa !9
  %98 = icmp sgt i64 %96, %97
  br i1 %98, label %99, label %100

99:                                               ; preds = %94
  store i8 0, ptr %12, align 1, !tbaa !5
  br label %102

100:                                              ; preds = %94
  %101 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %101, ptr %14, align 8, !tbaa !9
  br label %102

102:                                              ; preds = %100, %99
  %103 = load i8, ptr %12, align 1, !tbaa !5, !range !11, !noundef !12
  %104 = trunc i8 %103 to i1
  br i1 %104, label %105, label %110

105:                                              ; preds = %102
  %106 = load i64, ptr %13, align 8, !tbaa !9
  %107 = load i64, ptr %14, align 8, !tbaa !9
  %108 = load i64, ptr %15, align 8, !tbaa !9
  %109 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %106, i64 noundef %107, i64 noundef %108)
  br label %112

110:                                              ; preds = %102
  %111 = call i32 @puts(ptr noundef @.str.2)
  br label %112

112:                                              ; preds = %110, %105
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  ret i32 0
}

; 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

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

declare i32 @puts(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{i8 0, i8 2}
!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"

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

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %6 = load i64, ptr %1, align 8, !tbaa !5
  %7 = load i64, ptr %4, align 8
  %8 = shl nsw i64 %7, 1
  %.not = icmp sgt i64 %6, %8
  %9 = or disjoint i64 %8, 1
  %spec.select = select i1 %.not, i64 %6, i64 %9
  %10 = shl nsw i64 %6, 1
  %11 = load i64, ptr %3, align 8
  %12 = call i64 @llvm.smax.i64(i64 %11, i64 %7)
  %13 = call i64 @llvm.smin.i64(i64 %11, i64 %7)
  %14 = shl nsw i64 %13, 1
  %15 = icmp sgt i64 %spec.select, %10
  %16 = icmp sgt i64 %12, %14
  %17 = load i64, ptr %2, align 8, !tbaa !5
  %.not31 = icmp sgt i64 %17, %8
  %.027 = select i1 %.not31, i64 %17, i64 %9
  %18 = add nsw i64 %12, 1
  %19 = call i64 @llvm.smax.i64(i64 %.027, i64 %18)
  %20 = shl nsw i64 %17, 1
  %21 = add nsw i64 %10, -1
  %22 = call i64 @llvm.smin.i64(i64 %20, i64 %21)
  %23 = icmp sgt i64 %19, %22
  %24 = select i1 %23, i1 true, i1 %16
  %brmerge = select i1 %24, i1 true, i1 %15
  br i1 %brmerge, label %.critedge, label %25

25:                                               ; preds = %0
  %26 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %10, i64 noundef %19, i64 noundef %12)
  br label %28

.critedge:                                        ; preds = %0
  %27 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %28

28:                                               ; preds = %.critedge, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, 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) #1

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

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #3

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass