; LLVM IR from Izaron/ACM-ICPC :: Timus Online Judge/Volume 9/1800. Murphy's Law (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"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@g = external dso_local global x86_fp80, align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca x86_fp80, align 16
  %3 = alloca x86_fp80, align 16
  %4 = alloca x86_fp80, align 16
  %5 = alloca x86_fp80, align 16
  %6 = alloca i32, align 4
  %7 = alloca x86_fp80, align 16
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #6
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 16 dereferenceable(16) %2)
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 16 dereferenceable(16) %3)
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 16 dereferenceable(16) %4)
  %11 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %12 = fdiv x86_fp80 %11, 0xK4005C800000000000000
  store x86_fp80 %12, ptr %2, align 16, !tbaa !5
  %13 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %14 = fdiv x86_fp80 %13, 0xK4005C800000000000000
  store x86_fp80 %14, ptr %3, align 16, !tbaa !5
  %15 = call x86_fp80 @acosl(x86_fp80 noundef 0xK00000000000000000000) #6
  %16 = fdiv x86_fp80 %15, 0xK4002F000000000000000
  %17 = load x86_fp80, ptr %4, align 16, !tbaa !5
  %18 = fmul x86_fp80 %17, %16
  store x86_fp80 %18, ptr %4, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #6
  store x86_fp80 0xK00000000000000000000, ptr %5, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %62, %0
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = icmp slt i32 %20, 1000
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %65

23:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #6
  %24 = load x86_fp80, ptr %4, align 16, !tbaa !5
  %25 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %26 = fmul x86_fp80 %24, %25
  %27 = call x86_fp80 @sinl(x86_fp80 noundef %26) #6
  %28 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %29 = fmul x86_fp80 %27, %28
  %30 = fdiv x86_fp80 %29, 0xK40008000000000000000
  %31 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %30)
  store x86_fp80 %31, ptr %7, align 16, !tbaa !5
  %32 = load x86_fp80, ptr %4, align 16, !tbaa !5
  %33 = fneg x86_fp80 %32
  %34 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %35 = fmul x86_fp80 %33, %34
  %36 = fdiv x86_fp80 %35, 0xK40008000000000000000
  %37 = load x86_fp80, ptr %4, align 16, !tbaa !5
  %38 = load x86_fp80, ptr %4, align 16, !tbaa !5
  %39 = fmul x86_fp80 %37, %38
  %40 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %41 = fmul x86_fp80 %39, %40
  %42 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %43 = fmul x86_fp80 %41, %42
  %44 = fdiv x86_fp80 %43, 0xK40018000000000000000
  %45 = load x86_fp80, ptr @g, align 16, !tbaa !5
  %46 = fmul x86_fp80 0xK40008000000000000000, %45
  %47 = load x86_fp80, ptr %4, align 16, !tbaa !5
  %48 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %49 = fmul x86_fp80 %47, %48
  %50 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %51 = fmul x86_fp80 %49, %50
  %52 = fdiv x86_fp80 %51, 0xK40008000000000000000
  %53 = load x86_fp80, ptr %7, align 16, !tbaa !5
  %54 = fsub x86_fp80 %52, %53
  %55 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %56 = fadd x86_fp80 %54, %55
  %57 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %46, x86_fp80 %56, x86_fp80 %44)
  %58 = call x86_fp80 @sqrtl(x86_fp80 noundef %57) #6
  %59 = fadd x86_fp80 %36, %58
  %60 = load x86_fp80, ptr @g, align 16, !tbaa !5
  %61 = fdiv x86_fp80 %59, %60
  store x86_fp80 %61, ptr %5, align 16, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  br label %62

62:                                               ; preds = %23
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %6, align 4, !tbaa !9
  br label %19, !llvm.loop !11

65:                                               ; preds = %22
  %66 = load x86_fp80, ptr %4, align 16, !tbaa !5
  %67 = load x86_fp80, ptr %5, align 16, !tbaa !5
  %68 = fmul x86_fp80 %66, %67
  %69 = call x86_fp80 @cosl(x86_fp80 noundef %68) #6
  %70 = fcmp ogt x86_fp80 %69, 0xK00000000000000000000
  %71 = zext i1 %70 to i64
  %72 = select i1 %70, ptr @.str, ptr @.str.1
  %73 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef %72)
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #6
  %74 = load i32, ptr %1, align 4
  ret i32 %74
}

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 16 dereferenceable(16)) #2 align 2

; Function Attrs: nounwind
declare x86_fp80 @acosl(x86_fp80 noundef) #3

; Function Attrs: nounwind
declare x86_fp80 @sinl(x86_fp80 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fabs.f80(x86_fp80) #4

; Function Attrs: nounwind
declare x86_fp80 @sqrtl(x86_fp80 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #5

; Function Attrs: nounwind
declare x86_fp80 @cosl(x86_fp80 noundef) #3

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 = { 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 #6 = { 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 double", !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"}


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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@g = external dso_local local_unnamed_addr global x86_fp80, align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca x86_fp80, align 16
  %2 = alloca x86_fp80, align 16
  %3 = alloca x86_fp80, align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #6
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 16 dereferenceable(16) %1)
  %5 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 16 dereferenceable(16) %2)
  %6 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 16 dereferenceable(16) %3)
  %7 = load x86_fp80, ptr %1, align 16, !tbaa !5
  %8 = fdiv x86_fp80 %7, 0xK4005C800000000000000
  store x86_fp80 %8, ptr %1, align 16, !tbaa !5
  %9 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %10 = fdiv x86_fp80 %9, 0xK4005C800000000000000
  store x86_fp80 %10, ptr %2, align 16, !tbaa !5
  %11 = call x86_fp80 @acosl(x86_fp80 noundef 0xK00000000000000000000) #6
  %12 = fdiv x86_fp80 %11, 0xK4002F000000000000000
  %13 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %14 = fmul x86_fp80 %13, %12
  store x86_fp80 %14, ptr %3, align 16, !tbaa !5
  br label %22

15:                                               ; preds = %22
  %16 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %17 = fmul x86_fp80 %50, %16
  %18 = call x86_fp80 @cosl(x86_fp80 noundef %17) #6
  %19 = fcmp ogt x86_fp80 %18, 0xK00000000000000000000
  %20 = select i1 %19, ptr @.str, ptr @.str.1
  %21 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull %20)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #6
  ret i32 0

22:                                               ; preds = %0, %22
  %.08 = phi x86_fp80 [ 0xK00000000000000000000, %0 ], [ %50, %22 ]
  %.067 = phi i32 [ 0, %0 ], [ %51, %22 ]
  %23 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %24 = fmul x86_fp80 %.08, %23
  %25 = call x86_fp80 @sinl(x86_fp80 noundef %24) #6
  %26 = load x86_fp80, ptr %1, align 16, !tbaa !5
  %27 = fmul x86_fp80 %25, %26
  %28 = fmul x86_fp80 %27, 0xK3FFE8000000000000000
  %29 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %28)
  %30 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %31 = fneg x86_fp80 %30
  %32 = fmul x86_fp80 %26, %31
  %33 = fmul x86_fp80 %32, 0xK3FFE8000000000000000
  %34 = fmul x86_fp80 %30, %30
  %35 = fmul x86_fp80 %26, %34
  %36 = fmul x86_fp80 %26, %35
  %37 = fmul x86_fp80 %36, 0xK3FFD8000000000000000
  %38 = load x86_fp80, ptr @g, align 16, !tbaa !5
  %39 = fmul x86_fp80 %38, 0xK40008000000000000000
  %40 = fmul x86_fp80 %26, %30
  %41 = fmul x86_fp80 %.08, %40
  %42 = fmul x86_fp80 %41, 0xK3FFE8000000000000000
  %43 = fsub x86_fp80 %42, %29
  %44 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %45 = fadd x86_fp80 %44, %43
  %46 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %39, x86_fp80 %45, x86_fp80 %37)
  %47 = call x86_fp80 @sqrtl(x86_fp80 noundef %46) #6
  %48 = fadd x86_fp80 %33, %47
  %49 = load x86_fp80, ptr @g, align 16, !tbaa !5
  %50 = fdiv x86_fp80 %48, %49
  %51 = add nuw nsw i32 %.067, 1
  %exitcond.not = icmp eq i32 %51, 1000
  br i1 %exitcond.not, label %15, label %22, !llvm.loop !9
}

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 16 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare x86_fp80 @acosl(x86_fp80 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare x86_fp80 @sinl(x86_fp80 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fabs.f80(x86_fp80) #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare x86_fp80 @sqrtl(x86_fp80 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare x86_fp80 @cosl(x86_fp80 noundef) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 #6 = { 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 double", !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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass