; LLVM IR from Tinker-Twins/3D-LIDAR-Localization :: fast_gicp/thirdparty/nvbio/contrib/htslib/cram (zfio)

; 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.zfp = type { ptr, ptr }

@.str = external hidden unnamed_addr constant [8 x i8], align 1

declare i32 @fseeko(ptr noundef, i64 noundef, i32 noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @zfopen(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [1024 x i8], align 16
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca [2 x i8], align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %10 = call noalias ptr @malloc(i64 noundef 16) #6
  store ptr %10, ptr %7, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %95

13:                                               ; preds = %2
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.zfp, ptr %14, i32 0, i32 0
  store ptr null, ptr %15, align 8, !tbaa !9
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.zfp, ptr %16, i32 0, i32 1
  store ptr null, ptr %17, align 8, !tbaa !11
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 0
  %20 = load i8, ptr %19, align 1, !tbaa !12
  %21 = sext i8 %20 to i32
  %22 = icmp ne i32 %21, 122
  br i1 %22, label %23, label %71

23:                                               ; preds = %13
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 1
  %26 = load i8, ptr %25, align 1, !tbaa !12
  %27 = sext i8 %26 to i32
  %28 = icmp ne i32 %27, 122
  br i1 %28, label %29, label %71

29:                                               ; preds = %23
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call noalias ptr @fopen(ptr noundef %30, ptr noundef %31)
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.zfp, ptr %33, i32 0, i32 0
  store ptr %32, ptr %34, align 8, !tbaa !9
  %35 = icmp ne ptr null, %32
  br i1 %35, label %36, label %71

36:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 2, ptr %9) #5
  %37 = getelementptr inbounds [2 x i8], ptr %9, i64 0, i64 0
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.zfp, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !9
  %41 = call i64 @fread(ptr noundef %37, i64 noundef 1, i64 noundef 2, ptr noundef %40)
  %42 = icmp ne i64 2, %41
  br i1 %42, label %43, label %45

43:                                               ; preds = %36
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %44) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %68

45:                                               ; preds = %36
  %46 = getelementptr inbounds [2 x i8], ptr %9, i64 0, i64 0
  %47 = load i8, ptr %46, align 1, !tbaa !12
  %48 = zext i8 %47 to i32
  %49 = icmp eq i32 %48, 31
  br i1 %49, label %50, label %55

50:                                               ; preds = %45
  %51 = getelementptr inbounds [2 x i8], ptr %9, i64 0, i64 1
  %52 = load i8, ptr %51, align 1, !tbaa !12
  %53 = zext i8 %52 to i32
  %54 = icmp eq i32 %53, 139
  br i1 %54, label %61, label %55

55:                                               ; preds = %50, %45
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.zfp, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !9
  %59 = call i32 @fseeko(ptr noundef %58, i64 noundef 0, i32 noundef 0)
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %60, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %68

61:                                               ; preds = %50
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.zfp, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !9
  %65 = call i32 @fclose(ptr noundef %64)
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.zfp, ptr %66, i32 0, i32 0
  store ptr null, ptr %67, align 8, !tbaa !9
  store i32 0, ptr %8, align 4
  br label %68

68:                                               ; preds = %61, %55, %43
  call void @llvm.lifetime.end.p0(i64 2, ptr %9) #5
  %69 = load i32, ptr %8, align 4
  switch i32 %69, label %95 [
    i32 0, label %70
  ]

70:                                               ; preds = %68
  br label %71

71:                                               ; preds = %70, %29, %23, %13
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = call ptr @gzopen(ptr noundef %72, ptr noundef %73)
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.zfp, ptr %75, i32 0, i32 1
  store ptr %74, ptr %76, align 8, !tbaa !11
  %77 = icmp ne ptr %74, null
  br i1 %77, label %78, label %80

78:                                               ; preds = %71
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %79, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %95

80:                                               ; preds = %71
  %81 = getelementptr inbounds [1024 x i8], ptr %6, i64 0, i64 0
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %81, ptr noundef @.str, i32 noundef 1020, ptr noundef %82) #5
  %84 = getelementptr inbounds [1024 x i8], ptr %6, i64 0, i64 0
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = call ptr @gzopen(ptr noundef %84, ptr noundef %85)
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.zfp, ptr %87, i32 0, i32 1
  store ptr %86, ptr %88, align 8, !tbaa !11
  %89 = icmp ne ptr %86, null
  br i1 %89, label %90, label %92

90:                                               ; preds = %80
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %91, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %95

92:                                               ; preds = %80
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  call void @perror(ptr noundef %93)
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %94) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %95

95:                                               ; preds = %92, %90, %78, %68, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %6) #5
  %96 = load ptr, ptr %3, align 8
  ret ptr %96
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

declare noalias ptr @fopen(ptr noundef, ptr noundef) #0

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #0

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

declare i32 @fclose(ptr noundef) #0

declare ptr @gzopen(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #4

declare void @perror(ptr noundef) #0

attributes #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 = { 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 #3 = { nounwind allocsize(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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 8}
!11 = !{!10, !6, i64 8}
!12 = !{!7, !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"

@.str = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fseeko(ptr nocapture noundef, i64 noundef, i32 noundef) local_unnamed_addr #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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @zfopen(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca [1024 x i8], align 16
  %4 = alloca [2 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %3) #6
  %calloc = tail call dereferenceable_or_null(16) ptr @calloc(i64 1, i64 16)
  %.not = icmp eq ptr %calloc, null
  br i1 %.not, label %32, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %calloc, i64 8
  %7 = load i8, ptr %1, align 1, !tbaa !5
  %.not29 = icmp eq i8 %7, 122
  br i1 %.not29, label %26, label %8

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %1, i64 1
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %.not30 = icmp eq i8 %10, 122
  br i1 %.not30, label %26, label %11

11:                                               ; preds = %8
  %12 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull %1)
  store ptr %12, ptr %calloc, align 8, !tbaa !8
  %.not31 = icmp eq ptr %12, null
  br i1 %.not31, label %26, label %13

13:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %4) #6
  %14 = call i64 @fread(ptr noundef nonnull %4, i64 noundef 1, i64 noundef 2, ptr noundef nonnull %12)
  %.not32 = icmp eq i64 %14, 2
  br i1 %.not32, label %16, label %15

15:                                               ; preds = %13
  tail call void @free(ptr noundef nonnull %calloc) #6
  br label %.thread

16:                                               ; preds = %13
  %17 = load i8, ptr %4, align 1, !tbaa !5
  %18 = icmp eq i8 %17, 31
  %19 = getelementptr inbounds i8, ptr %4, i64 1
  %20 = load i8, ptr %19, align 1
  %21 = icmp eq i8 %20, -117
  %or.cond = select i1 %18, i1 %21, i1 false
  br i1 %or.cond, label %24, label %22

22:                                               ; preds = %16
  %23 = tail call i32 @fseeko(ptr noundef nonnull %12, i64 noundef 0, i32 noundef 0)
  br label %.thread

.thread:                                          ; preds = %15, %22
  %.027.ph = phi ptr [ %calloc, %22 ], [ null, %15 ]
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %4) #6
  br label %32

24:                                               ; preds = %16
  %25 = tail call i32 @fclose(ptr noundef nonnull %12)
  store ptr null, ptr %calloc, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %4) #6
  br label %26

26:                                               ; preds = %24, %11, %8, %5
  %27 = tail call ptr @gzopen(ptr noundef %0, ptr noundef nonnull %1) #6
  store ptr %27, ptr %6, align 8, !tbaa !11
  %.not33 = icmp eq ptr %27, null
  br i1 %.not33, label %28, label %32

28:                                               ; preds = %26
  %29 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 1020, ptr noundef %0) #6
  %30 = call ptr @gzopen(ptr noundef nonnull %3, ptr noundef nonnull %1) #6
  store ptr %30, ptr %6, align 8, !tbaa !11
  %.not34 = icmp eq ptr %30, null
  br i1 %.not34, label %31, label %32

31:                                               ; preds = %28
  call void @perror(ptr noundef %0) #7
  call void @free(ptr noundef nonnull %calloc) #6
  br label %32

32:                                               ; preds = %.thread, %28, %26, %2, %31
  %.1 = phi ptr [ null, %31 ], [ null, %2 ], [ %calloc, %26 ], [ %calloc, %28 ], [ %.027.ph, %.thread ]
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %3) #6
  ret ptr %.1
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #0

declare ptr @gzopen(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare void @perror(ptr nocapture noundef readonly) local_unnamed_addr #0

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #5

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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 #5 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #6 = { nounwind }
attributes #7 = { cold }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"", !10, i64 0, !10, i64 8}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!9, !10, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass