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

; 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_get_bfield(ptr noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @segy_trace0(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_sample_interval(ptr noundef %0, float noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca [400 x i8], align 16
  %9 = alloca [240 x i8], align 16
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 400, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 240, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds [400 x i8], ptr %8, i64 0, i64 0
  %19 = call i32 @segy_binheader(ptr noundef %17, ptr noundef %18)
  store i32 %19, ptr %10, align 4, !tbaa !11
  %20 = load i32, ptr %10, align 4, !tbaa !11
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %3
  %23 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %23, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %75

24:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %25 = getelementptr inbounds [400 x i8], ptr %8, i64 0, i64 0
  %26 = call i64 @segy_trace0(ptr noundef %25)
  store i64 %26, ptr %12, align 8, !tbaa !13
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds [240 x i8], ptr %9, i64 0, i64 0
  %29 = load i64, ptr %12, align 8, !tbaa !13
  %30 = call i32 @segy_traceheader(ptr noundef %27, i32 noundef 0, ptr noundef %28, i64 noundef %29, i32 noundef 0)
  store i32 %30, ptr %10, align 4, !tbaa !11
  %31 = load i32, ptr %10, align 4, !tbaa !11
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %24
  %34 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %34, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %74

35:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  store i32 0, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  store i32 0, ptr %14, align 4, !tbaa !11
  %36 = getelementptr inbounds [400 x i8], ptr %8, i64 0, i64 0
  %37 = call i32 @segy_get_bfield(ptr noundef %36, i32 noundef 3217, ptr noundef %13)
  %38 = getelementptr inbounds [240 x i8], ptr %9, i64 0, i64 0
  %39 = call i32 @segy_get_field(ptr noundef %38, i32 noundef 117, ptr noundef %14)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  %40 = load i32, ptr %13, align 4, !tbaa !11
  %41 = sitofp i32 %40 to float
  store float %41, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  %42 = load i32, ptr %14, align 4, !tbaa !11
  %43 = sitofp i32 %42 to float
  store float %43, ptr %16, align 4, !tbaa !9
  %44 = load float, ptr %6, align 4, !tbaa !9
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  store float %44, ptr %45, align 4, !tbaa !9
  %46 = load float, ptr %15, align 4, !tbaa !9
  %47 = fcmp oeq float %46, 0.000000e+00
  br i1 %47, label %48, label %54

48:                                               ; preds = %35
  %49 = load float, ptr %16, align 4, !tbaa !9
  %50 = fcmp une float %49, 0.000000e+00
  br i1 %50, label %51, label %54

51:                                               ; preds = %48
  %52 = load float, ptr %16, align 4, !tbaa !9
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  store float %52, ptr %53, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %51, %48, %35
  %55 = load float, ptr %16, align 4, !tbaa !9
  %56 = fcmp oeq float %55, 0.000000e+00
  br i1 %56, label %57, label %63

57:                                               ; preds = %54
  %58 = load float, ptr %15, align 4, !tbaa !9
  %59 = fcmp une float %58, 0.000000e+00
  br i1 %59, label %60, label %63

60:                                               ; preds = %57
  %61 = load float, ptr %15, align 4, !tbaa !9
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  store float %61, ptr %62, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %60, %57, %54
  %64 = load float, ptr %16, align 4, !tbaa !9
  %65 = load float, ptr %15, align 4, !tbaa !9
  %66 = fcmp oeq float %64, %65
  br i1 %66, label %67, label %73

67:                                               ; preds = %63
  %68 = load float, ptr %16, align 4, !tbaa !9
  %69 = fcmp une float %68, 0.000000e+00
  br i1 %69, label %70, label %73

70:                                               ; preds = %67
  %71 = load float, ptr %16, align 4, !tbaa !9
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  store float %71, ptr %72, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %70, %67, %63
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  br label %74

74:                                               ; preds = %73, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  br label %75

75:                                               ; preds = %74, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 240, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 400, ptr %8) #2
  %76 = load i32, ptr %4, align 4
  ret i32 %76
}

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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}


; 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: 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_get_bfield(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @segy_trace0(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_sample_interval(ptr noundef %0, float noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = alloca [400 x i8], align 16
  %5 = alloca [240 x i8], align 16
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %4) #2
  call void @llvm.lifetime.start.p0(i64 240, ptr nonnull %5) #2
  %8 = call i32 @segy_binheader(ptr noundef %0, ptr noundef nonnull %4)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %24

9:                                                ; preds = %3
  %10 = call i64 @segy_trace0(ptr noundef nonnull %4)
  %11 = call i32 @segy_traceheader(ptr noundef %0, i32 noundef 0, ptr noundef nonnull %5, i64 noundef %10, i32 noundef 0)
  %.not32 = icmp eq i32 %11, 0
  br i1 %.not32, label %12, label %24

12:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #2
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #2
  store i32 0, ptr %7, align 4, !tbaa !5
  %13 = call i32 @segy_get_bfield(ptr noundef nonnull %4, i32 noundef 3217, ptr noundef nonnull %6)
  %14 = call i32 @segy_get_field(ptr noundef nonnull %5, i32 noundef 117, ptr noundef nonnull %7)
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = sitofp i32 %15 to float
  %17 = load i32, ptr %7, align 4, !tbaa !5
  %18 = sitofp i32 %17 to float
  %19 = icmp eq i32 %15, 0
  %20 = icmp ne i32 %17, 0
  %or.cond = select i1 %19, i1 %20, i1 false
  %storemerge = select i1 %or.cond, float %18, float %1
  %21 = icmp eq i32 %17, 0
  %22 = icmp ne i32 %15, 0
  %or.cond3 = and i1 %22, %21
  %storemerge33 = select i1 %or.cond3, float %16, float %storemerge
  %23 = fcmp oeq float %18, %16
  %or.cond5 = and i1 %20, %23
  %storemerge34 = select i1 %or.cond5, float %18, float %storemerge33
  store float %storemerge34, ptr %2, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #2
  br label %24

24:                                               ; preds = %12, %9, %3
  %.1 = phi i32 [ %8, %3 ], [ 0, %12 ], [ %11, %9 ]
  call void @llvm.lifetime.end.p0(i64 240, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %4) #2
  ret i32 %.1
}

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 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}


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