; LLVM IR from moarseniy/CudaFEMproject :: FEMproject/thirdparty/segyio2/src (segy)

; 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.coord = type { float, float }

; 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
declare dso_local i32 @segy_line_trace0(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @segy_rotation_cw(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, i32 noundef %5, ptr noundef %6, i64 noundef %7, i32 noundef %8) #1 {
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  %20 = alloca %struct.coord, align 4
  %21 = alloca %struct.coord, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca float, align 4
  %26 = alloca float, align 4
  %27 = alloca float, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store i32 %1, ptr %12, align 4, !tbaa !9
  store i32 %2, ptr %13, align 4, !tbaa !9
  store i32 %3, ptr %14, align 4, !tbaa !9
  store ptr %4, ptr %15, align 8, !tbaa !5
  store i32 %5, ptr %16, align 4, !tbaa !9
  store ptr %6, ptr %17, align 8, !tbaa !5
  store i64 %7, ptr %18, align 8, !tbaa !11
  store i32 %8, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  %28 = load ptr, ptr %15, align 8, !tbaa !5
  %29 = getelementptr inbounds i32, ptr %28, i64 0
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = load i32, ptr %12, align 4, !tbaa !9
  %32 = load i32, ptr %13, align 4, !tbaa !9
  %33 = load i32, ptr %14, align 4, !tbaa !9
  %34 = load ptr, ptr %15, align 8, !tbaa !5
  %35 = load i32, ptr %16, align 4, !tbaa !9
  %36 = call i32 @segy_line_trace0(i32 noundef %30, i32 noundef %31, i32 noundef %32, i32 noundef %33, ptr noundef %34, i32 noundef %35, ptr noundef %23)
  store i32 %36, ptr %22, align 4, !tbaa !9
  %37 = load i32, ptr %22, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %9
  %40 = load i32, ptr %22, align 4, !tbaa !9
  store i32 %40, ptr %10, align 4
  store i32 1, ptr %24, align 4
  br label %110

41:                                               ; preds = %9
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = load i32, ptr %23, align 4, !tbaa !9
  %44 = getelementptr inbounds %struct.coord, ptr %21, i32 0, i32 0
  %45 = getelementptr inbounds %struct.coord, ptr %21, i32 0, i32 1
  %46 = load i64, ptr %18, align 8, !tbaa !11
  %47 = load i32, ptr %19, align 4, !tbaa !9
  %48 = call i32 @scaled_cdp(ptr noundef %42, i32 noundef %43, ptr noundef %44, ptr noundef %45, i64 noundef %46, i32 noundef %47)
  store i32 %48, ptr %22, align 4, !tbaa !9
  %49 = load i32, ptr %22, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %53

51:                                               ; preds = %41
  %52 = load i32, ptr %22, align 4, !tbaa !9
  store i32 %52, ptr %10, align 4
  store i32 1, ptr %24, align 4
  br label %110

53:                                               ; preds = %41
  %54 = load i32, ptr %12, align 4, !tbaa !9
  %55 = sub nsw i32 %54, 1
  %56 = load i32, ptr %13, align 4, !tbaa !9
  %57 = mul nsw i32 %55, %56
  %58 = load i32, ptr %14, align 4, !tbaa !9
  %59 = mul nsw i32 %57, %58
  %60 = load i32, ptr %23, align 4, !tbaa !9
  %61 = add nsw i32 %60, %59
  store i32 %61, ptr %23, align 4, !tbaa !9
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = load i32, ptr %23, align 4, !tbaa !9
  %64 = getelementptr inbounds %struct.coord, ptr %20, i32 0, i32 0
  %65 = getelementptr inbounds %struct.coord, ptr %20, i32 0, i32 1
  %66 = load i64, ptr %18, align 8, !tbaa !11
  %67 = load i32, ptr %19, align 4, !tbaa !9
  %68 = call i32 @scaled_cdp(ptr noundef %62, i32 noundef %63, ptr noundef %64, ptr noundef %65, i64 noundef %66, i32 noundef %67)
  store i32 %68, ptr %22, align 4, !tbaa !9
  %69 = load i32, ptr %22, align 4, !tbaa !9
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %73

71:                                               ; preds = %53
  %72 = load i32, ptr %22, align 4, !tbaa !9
  store i32 %72, ptr %10, align 4
  store i32 1, ptr %24, align 4
  br label %110

73:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #4
  %74 = getelementptr inbounds %struct.coord, ptr %20, i32 0, i32 0
  %75 = load float, ptr %74, align 4, !tbaa !13
  %76 = getelementptr inbounds %struct.coord, ptr %21, i32 0, i32 0
  %77 = load float, ptr %76, align 4, !tbaa !13
  %78 = fsub float %75, %77
  store float %78, ptr %25, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #4
  %79 = getelementptr inbounds %struct.coord, ptr %20, i32 0, i32 1
  %80 = load float, ptr %79, align 4, !tbaa !17
  %81 = getelementptr inbounds %struct.coord, ptr %21, i32 0, i32 1
  %82 = load float, ptr %81, align 4, !tbaa !17
  %83 = fsub float %80, %82
  store float %83, ptr %26, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #4
  %84 = load float, ptr %25, align 4, !tbaa !16
  %85 = fcmp une float %84, 0.000000e+00
  br i1 %85, label %89, label %86

86:                                               ; preds = %73
  %87 = load float, ptr %26, align 4, !tbaa !16
  %88 = fcmp une float %87, 0.000000e+00
  br i1 %88, label %89, label %95

89:                                               ; preds = %86, %73
  %90 = load float, ptr %25, align 4, !tbaa !16
  %91 = fpext float %90 to double
  %92 = load float, ptr %26, align 4, !tbaa !16
  %93 = fpext float %92 to double
  %94 = call double @atan2(double noundef %91, double noundef %93) #4
  br label %96

95:                                               ; preds = %86
  br label %96

96:                                               ; preds = %95, %89
  %97 = phi double [ %94, %89 ], [ 0.000000e+00, %95 ]
  %98 = fptrunc double %97 to float
  store float %98, ptr %27, align 4, !tbaa !16
  %99 = load float, ptr %27, align 4, !tbaa !16
  %100 = fcmp olt float %99, 0.000000e+00
  br i1 %100, label %101, label %107

101:                                              ; preds = %96
  %102 = call double @acos(double noundef -1.000000e+00) #4
  %103 = load float, ptr %27, align 4, !tbaa !16
  %104 = fpext float %103 to double
  %105 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %102, double %104)
  %106 = fptrunc double %105 to float
  store float %106, ptr %27, align 4, !tbaa !16
  br label %107

107:                                              ; preds = %101, %96
  %108 = load float, ptr %27, align 4, !tbaa !16
  %109 = load ptr, ptr %17, align 8, !tbaa !5
  store float %108, ptr %109, align 4, !tbaa !16
  store i32 0, ptr %10, align 4
  store i32 1, ptr %24, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #4
  br label %110

110:                                              ; preds = %107, %71, %51, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  %111 = load i32, ptr %10, align 4
  ret i32 %111
}

; Function Attrs: nounwind uwtable
declare hidden i32 @scaled_cdp(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef) #1

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

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

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

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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 = !{!"long", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"coord", !15, i64 0, !15, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!15, !15, i64 0}
!17 = !{!14, !15, i64 4}


; 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.coord = type { float, float }

; 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: nounwind uwtable
declare dso_local i32 @segy_line_trace0(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @segy_rotation_cw(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, i32 noundef %5, ptr nocapture noundef writeonly %6, i64 noundef %7, i32 noundef %8) local_unnamed_addr #1 {
  %10 = alloca %struct.coord, align 8
  %11 = alloca %struct.coord, align 8
  %12 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #3
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = call i32 @segy_line_trace0(i32 noundef %13, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull %4, i32 noundef %5, ptr noundef nonnull %12)
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %15, label %47

15:                                               ; preds = %9
  %16 = load i32, ptr %12, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %11, i64 4
  %18 = call i32 @scaled_cdp(ptr noundef %0, i32 noundef %16, ptr noundef nonnull %11, ptr noundef nonnull %17, i64 noundef %7, i32 noundef %8)
  %.not35 = icmp eq i32 %18, 0
  br i1 %.not35, label %19, label %47

19:                                               ; preds = %15
  %20 = add nsw i32 %1, -1
  %21 = mul nsw i32 %20, %2
  %22 = mul nsw i32 %21, %3
  %23 = load i32, ptr %12, align 4, !tbaa !5
  %24 = add nsw i32 %23, %22
  store i32 %24, ptr %12, align 4, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %10, i64 4
  %26 = call i32 @scaled_cdp(ptr noundef %0, i32 noundef %24, ptr noundef nonnull %10, ptr noundef nonnull %25, i64 noundef %7, i32 noundef %8)
  %.not36 = icmp eq i32 %26, 0
  br i1 %.not36, label %27, label %47

27:                                               ; preds = %19
  %28 = load <2 x float>, ptr %10, align 8, !tbaa !9
  %29 = load <2 x float>, ptr %11, align 8, !tbaa !9
  %30 = fsub <2 x float> %28, %29
  %31 = fcmp une <2 x float> %30, zeroinitializer
  %32 = extractelement <2 x i1> %31, i64 0
  %33 = extractelement <2 x i1> %31, i64 1
  %or.cond = select i1 %32, i1 true, i1 %33
  br i1 %or.cond, label %34, label %41

34:                                               ; preds = %27
  %35 = extractelement <2 x float> %30, i64 0
  %36 = fpext float %35 to double
  %37 = extractelement <2 x float> %30, i64 1
  %38 = fpext float %37 to double
  %39 = call double @atan2(double noundef %36, double noundef %38) #3
  %40 = fptrunc double %39 to float
  br label %41

41:                                               ; preds = %27, %34
  %42 = phi float [ %40, %34 ], [ 0.000000e+00, %27 ]
  %43 = fcmp olt float %42, 0.000000e+00
  %44 = fpext float %42 to double
  %45 = fadd double %44, 0x401921FB54442D18
  %46 = fptrunc double %45 to float
  %.0 = select i1 %43, float %46, float %42
  store float %.0, ptr %6, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %19, %15, %9, %41
  %.030 = phi i32 [ 0, %41 ], [ %14, %9 ], [ %18, %15 ], [ %26, %19 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #3
  ret i32 %.030
}

; Function Attrs: nounwind uwtable
declare hidden i32 @scaled_cdp(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @atan2(double noundef, double noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass