; LLVM IR from tangjz/acm-icpc :: codeforces/gym (100540K)

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

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

5:                                                ; preds = %2
  %6 = load i32, ptr @a, align 4, !tbaa !5
  %7 = load i32, ptr @b, align 4, !tbaa !5
  %8 = add nsw i32 %6, %7
  %9 = load i32, ptr @c, align 4, !tbaa !5
  %10 = add nsw i32 %8, %9
  %11 = icmp ne i32 %10, 0
  br label %12

12:                                               ; preds = %5, %2
  %13 = phi i1 [ false, %2 ], [ %11, %5 ]
  br i1 %13, label %14, label %106

14:                                               ; preds = %12
  %15 = load i32, ptr @a, align 4, !tbaa !5
  %16 = load i32, ptr @b, align 4, !tbaa !5
  %17 = icmp eq i32 %15, %16
  br i1 %17, label %18, label %37

18:                                               ; preds = %14
  %19 = load i32, ptr @b, align 4, !tbaa !5
  %20 = load i32, ptr @c, align 4, !tbaa !5
  %21 = icmp eq i32 %19, %20
  br i1 %21, label %22, label %37

22:                                               ; preds = %18
  %23 = load i32, ptr @a, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  %25 = icmp sle i32 %24, 13
  br i1 %25, label %26, label %34

26:                                               ; preds = %22
  %27 = load i32, ptr @a, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  %29 = load i32, ptr @b, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  %31 = load i32, ptr @c, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %28, i32 noundef %30, i32 noundef %32)
  br label %36

34:                                               ; preds = %22
  %35 = call i32 @puts(ptr noundef @.str.2)
  br label %36

36:                                               ; preds = %34, %26
  br label %105

37:                                               ; preds = %18, %14
  %38 = load i32, ptr @a, align 4, !tbaa !5
  %39 = load i32, ptr @b, align 4, !tbaa !5
  %40 = icmp eq i32 %38, %39
  br i1 %40, label %49, label %41

41:                                               ; preds = %37
  %42 = load i32, ptr @a, align 4, !tbaa !5
  %43 = load i32, ptr @c, align 4, !tbaa !5
  %44 = icmp eq i32 %42, %43
  br i1 %44, label %49, label %45

45:                                               ; preds = %41
  %46 = load i32, ptr @b, align 4, !tbaa !5
  %47 = load i32, ptr @c, align 4, !tbaa !5
  %48 = icmp eq i32 %46, %47
  br i1 %48, label %49, label %102

49:                                               ; preds = %45, %41, %37
  %50 = load i32, ptr @a, align 4, !tbaa !5
  %51 = load i32, ptr @b, align 4, !tbaa !5
  %52 = icmp ne i32 %50, %51
  br i1 %52, label %53, label %61

53:                                               ; preds = %49
  %54 = load i32, ptr @a, align 4, !tbaa !5
  %55 = load i32, ptr @c, align 4, !tbaa !5
  %56 = icmp ne i32 %54, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %53
  br label %59

58:                                               ; preds = %53
  br label %59

59:                                               ; preds = %58, %57
  %60 = phi ptr [ @a, %57 ], [ @b, %58 ]
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %60, ptr noundef nonnull align 4 dereferenceable(4) @c) #3
  br label %61

61:                                               ; preds = %59, %49
  %62 = load i32, ptr @c, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  %64 = load i32, ptr @a, align 4, !tbaa !5
  %65 = icmp ne i32 %63, %64
  br i1 %65, label %66, label %73

66:                                               ; preds = %61
  %67 = load i32, ptr @c, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  %69 = icmp sle i32 %68, 13
  br i1 %69, label %70, label %73

70:                                               ; preds = %66
  %71 = load i32, ptr @c, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr @c, align 4, !tbaa !5
  br label %92

73:                                               ; preds = %66, %61
  %74 = load i32, ptr @c, align 4, !tbaa !5
  %75 = add nsw i32 %74, 2
  %76 = icmp sle i32 %75, 13
  br i1 %76, label %77, label %80

77:                                               ; preds = %73
  %78 = load i32, ptr @c, align 4, !tbaa !5
  %79 = add nsw i32 %78, 2
  store i32 %79, ptr @c, align 4, !tbaa !5
  br label %91

80:                                               ; preds = %73
  %81 = load i32, ptr @a, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  %83 = icmp sle i32 %82, 13
  br i1 %83, label %84, label %89

84:                                               ; preds = %80
  %85 = load i32, ptr @a, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr @a, align 4, !tbaa !5
  %87 = load i32, ptr @b, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr @b, align 4, !tbaa !5
  store i32 1, ptr @c, align 4, !tbaa !5
  br label %90

89:                                               ; preds = %80
  store i32 1, ptr @c, align 4, !tbaa !5
  store i32 1, ptr @b, align 4, !tbaa !5
  store i32 1, ptr @a, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %89, %84
  br label %91

91:                                               ; preds = %90, %77
  br label %92

92:                                               ; preds = %91, %70
  %93 = load i32, ptr @a, align 4, !tbaa !5
  %94 = load i32, ptr @c, align 4, !tbaa !5
  %95 = icmp sgt i32 %93, %94
  br i1 %95, label %96, label %97

96:                                               ; preds = %92
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @a, ptr noundef nonnull align 4 dereferenceable(4) @c) #3
  br label %97

97:                                               ; preds = %96, %92
  %98 = load i32, ptr @a, align 4, !tbaa !5
  %99 = load i32, ptr @b, align 4, !tbaa !5
  %100 = load i32, ptr @c, align 4, !tbaa !5
  %101 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %98, i32 noundef %99, i32 noundef %100)
  br label %104

102:                                              ; preds = %45
  %103 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef 1, i32 noundef 1, i32 noundef 2)
  br label %104

104:                                              ; preds = %102, %97
  br label %105

105:                                              ; preds = %104, %36
  br label %2, !llvm.loop !9

106:                                              ; preds = %12
  ret i32 0
}

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

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

declare i32 @puts(ptr noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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 = { inlinehint 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 #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"}


; 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 i32, align 4
@b = external dso_local global i32, align 4
@c = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress 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, ptr noundef nonnull @c)
  %2 = icmp eq i32 %1, 3
  br i1 %2, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %0, %47
  %3 = load i32, ptr @a, align 4, !tbaa !5
  %4 = load i32, ptr @b, align 4, !tbaa !5
  %5 = add nsw i32 %4, %3
  %6 = load i32, ptr @c, align 4, !tbaa !5
  %7 = sub i32 0, %6
  %.not = icmp eq i32 %5, %7
  br i1 %.not, label %.critedge, label %8

8:                                                ; preds = %.lr.ph
  %9 = icmp eq i32 %3, %4
  %10 = icmp eq i32 %4, %6
  %or.cond = and i1 %9, %10
  br i1 %or.cond, label %11, label %18

11:                                               ; preds = %8
  %12 = icmp slt i32 %3, 13
  br i1 %12, label %13, label %16

13:                                               ; preds = %11
  %14 = add nsw i32 %3, 1
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %14, i32 noundef %14, i32 noundef %14)
  br label %47

16:                                               ; preds = %11
  %17 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %47

18:                                               ; preds = %8
  br i1 %9, label %.thread, label %19

19:                                               ; preds = %18
  %20 = icmp eq i32 %3, %6
  %or.cond14 = or i1 %20, %10
  br i1 %or.cond14, label %21, label %45

21:                                               ; preds = %19
  %a.b = select i1 %20, ptr @b, ptr @a
  tail call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %a.b, ptr noundef nonnull align 4 dereferenceable(4) @c) #3
  %.pre = load i32, ptr @c, align 4, !tbaa !5
  %.pre17 = load i32, ptr @a, align 4, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %18, %21
  %22 = phi i32 [ %3, %18 ], [ %.pre17, %21 ]
  %23 = phi i32 [ %6, %18 ], [ %.pre, %21 ]
  %24 = add nsw i32 %23, 1
  %.not13 = icmp ne i32 %24, %22
  %25 = icmp slt i32 %23, 13
  %or.cond15 = and i1 %25, %.not13
  br i1 %or.cond15, label %36, label %26

26:                                               ; preds = %.thread
  %27 = icmp slt i32 %23, 12
  br i1 %27, label %28, label %30

28:                                               ; preds = %26
  %29 = add nsw i32 %23, 2
  br label %36

30:                                               ; preds = %26
  %31 = icmp slt i32 %22, 13
  br i1 %31, label %32, label %.thread20

32:                                               ; preds = %30
  %33 = add nsw i32 %22, 1
  store i32 %33, ptr @a, align 4, !tbaa !5
  %34 = load i32, ptr @b, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr @b, align 4, !tbaa !5
  br label %36

.thread20:                                        ; preds = %30
  store i32 1, ptr @c, align 4, !tbaa !5
  store i32 1, ptr @b, align 4, !tbaa !5
  store i32 1, ptr @a, align 4, !tbaa !5
  br label %40

36:                                               ; preds = %.thread, %28, %32
  %.sink = phi i32 [ %29, %28 ], [ 1, %32 ], [ %24, %.thread ]
  %37 = phi i32 [ %22, %28 ], [ %33, %32 ], [ %22, %.thread ]
  store i32 %.sink, ptr @c, align 4, !tbaa !5
  %38 = icmp sgt i32 %37, %.sink
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  tail call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @a, ptr noundef nonnull align 4 dereferenceable(4) @c) #3
  %.pre18 = load i32, ptr @a, align 4, !tbaa !5
  %.pre19 = load i32, ptr @c, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %.thread20, %39, %36
  %41 = phi i32 [ %.pre19, %39 ], [ %.sink, %36 ], [ 1, %.thread20 ]
  %42 = phi i32 [ %.pre18, %39 ], [ %37, %36 ], [ 1, %.thread20 ]
  %43 = load i32, ptr @b, align 4, !tbaa !5
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %42, i32 noundef %43, i32 noundef %41)
  br label %47

45:                                               ; preds = %19
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 1, i32 noundef 1, i32 noundef 2)
  br label %47

47:                                               ; preds = %40, %45, %13, %16
  %48 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a, ptr noundef nonnull @b, ptr noundef nonnull @c)
  %49 = icmp eq i32 %48, 3
  br i1 %49, label %.lr.ph, label %.critedge, !llvm.loop !9

.critedge:                                        ; preds = %.lr.ph, %47, %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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

attributes #0 = { 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 #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" }
attributes #2 = { inlinehint 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 #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"}


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