; LLVM IR from Aakriti05/DSP-implementation_LMS_RNN :: rnn (thanh)

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

; 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: nounwind uwtable
define dso_local ptr @thanh(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %42, %1
  %7 = load i32, ptr %3, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 32
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %45

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %38, %10
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 16
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %41

15:                                               ; preds = %11
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds ptr, ptr %16, i64 %18
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds double, ptr %20, i64 %22
  %24 = load double, ptr %23, align 8, !tbaa !11
  %25 = fmul double 2.000000e+00, %24
  %26 = call double @exp(double noundef %25) #3
  %27 = fadd double 1.000000e+00, %26
  %28 = fdiv double 2.000000e+00, %27
  %29 = fsub double 1.000000e+00, %28
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds ptr, ptr %30, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds double, ptr %34, i64 %36
  store double %29, ptr %37, align 8, !tbaa !11
  br label %38

38:                                               ; preds = %15
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %5, align 4, !tbaa !9
  br label %11, !llvm.loop !13

41:                                               ; preds = %14
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %3, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %3, align 4, !tbaa !9
  br label %6, !llvm.loop !15

45:                                               ; preds = %9
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  ret ptr %46
}

; Function Attrs: nounwind
declare double @exp(double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

; Function Attrs: nofree nounwind memory(readwrite, inaccessiblemem: write) uwtable
define dso_local noundef ptr @thanh(ptr noundef readonly returned %0) local_unnamed_addr #0 {
  br label %.preheader

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

146:                                              ; preds = %.preheader
  ret ptr %0
}

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

attributes #0 = { nofree nounwind memory(readwrite, inaccessiblemem: write) 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 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 #2 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass