; LLVM IR from tangjz/acm-icpc :: codeforces/gym/101471J.ll (Z3dfsie)

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

%struct.Edge = type { i32, i32, x86_fp80 }

@T = external dso_local global i32, align 4
@lev = external dso_local global [201 x i32], align 16
@cur = external dso_local global [201 x i32], align 16
@e = external dso_local global [161605 x %struct.Edge], align 16

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z3sgne(x86_fp80 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef x86_fp80 @_Z3dfsie(i32 noundef %0, x86_fp80 noundef %1) #2 {
  %3 = alloca x86_fp80, align 16
  %4 = alloca i32, align 4
  %5 = alloca x86_fp80, align 16
  %6 = alloca x86_fp80, align 16
  %7 = alloca x86_fp80, align 16
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca x86_fp80, align 16
  store i32 %0, ptr %4, align 4, !tbaa !5
  store x86_fp80 %1, ptr %5, align 16, !tbaa !9
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = load i32, ptr @T, align 4, !tbaa !5
  %13 = icmp eq i32 %11, %12
  br i1 %13, label %14, label %16

14:                                               ; preds = %2
  %15 = load x86_fp80, ptr %5, align 16, !tbaa !9
  store x86_fp80 %15, ptr %3, align 16
  br label %120

16:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  store x86_fp80 0xK00000000000000000000, ptr %6, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [201 x i32], ptr @cur, i64 0, i64 %18
  store ptr %19, ptr %8, align 8, !tbaa !11
  br label %20

20:                                               ; preds = %101, %16
  %21 = load ptr, ptr %8, align 8, !tbaa !11
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = xor i32 %22, -1
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %26, label %25

25:                                               ; preds = %20
  store i32 2, ptr %9, align 4
  br label %109

26:                                               ; preds = %20
  %27 = load ptr, ptr %8, align 8, !tbaa !11
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %29
  %31 = getelementptr inbounds %struct.Edge, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !13
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [201 x i32], ptr @lev, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [201 x i32], ptr @lev, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  %41 = icmp eq i32 %35, %40
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  br i1 %41, label %42, label %71

42:                                               ; preds = %26
  %43 = load ptr, ptr %8, align 8, !tbaa !11
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %45
  %47 = getelementptr inbounds %struct.Edge, ptr %46, i32 0, i32 2
  %48 = load x86_fp80, ptr %47, align 16, !tbaa !15
  %49 = call noundef i32 @_Z3sgne(x86_fp80 noundef %48)
  %50 = icmp sgt i32 %49, 0
  br i1 %50, label %51, label %71

51:                                               ; preds = %42
  %52 = load ptr, ptr %8, align 8, !tbaa !11
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %54
  %56 = getelementptr inbounds %struct.Edge, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 4, !tbaa !13
  %58 = load x86_fp80, ptr %5, align 16, !tbaa !9
  %59 = load x86_fp80, ptr %6, align 16, !tbaa !9
  %60 = fsub x86_fp80 %58, %59
  store x86_fp80 %60, ptr %10, align 16, !tbaa !9
  %61 = load ptr, ptr %8, align 8, !tbaa !11
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %63
  %65 = getelementptr inbounds %struct.Edge, ptr %64, i32 0, i32 2
  %66 = call noundef nonnull align 16 dereferenceable(16) ptr @_ZSt3minIeERKT_S2_S2_(ptr noundef nonnull align 16 dereferenceable(16) %10, ptr noundef nonnull align 16 dereferenceable(16) %65)
  %67 = load x86_fp80, ptr %66, align 16, !tbaa !9
  %68 = call noundef x86_fp80 @_Z3dfsie(i32 noundef %57, x86_fp80 noundef %67)
  store x86_fp80 %68, ptr %7, align 16, !tbaa !9
  %69 = call noundef i32 @_Z3sgne(x86_fp80 noundef %68)
  %70 = icmp sgt i32 %69, 0
  br label %71

71:                                               ; preds = %51, %42, %26
  %72 = phi i1 [ false, %42 ], [ false, %26 ], [ %70, %51 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  br i1 %72, label %73, label %100

73:                                               ; preds = %71
  %74 = load x86_fp80, ptr %7, align 16, !tbaa !9
  %75 = load ptr, ptr %8, align 8, !tbaa !11
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %77
  %79 = getelementptr inbounds %struct.Edge, ptr %78, i32 0, i32 2
  %80 = load x86_fp80, ptr %79, align 16, !tbaa !15
  %81 = fsub x86_fp80 %80, %74
  store x86_fp80 %81, ptr %79, align 16, !tbaa !15
  %82 = load x86_fp80, ptr %7, align 16, !tbaa !9
  %83 = load ptr, ptr %8, align 8, !tbaa !11
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = xor i32 %84, 1
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %86
  %88 = getelementptr inbounds %struct.Edge, ptr %87, i32 0, i32 2
  %89 = load x86_fp80, ptr %88, align 16, !tbaa !15
  %90 = fadd x86_fp80 %89, %82
  store x86_fp80 %90, ptr %88, align 16, !tbaa !15
  %91 = load x86_fp80, ptr %7, align 16, !tbaa !9
  %92 = load x86_fp80, ptr %6, align 16, !tbaa !9
  %93 = fadd x86_fp80 %92, %91
  store x86_fp80 %93, ptr %6, align 16, !tbaa !9
  %94 = load x86_fp80, ptr %5, align 16, !tbaa !9
  %95 = fsub x86_fp80 %93, %94
  %96 = call noundef i32 @_Z3sgne(x86_fp80 noundef %95)
  %97 = icmp sge i32 %96, 0
  br i1 %97, label %98, label %99

98:                                               ; preds = %73
  store i32 2, ptr %9, align 4
  br label %109

99:                                               ; preds = %73
  br label %100

100:                                              ; preds = %99, %71
  br label %101

101:                                              ; preds = %100
  %102 = load ptr, ptr %8, align 8, !tbaa !11
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %104
  %106 = getelementptr inbounds %struct.Edge, ptr %105, i32 0, i32 0
  %107 = load i32, ptr %106, align 16, !tbaa !16
  %108 = load ptr, ptr %8, align 8, !tbaa !11
  store i32 %107, ptr %108, align 4, !tbaa !5
  br label %20, !llvm.loop !17

109:                                              ; preds = %98, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %110

110:                                              ; preds = %109
  %111 = load x86_fp80, ptr %6, align 16, !tbaa !9
  %112 = call noundef i32 @_Z3sgne(x86_fp80 noundef %111)
  %113 = icmp ne i32 %112, 0
  br i1 %113, label %118, label %114

114:                                              ; preds = %110
  %115 = load i32, ptr %4, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [201 x i32], ptr @lev, i64 0, i64 %116
  store i32 -1, ptr %117, align 4, !tbaa !5
  br label %118

118:                                              ; preds = %114, %110
  %119 = load x86_fp80, ptr %6, align 16, !tbaa !9
  store x86_fp80 %119, ptr %3, align 16
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  br label %120

120:                                              ; preds = %118, %14
  %121 = load x86_fp80, ptr %3, align 16
  ret x86_fp80 %121
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 16 dereferenceable(16) ptr @_ZSt3minIeERKT_S2_S2_(ptr noundef nonnull align 16 dereferenceable(16), ptr noundef nonnull align 16 dereferenceable(16)) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 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 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"long double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !6, i64 4}
!14 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !10, i64 16}
!15 = !{!14, !10, i64 16}
!16 = !{!14, !6, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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"

%struct.Edge = type { i32, i32, x86_fp80 }

@T = external dso_local local_unnamed_addr global i32, align 4
@lev = external dso_local local_unnamed_addr global [201 x i32], align 16
@cur = external dso_local local_unnamed_addr global [201 x i32], align 16
@e = external dso_local global [161605 x %struct.Edge], align 16

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z3sgne(x86_fp80 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef x86_fp80 @_Z3dfsie(i32 noundef %0, x86_fp80 noundef %1) local_unnamed_addr #2 {
  %3 = alloca x86_fp80, align 16
  %4 = load i32, ptr @T, align 4, !tbaa !5
  %5 = icmp eq i32 %4, %0
  br i1 %5, label %61, label %6

6:                                                ; preds = %2
  %7 = sext i32 %0 to i64
  %8 = getelementptr inbounds [201 x i32], ptr @cur, i64 0, i64 %7
  %.pr = load i32, ptr %8, align 4, !tbaa !5
  %.not26 = icmp eq i32 %.pr, -1
  br i1 %.not26, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %6
  %9 = getelementptr inbounds [201 x i32], ptr @lev, i64 0, i64 %7
  br label %10

10:                                               ; preds = %.lr.ph, %53
  %.02327 = phi x86_fp80 [ 0xK00000000000000000000, %.lr.ph ], [ %.1, %53 ]
  %11 = phi i32 [ %.pr, %.lr.ph ], [ %57, %53 ]
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %12, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [201 x i32], ptr @lev, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = load i32, ptr %9, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  %20 = icmp eq i32 %17, %19
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  br i1 %20, label %21, label %.critedge

21:                                               ; preds = %10
  %22 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %12, i32 2
  %23 = load x86_fp80, ptr %22, align 16, !tbaa !12
  %24 = call noundef i32 @_Z3sgne(x86_fp80 noundef %23)
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %26, label %.critedge

26:                                               ; preds = %21
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %28, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = fsub x86_fp80 %1, %.02327
  store x86_fp80 %31, ptr %3, align 16, !tbaa !13
  %32 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %28, i32 2
  %33 = call noundef nonnull align 16 dereferenceable(16) ptr @_ZSt3minIeERKT_S2_S2_(ptr noundef nonnull align 16 dereferenceable(16) %3, ptr noundef nonnull align 16 dereferenceable(16) %32)
  %34 = load x86_fp80, ptr %33, align 16, !tbaa !13
  %35 = call noundef x86_fp80 @_Z3dfsie(i32 noundef %30, x86_fp80 noundef %34)
  %36 = call noundef i32 @_Z3sgne(x86_fp80 noundef %35)
  %37 = icmp sgt i32 %36, 0
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  br i1 %37, label %38, label %53

38:                                               ; preds = %26
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %40, i32 2
  %42 = load x86_fp80, ptr %41, align 16, !tbaa !12
  %43 = fsub x86_fp80 %42, %35
  store x86_fp80 %43, ptr %41, align 16, !tbaa !12
  %44 = xor i32 %39, 1
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %45, i32 2
  %47 = load x86_fp80, ptr %46, align 16, !tbaa !12
  %48 = fadd x86_fp80 %35, %47
  store x86_fp80 %48, ptr %46, align 16, !tbaa !12
  %49 = fadd x86_fp80 %.02327, %35
  %50 = fsub x86_fp80 %49, %1
  %51 = call noundef i32 @_Z3sgne(x86_fp80 noundef %50)
  %52 = icmp sgt i32 %51, -1
  br i1 %52, label %._crit_edge, label %53

.critedge:                                        ; preds = %10, %21
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  br label %53

53:                                               ; preds = %26, %.critedge, %38
  %.1 = phi x86_fp80 [ %49, %38 ], [ %.02327, %26 ], [ %.02327, %.critedge ]
  %54 = load i32, ptr %8, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [161605 x %struct.Edge], ptr @e, i64 0, i64 %55
  %57 = load i32, ptr %56, align 16, !tbaa !14
  store i32 %57, ptr %8, align 4, !tbaa !5
  %.not = icmp eq i32 %57, -1
  br i1 %.not, label %._crit_edge, label %10, !llvm.loop !15

._crit_edge:                                      ; preds = %53, %38, %6
  %.2 = phi x86_fp80 [ 0xK00000000000000000000, %6 ], [ %49, %38 ], [ %.1, %53 ]
  %58 = call noundef i32 @_Z3sgne(x86_fp80 noundef %.2)
  %.not25 = icmp eq i32 %58, 0
  br i1 %.not25, label %59, label %61

59:                                               ; preds = %._crit_edge
  %60 = getelementptr inbounds [201 x i32], ptr @lev, i64 0, i64 %7
  store i32 -1, ptr %60, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %._crit_edge, %59, %2
  %.0 = phi x86_fp80 [ %1, %2 ], [ %.2, %59 ], [ %.2, %._crit_edge ]
  ret x86_fp80 %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 16 dereferenceable(16) ptr @_ZSt3minIeERKT_S2_S2_(ptr noundef nonnull align 16 dereferenceable(16), ptr noundef nonnull align 16 dereferenceable(16)) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 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 = { 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 #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 = !{!10, !6, i64 4}
!10 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !11, i64 16}
!11 = !{!"long double", !7, i64 0}
!12 = !{!10, !11, i64 16}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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