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

@field_size = external hidden global [238 x i32], 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: nounwind uwtable
declare dso_local i32 @segy_get_field(ptr noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @segy_offsets(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5, i32 noundef %6) #1 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca [240 x i8], align 16
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !9
  store i32 %2, ptr %11, align 4, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !5
  store i64 %5, ptr %14, align 8, !tbaa !11
  store i32 %6, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #2
  store i32 0, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  store i32 0, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  store i32 0, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #2
  store i32 0, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 240, ptr %21) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #2
  store i32 0, ptr %22, align 4, !tbaa !9
  %24 = load i32, ptr %12, align 4, !tbaa !9
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %26, label %28

26:                                               ; preds = %7
  %27 = load ptr, ptr %13, align 8, !tbaa !5
  store i32 1, ptr %27, align 4, !tbaa !9
  store i32 0, ptr %8, align 4
  store i32 1, ptr %23, align 4
  br label %95

28:                                               ; preds = %7
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [238 x i32], ptr @field_size, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %40, label %34

34:                                               ; preds = %28
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [238 x i32], ptr @field_size, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %34, %28
  store i32 5, ptr %8, align 4
  store i32 1, ptr %23, align 4
  br label %95

41:                                               ; preds = %34
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds [240 x i8], ptr %21, i64 0, i64 0
  %44 = load i64, ptr %14, align 8, !tbaa !11
  %45 = load i32, ptr %15, align 4, !tbaa !9
  %46 = call i32 @segy_traceheader(ptr noundef %42, i32 noundef 0, ptr noundef %43, i64 noundef %44, i32 noundef %45)
  store i32 %46, ptr %16, align 4, !tbaa !9
  %47 = load i32, ptr %16, align 4, !tbaa !9
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %41
  store i32 3, ptr %8, align 4
  store i32 1, ptr %23, align 4
  br label %95

50:                                               ; preds = %41
  %51 = getelementptr inbounds [240 x i8], ptr %21, i64 0, i64 0
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = call i32 @segy_get_field(ptr noundef %51, i32 noundef %52, ptr noundef %17)
  %54 = getelementptr inbounds [240 x i8], ptr %21, i64 0, i64 0
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = call i32 @segy_get_field(ptr noundef %54, i32 noundef %55, ptr noundef %19)
  br label %57

57:                                               ; preds = %90, %50
  %58 = load i32, ptr %22, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %22, align 4, !tbaa !9
  %60 = load i32, ptr %22, align 4, !tbaa !9
  %61 = load i32, ptr %12, align 4, !tbaa !9
  %62 = icmp eq i32 %60, %61
  br i1 %62, label %63, label %64

63:                                               ; preds = %57
  br label %92

64:                                               ; preds = %57
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = load i32, ptr %22, align 4, !tbaa !9
  %67 = getelementptr inbounds [240 x i8], ptr %21, i64 0, i64 0
  %68 = load i64, ptr %14, align 8, !tbaa !11
  %69 = load i32, ptr %15, align 4, !tbaa !9
  %70 = call i32 @segy_traceheader(ptr noundef %65, i32 noundef %66, ptr noundef %67, i64 noundef %68, i32 noundef %69)
  store i32 %70, ptr %16, align 4, !tbaa !9
  %71 = load i32, ptr %16, align 4, !tbaa !9
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %75

73:                                               ; preds = %64
  %74 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %74, ptr %8, align 4
  store i32 1, ptr %23, align 4
  br label %95

75:                                               ; preds = %64
  %76 = getelementptr inbounds [240 x i8], ptr %21, i64 0, i64 0
  %77 = load i32, ptr %10, align 4, !tbaa !9
  %78 = call i32 @segy_get_field(ptr noundef %76, i32 noundef %77, ptr noundef %18)
  %79 = getelementptr inbounds [240 x i8], ptr %21, i64 0, i64 0
  %80 = load i32, ptr %11, align 4, !tbaa !9
  %81 = call i32 @segy_get_field(ptr noundef %79, i32 noundef %80, ptr noundef %20)
  br label %82

82:                                               ; preds = %75
  %83 = load i32, ptr %17, align 4, !tbaa !9
  %84 = load i32, ptr %18, align 4, !tbaa !9
  %85 = icmp eq i32 %83, %84
  br i1 %85, label %86, label %90

86:                                               ; preds = %82
  %87 = load i32, ptr %19, align 4, !tbaa !9
  %88 = load i32, ptr %20, align 4, !tbaa !9
  %89 = icmp eq i32 %87, %88
  br label %90

90:                                               ; preds = %86, %82
  %91 = phi i1 [ false, %82 ], [ %89, %86 ]
  br i1 %91, label %57, label %92, !llvm.loop !13

92:                                               ; preds = %90, %63
  %93 = load i32, ptr %22, align 4, !tbaa !9
  %94 = load ptr, ptr %13, align 8, !tbaa !5
  store i32 %93, ptr %94, align 4, !tbaa !9
  store i32 0, ptr %8, align 4
  store i32 1, ptr %23, align 4
  br label %95

95:                                               ; preds = %92, %73, %49, %40, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #2
  call void @llvm.lifetime.end.p0(i64 240, ptr %21) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  %96 = load i32, ptr %8, align 4
  ret i32 %96
}

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 }

!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 = distinct !{!13, !14}
!14 = !{!"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"

@field_size = external hidden local_unnamed_addr global [238 x i32], 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: nounwind uwtable
declare dso_local i32 @segy_get_field(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @segy_offsets(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef writeonly %4, i64 noundef %5, i32 noundef %6) local_unnamed_addr #1 {
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca [240 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #2
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #2
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #2
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #2
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 240, ptr nonnull %12) #2
  %13 = icmp eq i32 %3, 1
  br i1 %13, label %.loopexit.sink.split, label %14

14:                                               ; preds = %7
  %15 = sext i32 %1 to i64
  %16 = getelementptr inbounds [238 x i32], ptr @field_size, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %.loopexit, label %19

19:                                               ; preds = %14
  %20 = sext i32 %2 to i64
  %21 = getelementptr inbounds [238 x i32], ptr @field_size, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %.loopexit, label %24

24:                                               ; preds = %19
  %25 = call i32 @segy_traceheader(ptr noundef %0, i32 noundef 0, ptr noundef nonnull %12, i64 noundef %5, i32 noundef %6)
  %.not = icmp eq i32 %25, 0
  br i1 %.not, label %26, label %.loopexit

26:                                               ; preds = %24
  %27 = call i32 @segy_get_field(ptr noundef nonnull %12, i32 noundef %1, ptr noundef nonnull %8)
  %28 = call i32 @segy_get_field(ptr noundef nonnull %12, i32 noundef %2, ptr noundef nonnull %10)
  br label %29

29:                                               ; preds = %34, %26
  %.0 = phi i32 [ 0, %26 ], [ %30, %34 ]
  %30 = add nuw nsw i32 %.0, 1
  %31 = icmp eq i32 %30, %3
  br i1 %31, label %.loopexit.sink.split, label %32

32:                                               ; preds = %29
  %33 = call i32 @segy_traceheader(ptr noundef %0, i32 noundef %30, ptr noundef nonnull %12, i64 noundef %5, i32 noundef %6)
  %.not27 = icmp eq i32 %33, 0
  br i1 %.not27, label %34, label %.loopexit

34:                                               ; preds = %32
  %35 = call i32 @segy_get_field(ptr noundef nonnull %12, i32 noundef %1, ptr noundef nonnull %9)
  %36 = call i32 @segy_get_field(ptr noundef nonnull %12, i32 noundef %2, ptr noundef nonnull %11)
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = load i32, ptr %9, align 4, !tbaa !5
  %39 = icmp eq i32 %37, %38
  %40 = load i32, ptr %10, align 4
  %41 = load i32, ptr %11, align 4
  %42 = icmp eq i32 %40, %41
  %43 = select i1 %39, i1 %42, i1 false
  br i1 %43, label %29, label %.loopexit.sink.split, !llvm.loop !9

.loopexit.sink.split:                             ; preds = %34, %29, %7
  %.lcssa30.sink = phi i32 [ 1, %7 ], [ %3, %29 ], [ %30, %34 ]
  store i32 %.lcssa30.sink, ptr %4, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %32, %.loopexit.sink.split, %24, %14, %19
  %.023 = phi i32 [ 5, %19 ], [ 5, %14 ], [ 3, %24 ], [ 0, %.loopexit.sink.split ], [ %33, %32 ]
  call void @llvm.lifetime.end.p0(i64 240, ptr nonnull %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #2
  ret i32 %.023
}

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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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