; LLVM IR from VastoLorde95/Competitive-Programming :: SPOJ/Random/TRIGALGE (tri)

; 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 [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 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 double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %9

9:                                                ; preds = %43, %0
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = add nsw i32 %10, -1
  store i32 %11, ptr %2, align 4, !tbaa !5
  %12 = icmp ne i32 %10, 0
  br i1 %12, label %13, label %46

13:                                               ; preds = %9
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4, ptr noundef %5, ptr noundef %6)
  %15 = load double, ptr %6, align 8, !tbaa !9
  %16 = load double, ptr %4, align 8, !tbaa !9
  %17 = fdiv double %15, %16
  store double %17, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %40, %13
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = icmp slt i32 %19, 10
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %43

22:                                               ; preds = %18
  %23 = load double, ptr %3, align 8, !tbaa !9
  %24 = load double, ptr %4, align 8, !tbaa !9
  %25 = load double, ptr %3, align 8, !tbaa !9
  %26 = load double, ptr %5, align 8, !tbaa !9
  %27 = load double, ptr %3, align 8, !tbaa !9
  %28 = call double @sin(double noundef %27) #5
  %29 = fmul double %26, %28
  %30 = call double @llvm.fmuladd.f64(double %24, double %25, double %29)
  %31 = load double, ptr %6, align 8, !tbaa !9
  %32 = fsub double %30, %31
  %33 = load double, ptr %4, align 8, !tbaa !9
  %34 = load double, ptr %5, align 8, !tbaa !9
  %35 = load double, ptr %3, align 8, !tbaa !9
  %36 = call double @cos(double noundef %35) #5
  %37 = call double @llvm.fmuladd.f64(double %34, double %36, double %33)
  %38 = fdiv double %32, %37
  %39 = fsub double %23, %38
  store double %39, ptr %3, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %22
  %41 = load i32, ptr %7, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %7, align 4, !tbaa !5
  br label %18, !llvm.loop !11

43:                                               ; preds = %21
  %44 = load double, ptr %3, align 8, !tbaa !9
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %44)
  br label %9, !llvm.loop !13

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

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

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

; Function Attrs: nounwind
declare double @sin(double noundef) #3

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

; Function Attrs: nounwind
declare double @cos(double noundef) #3

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

declare i32 @printf(ptr noundef, ...) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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 [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = add nsw i32 %6, -1
  store i32 %7, ptr %1, align 4, !tbaa !5
  %.not9 = icmp eq i32 %6, 0
  br i1 %.not9, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.lr.ph
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %9 = load double, ptr %4, align 8, !tbaa !9
  %10 = load double, ptr %2, align 8, !tbaa !9
  %11 = fdiv double %9, %10
  %12 = load double, ptr %3, align 8, !tbaa !9
  %13 = call double @sin(double noundef %11) #5
  %14 = fmul double %12, %13
  %15 = call double @llvm.fmuladd.f64(double %10, double %11, double %14)
  %16 = load double, ptr %4, align 8, !tbaa !9
  %17 = fsub double %15, %16
  %18 = load double, ptr %2, align 8, !tbaa !9
  %19 = load double, ptr %3, align 8, !tbaa !9
  %20 = call double @cos(double noundef %11) #5
  %21 = call double @llvm.fmuladd.f64(double %19, double %20, double %18)
  %22 = fdiv double %17, %21
  %23 = fsub double %11, %22
  %24 = load double, ptr %2, align 8, !tbaa !9
  %25 = load double, ptr %3, align 8, !tbaa !9
  %26 = call double @sin(double noundef %23) #5
  %27 = fmul double %25, %26
  %28 = call double @llvm.fmuladd.f64(double %24, double %23, double %27)
  %29 = load double, ptr %4, align 8, !tbaa !9
  %30 = fsub double %28, %29
  %31 = load double, ptr %2, align 8, !tbaa !9
  %32 = load double, ptr %3, align 8, !tbaa !9
  %33 = call double @cos(double noundef %23) #5
  %34 = call double @llvm.fmuladd.f64(double %32, double %33, double %31)
  %35 = fdiv double %30, %34
  %36 = fsub double %23, %35
  %37 = load double, ptr %2, align 8, !tbaa !9
  %38 = load double, ptr %3, align 8, !tbaa !9
  %39 = call double @sin(double noundef %36) #5
  %40 = fmul double %38, %39
  %41 = call double @llvm.fmuladd.f64(double %37, double %36, double %40)
  %42 = load double, ptr %4, align 8, !tbaa !9
  %43 = fsub double %41, %42
  %44 = load double, ptr %2, align 8, !tbaa !9
  %45 = load double, ptr %3, align 8, !tbaa !9
  %46 = call double @cos(double noundef %36) #5
  %47 = call double @llvm.fmuladd.f64(double %45, double %46, double %44)
  %48 = fdiv double %43, %47
  %49 = fsub double %36, %48
  %50 = load double, ptr %2, align 8, !tbaa !9
  %51 = load double, ptr %3, align 8, !tbaa !9
  %52 = call double @sin(double noundef %49) #5
  %53 = fmul double %51, %52
  %54 = call double @llvm.fmuladd.f64(double %50, double %49, double %53)
  %55 = load double, ptr %4, align 8, !tbaa !9
  %56 = fsub double %54, %55
  %57 = load double, ptr %2, align 8, !tbaa !9
  %58 = load double, ptr %3, align 8, !tbaa !9
  %59 = call double @cos(double noundef %49) #5
  %60 = call double @llvm.fmuladd.f64(double %58, double %59, double %57)
  %61 = fdiv double %56, %60
  %62 = fsub double %49, %61
  %63 = load double, ptr %2, align 8, !tbaa !9
  %64 = load double, ptr %3, align 8, !tbaa !9
  %65 = call double @sin(double noundef %62) #5
  %66 = fmul double %64, %65
  %67 = call double @llvm.fmuladd.f64(double %63, double %62, double %66)
  %68 = load double, ptr %4, align 8, !tbaa !9
  %69 = fsub double %67, %68
  %70 = load double, ptr %2, align 8, !tbaa !9
  %71 = load double, ptr %3, align 8, !tbaa !9
  %72 = call double @cos(double noundef %62) #5
  %73 = call double @llvm.fmuladd.f64(double %71, double %72, double %70)
  %74 = fdiv double %69, %73
  %75 = fsub double %62, %74
  %76 = load double, ptr %2, align 8, !tbaa !9
  %77 = load double, ptr %3, align 8, !tbaa !9
  %78 = call double @sin(double noundef %75) #5
  %79 = fmul double %77, %78
  %80 = call double @llvm.fmuladd.f64(double %76, double %75, double %79)
  %81 = load double, ptr %4, align 8, !tbaa !9
  %82 = fsub double %80, %81
  %83 = load double, ptr %2, align 8, !tbaa !9
  %84 = load double, ptr %3, align 8, !tbaa !9
  %85 = call double @cos(double noundef %75) #5
  %86 = call double @llvm.fmuladd.f64(double %84, double %85, double %83)
  %87 = fdiv double %82, %86
  %88 = fsub double %75, %87
  %89 = load double, ptr %2, align 8, !tbaa !9
  %90 = load double, ptr %3, align 8, !tbaa !9
  %91 = call double @sin(double noundef %88) #5
  %92 = fmul double %90, %91
  %93 = call double @llvm.fmuladd.f64(double %89, double %88, double %92)
  %94 = load double, ptr %4, align 8, !tbaa !9
  %95 = fsub double %93, %94
  %96 = load double, ptr %2, align 8, !tbaa !9
  %97 = load double, ptr %3, align 8, !tbaa !9
  %98 = call double @cos(double noundef %88) #5
  %99 = call double @llvm.fmuladd.f64(double %97, double %98, double %96)
  %100 = fdiv double %95, %99
  %101 = fsub double %88, %100
  %102 = load double, ptr %2, align 8, !tbaa !9
  %103 = load double, ptr %3, align 8, !tbaa !9
  %104 = call double @sin(double noundef %101) #5
  %105 = fmul double %103, %104
  %106 = call double @llvm.fmuladd.f64(double %102, double %101, double %105)
  %107 = load double, ptr %4, align 8, !tbaa !9
  %108 = fsub double %106, %107
  %109 = load double, ptr %2, align 8, !tbaa !9
  %110 = load double, ptr %3, align 8, !tbaa !9
  %111 = call double @cos(double noundef %101) #5
  %112 = call double @llvm.fmuladd.f64(double %110, double %111, double %109)
  %113 = fdiv double %108, %112
  %114 = fsub double %101, %113
  %115 = load double, ptr %2, align 8, !tbaa !9
  %116 = load double, ptr %3, align 8, !tbaa !9
  %117 = call double @sin(double noundef %114) #5
  %118 = fmul double %116, %117
  %119 = call double @llvm.fmuladd.f64(double %115, double %114, double %118)
  %120 = load double, ptr %4, align 8, !tbaa !9
  %121 = fsub double %119, %120
  %122 = load double, ptr %2, align 8, !tbaa !9
  %123 = load double, ptr %3, align 8, !tbaa !9
  %124 = call double @cos(double noundef %114) #5
  %125 = call double @llvm.fmuladd.f64(double %123, double %124, double %122)
  %126 = fdiv double %121, %125
  %127 = fsub double %114, %126
  %128 = load double, ptr %2, align 8, !tbaa !9
  %129 = load double, ptr %3, align 8, !tbaa !9
  %130 = call double @sin(double noundef %127) #5
  %131 = fmul double %129, %130
  %132 = call double @llvm.fmuladd.f64(double %128, double %127, double %131)
  %133 = load double, ptr %4, align 8, !tbaa !9
  %134 = fsub double %132, %133
  %135 = load double, ptr %2, align 8, !tbaa !9
  %136 = load double, ptr %3, align 8, !tbaa !9
  %137 = call double @cos(double noundef %127) #5
  %138 = call double @llvm.fmuladd.f64(double %136, double %137, double %135)
  %139 = fdiv double %134, %138
  %140 = fsub double %127, %139
  %141 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %140)
  %142 = load i32, ptr %1, align 4, !tbaa !5
  %143 = add nsw i32 %142, -1
  store i32 %143, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %142, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) 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) #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass