; LLVM IR from glotzerlab/hoomd-blue :: hoomd/extern (gsd)

; 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.gsd_handle = type { i32, %struct.gsd_header, %struct.gsd_index_buffer, %struct.gsd_index_buffer, %struct.gsd_index_buffer, %struct.gsd_byte_buffer, %struct.gsd_name_buffer, %struct.gsd_name_buffer, i64, i64, i32, %struct.gsd_name_id_map, i64, i64, i64 }
%struct.gsd_header = type { i64, i64, i64, i64, i64, i32, i32, [64 x i8], [64 x i8], [80 x i8] }
%struct.gsd_index_buffer = type { ptr, i64, i64, ptr, i64 }
%struct.gsd_byte_buffer = type { ptr, i64, i64 }
%struct.gsd_name_buffer = type { %struct.gsd_byte_buffer, i64 }
%struct.gsd_name_id_map = type { ptr, i64 }
%struct.gsd_index_entry = type { i64, i64, i64, i32, i16, i8, i8 }

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @gsd_flush(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %1
  store i32 -2, ptr %2, align 4
  br label %180

14:                                               ; preds = %1
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.gsd_handle, ptr %15, i32 0, i32 10
  %17 = load i32, ptr %16, align 8, !tbaa !9
  %18 = icmp eq i32 %17, 2
  br i1 %18, label %19, label %20

19:                                               ; preds = %14
  store i32 -8, ptr %2, align 4
  br label %180

20:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = call i32 @gsd_flush_name_buffer(ptr noundef %21)
  store i32 %22, ptr %4, align 4, !tbaa !18
  %23 = load i32, ptr %4, align 4, !tbaa !18
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %27

25:                                               ; preds = %20
  %26 = load i32, ptr %4, align 4, !tbaa !18
  store i32 %26, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %179

27:                                               ; preds = %20
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = call i32 @gsd_flush_write_buffer(ptr noundef %28)
  store i32 %29, ptr %4, align 4, !tbaa !18
  %30 = load i32, ptr %4, align 4, !tbaa !18
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %34

32:                                               ; preds = %27
  %33 = load i32, ptr %4, align 4, !tbaa !18
  store i32 %33, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %179

34:                                               ; preds = %27
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.gsd_handle, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !19
  %38 = call i32 @fsync(i32 noundef %37)
  store i32 %38, ptr %4, align 4, !tbaa !18
  %39 = load i32, ptr %4, align 4, !tbaa !18
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %34
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %179

42:                                               ; preds = %34
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.gsd_handle, ptr %43, i32 0, i32 12
  %45 = load i64, ptr %44, align 8, !tbaa !20
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.gsd_handle, ptr %46, i32 0, i32 3
  %48 = getelementptr inbounds %struct.gsd_index_buffer, ptr %47, i32 0, i32 1
  %49 = load i64, ptr %48, align 8, !tbaa !21
  %50 = icmp ugt i64 %45, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %42
  store i32 -2, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %179

52:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.gsd_handle, ptr %53, i32 0, i32 3
  %55 = getelementptr inbounds %struct.gsd_index_buffer, ptr %54, i32 0, i32 1
  %56 = load i64, ptr %55, align 8, !tbaa !21
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.gsd_handle, ptr %57, i32 0, i32 12
  %59 = load i64, ptr %58, align 8, !tbaa !20
  %60 = sub i64 %56, %59
  store i64 %60, ptr %6, align 8, !tbaa !22
  %61 = load i64, ptr %6, align 8, !tbaa !22
  %62 = icmp ugt i64 %61, 0
  br i1 %62, label %63, label %177

63:                                               ; preds = %52
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.gsd_handle, ptr %64, i32 0, i32 2
  %66 = getelementptr inbounds %struct.gsd_index_buffer, ptr %65, i32 0, i32 1
  %67 = load i64, ptr %66, align 8, !tbaa !23
  %68 = load i64, ptr %6, align 8, !tbaa !22
  %69 = add i64 %67, %68
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.gsd_handle, ptr %70, i32 0, i32 2
  %72 = getelementptr inbounds %struct.gsd_index_buffer, ptr %71, i32 0, i32 2
  %73 = load i64, ptr %72, align 8, !tbaa !24
  %74 = icmp ugt i64 %69, %73
  br i1 %74, label %75, label %84

75:                                               ; preds = %63
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.gsd_handle, ptr %77, i32 0, i32 2
  %79 = getelementptr inbounds %struct.gsd_index_buffer, ptr %78, i32 0, i32 1
  %80 = load i64, ptr %79, align 8, !tbaa !23
  %81 = load i64, ptr %6, align 8, !tbaa !22
  %82 = add i64 %80, %81
  %83 = call i32 @gsd_expand_file_index(ptr noundef %76, i64 noundef %82)
  br label %84

84:                                               ; preds = %75, %63
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.gsd_handle, ptr %85, i32 0, i32 3
  %87 = call i32 @gsd_index_buffer_sort(ptr noundef %86)
  store i32 %87, ptr %4, align 4, !tbaa !18
  %88 = load i32, ptr %4, align 4, !tbaa !18
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %90, label %92

90:                                               ; preds = %84
  %91 = load i32, ptr %4, align 4, !tbaa !18
  store i32 %91, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %178

92:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.gsd_handle, ptr %93, i32 0, i32 1
  %95 = getelementptr inbounds %struct.gsd_header, ptr %94, i32 0, i32 1
  %96 = load i64, ptr %95, align 8, !tbaa !25
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.gsd_handle, ptr %97, i32 0, i32 2
  %99 = getelementptr inbounds %struct.gsd_index_buffer, ptr %98, i32 0, i32 1
  %100 = load i64, ptr %99, align 8, !tbaa !23
  %101 = mul i64 32, %100
  %102 = add i64 %96, %101
  store i64 %102, ptr %7, align 8, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %103 = load i64, ptr %6, align 8, !tbaa !22
  %104 = mul i64 32, %103
  store i64 %104, ptr %8, align 8, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.gsd_handle, ptr %105, i32 0, i32 0
  %107 = load i32, ptr %106, align 8, !tbaa !19
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.gsd_handle, ptr %108, i32 0, i32 3
  %110 = getelementptr inbounds %struct.gsd_index_buffer, ptr %109, i32 0, i32 0
  %111 = load ptr, ptr %110, align 8, !tbaa !26
  %112 = load i64, ptr %8, align 8, !tbaa !22
  %113 = load i64, ptr %7, align 8, !tbaa !22
  %114 = call i64 @gsd_io_pwrite_retry(i32 noundef %107, ptr noundef %111, i64 noundef %112, i64 noundef %113)
  store i64 %114, ptr %9, align 8, !tbaa !22
  %115 = load i64, ptr %9, align 8, !tbaa !22
  %116 = icmp eq i64 %115, -1
  br i1 %116, label %121, label %117

117:                                              ; preds = %92
  %118 = load i64, ptr %9, align 8, !tbaa !22
  %119 = load i64, ptr %8, align 8, !tbaa !22
  %120 = icmp ne i64 %118, %119
  br i1 %120, label %121, label %122

121:                                              ; preds = %117, %92
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %174

122:                                              ; preds = %117
  %123 = load i64, ptr %6, align 8, !tbaa !22
  %124 = load ptr, ptr %3, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.gsd_handle, ptr %124, i32 0, i32 2
  %126 = getelementptr inbounds %struct.gsd_index_buffer, ptr %125, i32 0, i32 1
  %127 = load i64, ptr %126, align 8, !tbaa !23
  %128 = add i64 %127, %123
  store i64 %128, ptr %126, align 8, !tbaa !23
  %129 = load ptr, ptr %3, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.gsd_handle, ptr %129, i32 0, i32 12
  %131 = load i64, ptr %130, align 8, !tbaa !20
  %132 = icmp ugt i64 %131, 0
  br i1 %132, label %133, label %167

133:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store i64 0, ptr %10, align 8, !tbaa !22
  br label %134

134:                                              ; preds = %163, %133
  %135 = load i64, ptr %10, align 8, !tbaa !22
  %136 = load ptr, ptr %3, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.gsd_handle, ptr %136, i32 0, i32 12
  %138 = load i64, ptr %137, align 8, !tbaa !20
  %139 = icmp ult i64 %135, %138
  br i1 %139, label %141, label %140

140:                                              ; preds = %134
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %166

141:                                              ; preds = %134
  %142 = load ptr, ptr %3, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.gsd_handle, ptr %142, i32 0, i32 3
  %144 = getelementptr inbounds %struct.gsd_index_buffer, ptr %143, i32 0, i32 0
  %145 = load ptr, ptr %144, align 8, !tbaa !26
  %146 = load i64, ptr %10, align 8, !tbaa !22
  %147 = getelementptr inbounds %struct.gsd_index_entry, ptr %145, i64 %146
  %148 = load ptr, ptr %3, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.gsd_handle, ptr %148, i32 0, i32 3
  %150 = getelementptr inbounds %struct.gsd_index_buffer, ptr %149, i32 0, i32 0
  %151 = load ptr, ptr %150, align 8, !tbaa !26
  %152 = load ptr, ptr %3, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.gsd_handle, ptr %152, i32 0, i32 3
  %154 = getelementptr inbounds %struct.gsd_index_buffer, ptr %153, i32 0, i32 1
  %155 = load i64, ptr %154, align 8, !tbaa !21
  %156 = load ptr, ptr %3, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.gsd_handle, ptr %156, i32 0, i32 12
  %158 = load i64, ptr %157, align 8, !tbaa !20
  %159 = sub i64 %155, %158
  %160 = load i64, ptr %10, align 8, !tbaa !22
  %161 = add i64 %159, %160
  %162 = getelementptr inbounds %struct.gsd_index_entry, ptr %151, i64 %161
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %147, ptr align 8 %162, i64 32, i1 false), !tbaa.struct !27
  br label %163

163:                                              ; preds = %141
  %164 = load i64, ptr %10, align 8, !tbaa !22
  %165 = add i64 %164, 1
  store i64 %165, ptr %10, align 8, !tbaa !22
  br label %134, !llvm.loop !31

166:                                              ; preds = %140
  br label %167

167:                                              ; preds = %166, %122
  %168 = load ptr, ptr %3, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.gsd_handle, ptr %168, i32 0, i32 12
  %170 = load i64, ptr %169, align 8, !tbaa !20
  %171 = load ptr, ptr %3, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.gsd_handle, ptr %171, i32 0, i32 3
  %173 = getelementptr inbounds %struct.gsd_index_buffer, ptr %172, i32 0, i32 1
  store i64 %170, ptr %173, align 8, !tbaa !21
  store i32 0, ptr %5, align 4
  br label %174

174:                                              ; preds = %167, %121
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %175 = load i32, ptr %5, align 4
  switch i32 %175, label %178 [
    i32 0, label %176
  ]

176:                                              ; preds = %174
  br label %177

177:                                              ; preds = %176, %52
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %178

178:                                              ; preds = %177, %174, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %179

179:                                              ; preds = %178, %51, %41, %32, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %180

180:                                              ; preds = %179, %19, %13
  %181 = load i32, ptr %2, align 4
  ret i32 %181
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @gsd_flush_name_buffer(ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @gsd_flush_write_buffer(ptr noundef) #3

declare i32 @fsync(i32 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @gsd_expand_file_index(ptr noundef, i64 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @gsd_index_buffer_sort(ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @gsd_io_pwrite_retry(i32 noundef, ptr noundef, i64 noundef, i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree 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 = { inlinehint 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 #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 = { 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, !11, i64 488}
!10 = !{!"gsd_handle", !11, i64 0, !12, i64 8, !14, i64 264, !14, i64 304, !14, i64 344, !15, i64 384, !16, i64 408, !16, i64 440, !13, i64 472, !13, i64 480, !11, i64 488, !17, i64 496, !13, i64 512, !13, i64 520, !13, i64 528}
!11 = !{!"int", !7, i64 0}
!12 = !{!"gsd_header", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !11, i64 40, !11, i64 44, !7, i64 48, !7, i64 112, !7, i64 176}
!13 = !{!"long", !7, i64 0}
!14 = !{!"gsd_index_buffer", !6, i64 0, !13, i64 8, !13, i64 16, !6, i64 24, !13, i64 32}
!15 = !{!"gsd_byte_buffer", !6, i64 0, !13, i64 8, !13, i64 16}
!16 = !{!"gsd_name_buffer", !15, i64 0, !13, i64 24}
!17 = !{!"gsd_name_id_map", !6, i64 0, !13, i64 8}
!18 = !{!11, !11, i64 0}
!19 = !{!10, !11, i64 0}
!20 = !{!10, !13, i64 512}
!21 = !{!10, !13, i64 312}
!22 = !{!13, !13, i64 0}
!23 = !{!10, !13, i64 272}
!24 = !{!10, !13, i64 280}
!25 = !{!10, !13, i64 16}
!26 = !{!10, !6, i64 304}
!27 = !{i64 0, i64 8, !22, i64 8, i64 8, !22, i64 16, i64 8, !22, i64 24, i64 4, !18, i64 28, i64 2, !28, i64 30, i64 1, !30, i64 31, i64 1, !30}
!28 = !{!29, !29, i64 0}
!29 = !{!"short", !7, i64 0}
!30 = !{!7, !7, i64 0}
!31 = distinct !{!31, !32}
!32 = !{!"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"

%struct.gsd_index_entry = type { i64, i64, i64, i32, i16, i8, i8 }

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @gsd_flush(ptr noundef %0) local_unnamed_addr #1 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %59, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 488
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i32 %5, 2
  br i1 %6, label %59, label %7

7:                                                ; preds = %3
  %8 = tail call i32 @gsd_flush_name_buffer(ptr noundef nonnull %0)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %59

9:                                                ; preds = %7
  %10 = tail call i32 @gsd_flush_write_buffer(ptr noundef nonnull %0)
  %.not61 = icmp eq i32 %10, 0
  br i1 %.not61, label %11, label %59

11:                                               ; preds = %9
  %12 = load i32, ptr %0, align 8, !tbaa !17
  %13 = tail call i32 @fsync(i32 noundef %12) #4
  %.not62 = icmp eq i32 %13, 0
  br i1 %.not62, label %14, label %59

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %0, i64 512
  %16 = load i64, ptr %15, align 8, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %0, i64 304
  %18 = getelementptr inbounds i8, ptr %0, i64 312
  %19 = load i64, ptr %18, align 8, !tbaa !19
  %20 = icmp ugt i64 %16, %19
  br i1 %20, label %59, label %21

21:                                               ; preds = %14
  %22 = sub i64 %19, %16
  %.not63 = icmp eq i64 %19, %16
  br i1 %.not63, label %59, label %23

23:                                               ; preds = %21
  %24 = getelementptr inbounds i8, ptr %0, i64 272
  %25 = load i64, ptr %24, align 8, !tbaa !20
  %26 = add i64 %25, %22
  %27 = getelementptr inbounds i8, ptr %0, i64 280
  %28 = load i64, ptr %27, align 8, !tbaa !21
  %29 = icmp ugt i64 %26, %28
  br i1 %29, label %30, label %32

30:                                               ; preds = %23
  %31 = tail call i32 @gsd_expand_file_index(ptr noundef nonnull %0, i64 noundef %26)
  br label %32

32:                                               ; preds = %30, %23
  %33 = tail call i32 @gsd_index_buffer_sort(ptr noundef nonnull %17)
  %.not64 = icmp eq i32 %33, 0
  br i1 %.not64, label %34, label %59

34:                                               ; preds = %32
  %35 = getelementptr inbounds i8, ptr %0, i64 16
  %36 = load i64, ptr %35, align 8, !tbaa !22
  %37 = load i64, ptr %24, align 8, !tbaa !20
  %38 = shl i64 %37, 5
  %39 = add i64 %38, %36
  %40 = shl i64 %22, 5
  %41 = load i32, ptr %0, align 8, !tbaa !17
  %42 = load ptr, ptr %17, align 8, !tbaa !23
  %43 = tail call i64 @gsd_io_pwrite_retry(i32 noundef %41, ptr noundef %42, i64 noundef %40, i64 noundef %39)
  %.not65 = icmp eq i64 %43, %40
  br i1 %.not65, label %44, label %59

44:                                               ; preds = %34
  %45 = load i64, ptr %24, align 8, !tbaa !20
  %46 = add i64 %45, %22
  store i64 %46, ptr %24, align 8, !tbaa !20
  %47 = load i64, ptr %15, align 8, !tbaa !18
  %.not66 = icmp eq i64 %47, 0
  br i1 %.not66, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %44, %.lr.ph
  %48 = phi i64 [ %56, %.lr.ph ], [ %47, %44 ]
  %.067 = phi i64 [ %55, %.lr.ph ], [ 0, %44 ]
  %49 = load ptr, ptr %17, align 8, !tbaa !23
  %50 = getelementptr inbounds %struct.gsd_index_entry, ptr %49, i64 %.067
  %51 = load i64, ptr %18, align 8, !tbaa !19
  %52 = sub i64 %51, %48
  %53 = getelementptr %struct.gsd_index_entry, ptr %49, i64 %52
  %54 = getelementptr %struct.gsd_index_entry, ptr %53, i64 %.067
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %50, ptr noundef nonnull align 8 dereferenceable(32) %54, i64 32, i1 false), !tbaa.struct !24
  %55 = add nuw i64 %.067, 1
  %56 = load i64, ptr %15, align 8, !tbaa !18
  %57 = icmp ult i64 %55, %56
  br i1 %57, label %.lr.ph, label %.critedge, !llvm.loop !30

.critedge:                                        ; preds = %.lr.ph, %44
  %58 = phi i64 [ 0, %44 ], [ %56, %.lr.ph ]
  store i64 %58, ptr %18, align 8, !tbaa !19
  br label %59

59:                                               ; preds = %7, %9, %11, %14, %21, %.critedge, %34, %32, %3, %1
  %.3 = phi i32 [ -2, %1 ], [ -8, %3 ], [ %8, %7 ], [ %10, %9 ], [ -1, %11 ], [ -2, %14 ], [ %33, %32 ], [ -1, %34 ], [ 0, %.critedge ], [ 0, %21 ]
  ret i32 %.3
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @gsd_flush_name_buffer(ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @gsd_flush_write_buffer(ptr noundef) local_unnamed_addr #2

declare i32 @fsync(i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @gsd_expand_file_index(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @gsd_index_buffer_sort(ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @gsd_io_pwrite_retry(i32 noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree 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 = { inlinehint 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 = { "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 }

!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, !7, i64 488}
!6 = !{!"gsd_handle", !7, i64 0, !10, i64 8, !12, i64 264, !12, i64 304, !12, i64 344, !14, i64 384, !15, i64 408, !15, i64 440, !11, i64 472, !11, i64 480, !7, i64 488, !16, i64 496, !11, i64 512, !11, i64 520, !11, i64 528}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"gsd_header", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !7, i64 40, !7, i64 44, !8, i64 48, !8, i64 112, !8, i64 176}
!11 = !{!"long", !8, i64 0}
!12 = !{!"gsd_index_buffer", !13, i64 0, !11, i64 8, !11, i64 16, !13, i64 24, !11, i64 32}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"gsd_byte_buffer", !13, i64 0, !11, i64 8, !11, i64 16}
!15 = !{!"gsd_name_buffer", !14, i64 0, !11, i64 24}
!16 = !{!"gsd_name_id_map", !13, i64 0, !11, i64 8}
!17 = !{!6, !7, i64 0}
!18 = !{!6, !11, i64 512}
!19 = !{!6, !11, i64 312}
!20 = !{!6, !11, i64 272}
!21 = !{!6, !11, i64 280}
!22 = !{!6, !11, i64 16}
!23 = !{!6, !13, i64 304}
!24 = !{i64 0, i64 8, !25, i64 8, i64 8, !25, i64 16, i64 8, !25, i64 24, i64 4, !26, i64 28, i64 2, !27, i64 30, i64 1, !29, i64 31, i64 1, !29}
!25 = !{!11, !11, i64 0}
!26 = !{!7, !7, i64 0}
!27 = !{!28, !28, i64 0}
!28 = !{!"short", !8, i64 0}
!29 = !{!8, !8, i64 0}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass