; LLVM IR from Shah-Shishir/Codeforces-Solutions :: 253A. Boys and Girls (main)

; 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 [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = 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 = load ptr, ptr @stdin, align 8, !tbaa !5
  %8 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %7)
  %9 = load ptr, ptr @stdout, align 8, !tbaa !5
  %10 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %9)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  br label %11

11:                                               ; preds = %80, %0
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %2, ptr noundef %3)
  %13 = icmp ne i32 %12, -1
  br i1 %13, label %14, label %82

14:                                               ; preds = %11
  %15 = load i32, ptr %2, align 4, !tbaa !9
  %16 = load i32, ptr %3, align 4, !tbaa !9
  %17 = icmp eq i32 %15, %16
  br i1 %17, label %18, label %29

18:                                               ; preds = %14
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %25, %18
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = load i32, ptr %2, align 4, !tbaa !9
  %22 = icmp sle i32 %20, %21
  br i1 %22, label %23, label %28

23:                                               ; preds = %19
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %25

25:                                               ; preds = %23
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %4, align 4, !tbaa !9
  br label %19, !llvm.loop !11

28:                                               ; preds = %19
  br label %80

29:                                               ; preds = %14
  %30 = load i32, ptr %2, align 4, !tbaa !9
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = icmp sgt i32 %30, %31
  br i1 %32, label %33, label %56

33:                                               ; preds = %29
  %34 = load i32, ptr %3, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %4, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %42, %33
  %37 = load i32, ptr %4, align 4, !tbaa !9
  %38 = load i32, ptr %2, align 4, !tbaa !9
  %39 = icmp sle i32 %37, %38
  br i1 %39, label %40, label %45

40:                                               ; preds = %36
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  br label %42

42:                                               ; preds = %40
  %43 = load i32, ptr %4, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %4, align 4, !tbaa !9
  br label %36, !llvm.loop !13

45:                                               ; preds = %36
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %52, %45
  %47 = load i32, ptr %4, align 4, !tbaa !9
  %48 = load i32, ptr %3, align 4, !tbaa !9
  %49 = icmp sle i32 %47, %48
  br i1 %49, label %50, label %55

50:                                               ; preds = %46
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %52

52:                                               ; preds = %50
  %53 = load i32, ptr %4, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %4, align 4, !tbaa !9
  br label %46, !llvm.loop !14

55:                                               ; preds = %46
  br label %79

56:                                               ; preds = %29
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %63, %56
  %58 = load i32, ptr %4, align 4, !tbaa !9
  %59 = load i32, ptr %2, align 4, !tbaa !9
  %60 = icmp sle i32 %58, %59
  br i1 %60, label %61, label %66

61:                                               ; preds = %57
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %63

63:                                               ; preds = %61
  %64 = load i32, ptr %4, align 4, !tbaa !9
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %4, align 4, !tbaa !9
  br label %57, !llvm.loop !15

66:                                               ; preds = %57
  %67 = load i32, ptr %2, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %4, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %75, %66
  %70 = load i32, ptr %4, align 4, !tbaa !9
  %71 = load i32, ptr %3, align 4, !tbaa !9
  %72 = icmp sle i32 %70, %71
  br i1 %72, label %73, label %78

73:                                               ; preds = %69
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %75

75:                                               ; preds = %73
  %76 = load i32, ptr %4, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %4, align 4, !tbaa !9
  br label %69, !llvm.loop !16

78:                                               ; preds = %69
  br label %79

79:                                               ; preds = %78, %55
  br label %80

80:                                               ; preds = %79, %28
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %11, !llvm.loop !17

82:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret i32 0
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #1

; 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, ...) #1

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

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

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !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 [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = load ptr, ptr @stdin, align 8, !tbaa !5
  %4 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %3)
  %5 = load ptr, ptr @stdout, align 8, !tbaa !5
  %6 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %.not38 = icmp eq i32 %7, -1
  br i1 %.not38, label %._crit_edge, label %.lr.ph39

.lr.ph39:                                         ; preds = %0, %.loopexit
  %8 = load i32, ptr %1, align 4, !tbaa !9
  %9 = load i32, ptr %2, align 4, !tbaa !9
  %10 = icmp eq i32 %8, %9
  br i1 %10, label %.preheader, label %14

.preheader:                                       ; preds = %.lr.ph39
  %.not1735 = icmp slt i32 %8, 1
  br i1 %.not1735, label %.loopexit, label %.lr.ph37

.lr.ph37:                                         ; preds = %.preheader, %.lr.ph37
  %.036 = phi i32 [ %12, %.lr.ph37 ], [ 1, %.preheader ]
  %11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %12 = add nuw nsw i32 %.036, 1
  %13 = load i32, ptr %1, align 4, !tbaa !9
  %.not17.not = icmp slt i32 %.036, %13
  br i1 %.not17.not, label %.lr.ph37, label %.loopexit, !llvm.loop !11

14:                                               ; preds = %.lr.ph39
  %15 = icmp sgt i32 %8, %9
  br i1 %15, label %.lr.ph31, label %.preheader23

.preheader23:                                     ; preds = %14
  %.not1324 = icmp slt i32 %8, 1
  br i1 %.not1324, label %.preheader21, label %.lr.ph

.preheader18:                                     ; preds = %.lr.ph31
  %.pre43 = load i32, ptr %2, align 4, !tbaa !9
  %.not1632 = icmp slt i32 %.pre43, 1
  br i1 %.not1632, label %.loopexit, label %.lr.ph34

.lr.ph31:                                         ; preds = %14, %.lr.ph31
  %.1.in30 = phi i32 [ %.1, %.lr.ph31 ], [ %9, %14 ]
  %.1 = add nsw i32 %.1.in30, 1
  %16 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %17 = load i32, ptr %1, align 4, !tbaa !9
  %.not15.not = icmp slt i32 %.1, %17
  br i1 %.not15.not, label %.lr.ph31, label %.preheader18, !llvm.loop !13

.lr.ph34:                                         ; preds = %.preheader18, %.lr.ph34
  %.233 = phi i32 [ %19, %.lr.ph34 ], [ 1, %.preheader18 ]
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %19 = add nuw nsw i32 %.233, 1
  %20 = load i32, ptr %2, align 4, !tbaa !9
  %.not16.not = icmp slt i32 %.233, %20
  br i1 %.not16.not, label %.lr.ph34, label %.loopexit, !llvm.loop !14

.preheader21.loopexit:                            ; preds = %.lr.ph
  %.pre = load i32, ptr %2, align 4, !tbaa !9
  br label %.preheader21

.preheader21:                                     ; preds = %.preheader21.loopexit, %.preheader23
  %21 = phi i32 [ %9, %.preheader23 ], [ %.pre, %.preheader21.loopexit ]
  %.lcssa = phi i32 [ %8, %.preheader23 ], [ %24, %.preheader21.loopexit ]
  %.not14.not26 = icmp slt i32 %.lcssa, %21
  br i1 %.not14.not26, label %.lr.ph28, label %.loopexit

.lr.ph:                                           ; preds = %.preheader23, %.lr.ph
  %.325 = phi i32 [ %23, %.lr.ph ], [ 1, %.preheader23 ]
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %23 = add nuw nsw i32 %.325, 1
  %24 = load i32, ptr %1, align 4, !tbaa !9
  %.not13.not = icmp slt i32 %.325, %24
  br i1 %.not13.not, label %.lr.ph, label %.preheader21.loopexit, !llvm.loop !15

.lr.ph28:                                         ; preds = %.preheader21, %.lr.ph28
  %.4.in27 = phi i32 [ %.4, %.lr.ph28 ], [ %.lcssa, %.preheader21 ]
  %.4 = add nsw i32 %.4.in27, 1
  %25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %26 = load i32, ptr %2, align 4, !tbaa !9
  %.not14.not = icmp slt i32 %.4, %26
  br i1 %.not14.not, label %.lr.ph28, label %.loopexit, !llvm.loop !16

.loopexit:                                        ; preds = %.lr.ph28, %.lr.ph34, %.lr.ph37, %.preheader21, %.preheader18, %.preheader
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %.not = icmp eq i32 %28, -1
  br i1 %.not, label %._crit_edge, label %.lr.ph39, !llvm.loop !17

._crit_edge:                                      ; preds = %.loopexit, %0
  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
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; 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: nofree nounwind
declare noundef i32 @printf(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

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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass