; LLVM IR from tangjz/acm-icpc :: buaa/oj3rd (538)

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

@a = external dso_local global [2 x i8], align 1
@b = external dso_local global [2 x i8], align 1
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = 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
  store i32 0, ptr %1, align 4
  br label %2

2:                                                ; preds = %71, %0
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @a, ptr noundef @b)
  %4 = icmp eq i32 %3, 2
  br i1 %4, label %5, label %72

5:                                                ; preds = %2
  %6 = load i8, ptr @a, align 1, !tbaa !5
  %7 = sext i8 %6 to i32
  %8 = icmp eq i32 %7, 77
  br i1 %8, label %13, label %9

9:                                                ; preds = %5
  %10 = load i8, ptr @a, align 1, !tbaa !5
  %11 = sext i8 %10 to i32
  %12 = icmp eq i32 %11, 70
  br i1 %12, label %13, label %15

13:                                               ; preds = %9, %5
  %14 = call i32 @puts(ptr noundef @.str.1)
  br label %71

15:                                               ; preds = %9
  %16 = load i8, ptr @b, align 1, !tbaa !5
  %17 = sext i8 %16 to i32
  %18 = icmp eq i32 %17, 70
  br i1 %18, label %19, label %21

19:                                               ; preds = %15
  %20 = call i32 @puts(ptr noundef @.str.2)
  br label %70

21:                                               ; preds = %15
  %22 = load i8, ptr @a, align 1, !tbaa !5
  %23 = sext i8 %22 to i32
  %24 = icmp eq i32 %23, 66
  br i1 %24, label %29, label %25

25:                                               ; preds = %21
  %26 = load i8, ptr @b, align 1, !tbaa !5
  %27 = sext i8 %26 to i32
  %28 = icmp eq i32 %27, 66
  br i1 %28, label %29, label %31

29:                                               ; preds = %25, %21
  %30 = call i32 @puts(ptr noundef @.str.3)
  br label %69

31:                                               ; preds = %25
  %32 = load i8, ptr @a, align 1, !tbaa !5
  %33 = sext i8 %32 to i32
  %34 = icmp eq i32 %33, 57
  br i1 %34, label %35, label %41

35:                                               ; preds = %31
  %36 = load i8, ptr @b, align 1, !tbaa !5
  %37 = sext i8 %36 to i32
  %38 = icmp eq i32 %37, 77
  br i1 %38, label %39, label %41

39:                                               ; preds = %35
  %40 = call i32 @puts(ptr noundef @.str.4)
  br label %68

41:                                               ; preds = %35, %31
  %42 = load i8, ptr @b, align 1, !tbaa !5
  %43 = sext i8 %42 to i32
  %44 = icmp eq i32 %43, 77
  br i1 %44, label %45, label %47

45:                                               ; preds = %41
  %46 = call i32 @puts(ptr noundef @.str.5)
  br label %67

47:                                               ; preds = %41
  %48 = load i8, ptr @a, align 1, !tbaa !5
  %49 = sext i8 %48 to i32
  %50 = load i8, ptr @b, align 1, !tbaa !5
  %51 = sext i8 %50 to i32
  %52 = icmp sgt i32 %49, %51
  br i1 %52, label %53, label %55

53:                                               ; preds = %47
  %54 = call i32 @puts(ptr noundef @.str.5)
  br label %66

55:                                               ; preds = %47
  %56 = load i8, ptr @a, align 1, !tbaa !5
  %57 = sext i8 %56 to i32
  %58 = load i8, ptr @b, align 1, !tbaa !5
  %59 = sext i8 %58 to i32
  %60 = icmp eq i32 %57, %59
  br i1 %60, label %61, label %63

61:                                               ; preds = %55
  %62 = call i32 @puts(ptr noundef @.str.3)
  br label %65

63:                                               ; preds = %55
  %64 = call i32 @puts(ptr noundef @.str.4)
  br label %65

65:                                               ; preds = %63, %61
  br label %66

66:                                               ; preds = %65, %53
  br label %67

67:                                               ; preds = %66, %45
  br label %68

68:                                               ; preds = %67, %39
  br label %69

69:                                               ; preds = %68, %29
  br label %70

70:                                               ; preds = %69, %19
  br label %71

71:                                               ; preds = %70, %13
  br label %2, !llvm.loop !8

72:                                               ; preds = %2
  ret i32 0
}

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

declare i32 @puts(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" }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"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"

@a = external dso_local global [2 x i8], align 1
@b = external dso_local global [2 x i8], align 1
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = 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 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a, ptr noundef nonnull @b)
  %2 = icmp eq i32 %1, 2
  br i1 %2, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %17
  %3 = load i8, ptr @a, align 1
  switch i8 %3, label %4 [
    i8 77, label %17
    i8 70, label %17
  ]

4:                                                ; preds = %.lr.ph
  %5 = load i8, ptr @b, align 1
  %6 = icmp eq i8 %5, 70
  br i1 %6, label %17, label %7

7:                                                ; preds = %4
  %8 = icmp eq i8 %3, 66
  %9 = icmp eq i8 %5, 66
  %or.cond5 = or i1 %8, %9
  br i1 %or.cond5, label %17, label %10

10:                                               ; preds = %7
  %11 = icmp eq i8 %3, 57
  %12 = icmp eq i8 %5, 77
  %or.cond8 = and i1 %11, %12
  %.str.4.mux = select i1 %or.cond8, ptr @.str.4, ptr @.str.5
  br i1 %12, label %17, label %13

13:                                               ; preds = %10
  %14 = icmp sgt i8 %3, %5
  br i1 %14, label %17, label %15

15:                                               ; preds = %13
  %16 = icmp eq i8 %3, %5
  %.str.3..str.4 = select i1 %16, ptr @.str.3, ptr @.str.4
  br label %17

17:                                               ; preds = %10, %15, %13, %7, %4, %.lr.ph, %.lr.ph
  %.str.2.sink = phi ptr [ @.str.1, %.lr.ph ], [ @.str.1, %.lr.ph ], [ @.str.2, %4 ], [ @.str.3, %7 ], [ %.str.4.mux, %10 ], [ @.str.5, %13 ], [ %.str.3..str.4, %15 ]
  %18 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
  %19 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a, ptr noundef nonnull @b)
  %20 = icmp eq i32 %19, 2
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %17, %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 @puts(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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass