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

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

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

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

declare i32 @close(i32 noundef) #2

; 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
define dso_local i32 @gsd_create_and_open(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #3 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store i32 %4, ptr %13, align 4, !tbaa !9
  store i32 %5, ptr %14, align 4, !tbaa !9
  store i32 %6, ptr %15, align 4, !tbaa !9
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  call void @gsd_util_zero_memory(ptr noundef %19, i64 noundef 536)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !9
  %20 = load i32, ptr %14, align 4, !tbaa !9
  %21 = icmp eq i32 %20, 1
  br i1 %21, label %22, label %25

22:                                               ; preds = %7
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.gsd_handle, ptr %23, i32 0, i32 10
  store i32 1, ptr %24, align 8, !tbaa !11
  br label %37

25:                                               ; preds = %7
  %26 = load i32, ptr %14, align 4, !tbaa !9
  %27 = icmp eq i32 %26, 2
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  store i32 -8, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %90

29:                                               ; preds = %25
  %30 = load i32, ptr %14, align 4, !tbaa !9
  %31 = icmp eq i32 %30, 3
  br i1 %31, label %32, label %35

32:                                               ; preds = %29
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.gsd_handle, ptr %33, i32 0, i32 10
  store i32 3, ptr %34, align 8, !tbaa !11
  br label %35

35:                                               ; preds = %32, %29
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36, %22
  %38 = load i32, ptr %15, align 4, !tbaa !9
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %43

40:                                               ; preds = %37
  %41 = load i32, ptr %16, align 4, !tbaa !9
  %42 = or i32 %41, 128
  store i32 %42, ptr %16, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %40, %37
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = load i32, ptr %16, align 4, !tbaa !9
  %46 = or i32 578, %45
  %47 = call i32 @gsd_open_file(ptr noundef %44, i32 noundef %46, i32 noundef 432)
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.gsd_handle, ptr %48, i32 0, i32 0
  store i32 %47, ptr %49, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.gsd_handle, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 8, !tbaa !19
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = call i32 @gsd_initialize_file(i32 noundef %52, ptr noundef %53, ptr noundef %54, i32 noundef %55)
  store i32 %56, ptr %18, align 4, !tbaa !9
  %57 = load i32, ptr %18, align 4, !tbaa !9
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %71

59:                                               ; preds = %43
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.gsd_handle, ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 8, !tbaa !19
  %63 = icmp ne i32 %62, -1
  br i1 %63, label %64, label %69

64:                                               ; preds = %59
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.gsd_handle, ptr %65, i32 0, i32 0
  %67 = load i32, ptr %66, align 8, !tbaa !19
  %68 = call i32 @close(i32 noundef %67)
  br label %69

69:                                               ; preds = %64, %59
  %70 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %70, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %89

71:                                               ; preds = %43
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = call i32 @gsd_initialize_handle(ptr noundef %72)
  store i32 %73, ptr %18, align 4, !tbaa !9
  %74 = load i32, ptr %18, align 4, !tbaa !9
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %87

76:                                               ; preds = %71
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.gsd_handle, ptr %77, i32 0, i32 0
  %79 = load i32, ptr %78, align 8, !tbaa !19
  %80 = icmp ne i32 %79, -1
  br i1 %80, label %81, label %86

81:                                               ; preds = %76
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.gsd_handle, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 8, !tbaa !19
  %85 = call i32 @close(i32 noundef %84)
  br label %86

86:                                               ; preds = %81, %76
  br label %87

87:                                               ; preds = %86, %71
  %88 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %88, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %89

89:                                               ; preds = %87, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %90

90:                                               ; preds = %89, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  %91 = load i32, ptr %8, align 4
  ret i32 %91
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @gsd_util_zero_memory(ptr noundef, i64 noundef) #1

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 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 = { 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, !10, i64 488}
!12 = !{!"gsd_handle", !10, i64 0, !13, i64 8, !15, i64 264, !15, i64 304, !15, i64 344, !16, i64 384, !17, i64 408, !17, i64 440, !14, i64 472, !14, i64 480, !10, i64 488, !18, i64 496, !14, i64 512, !14, i64 520, !14, i64 528}
!13 = !{!"gsd_header", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !10, i64 40, !10, i64 44, !7, i64 48, !7, i64 112, !7, i64 176}
!14 = !{!"long", !7, i64 0}
!15 = !{!"gsd_index_buffer", !6, i64 0, !14, i64 8, !14, i64 16, !6, i64 24, !14, i64 32}
!16 = !{!"gsd_byte_buffer", !6, i64 0, !14, i64 8, !14, i64 16}
!17 = !{!"gsd_name_buffer", !16, i64 0, !14, i64 24}
!18 = !{!"gsd_name_id_map", !6, i64 0, !14, i64 8}
!19 = !{!12, !10, 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: inlinehint nounwind uwtable
declare hidden i32 @gsd_open_file(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @gsd_initialize_file(i32 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @close(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @gsd_create_and_open(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #2 {
  tail call void @gsd_util_zero_memory(ptr noundef %0, i64 noundef 536)
  switch i32 %5, label %9 [
    i32 1, label %.sink.split
    i32 2, label %19
    i32 3, label %.sink.split
  ]

.sink.split:                                      ; preds = %7, %7
  %8 = getelementptr inbounds i8, ptr %0, i64 488
  store i32 %5, ptr %8, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %.sink.split, %7
  %.not = icmp eq i32 %6, 0
  %spec.select = select i1 %.not, i32 578, i32 706
  %10 = tail call i32 @gsd_open_file(ptr noundef %1, i32 noundef %spec.select, i32 noundef 432)
  store i32 %10, ptr %0, align 8, !tbaa !17
  %11 = tail call i32 @gsd_initialize_file(i32 noundef %10, ptr noundef %2, ptr noundef %3, i32 noundef %4)
  %.not29 = icmp eq i32 %11, 0
  br i1 %.not29, label %14, label %12

12:                                               ; preds = %9
  %13 = load i32, ptr %0, align 8, !tbaa !17
  %.not32 = icmp eq i32 %13, -1
  br i1 %.not32, label %19, label %.sink.split34

14:                                               ; preds = %9
  %15 = tail call i32 @gsd_initialize_handle(ptr noundef nonnull %0)
  %.not30 = icmp eq i32 %15, 0
  br i1 %.not30, label %19, label %16

16:                                               ; preds = %14
  %17 = load i32, ptr %0, align 8, !tbaa !17
  %.not31 = icmp eq i32 %17, -1
  br i1 %.not31, label %19, label %.sink.split34

.sink.split34:                                    ; preds = %16, %12
  %.sink35 = phi i32 [ %13, %12 ], [ %17, %16 ]
  %.1.ph = phi i32 [ %11, %12 ], [ %15, %16 ]
  %18 = tail call i32 @close(i32 noundef %.sink35) #3
  br label %19

19:                                               ; preds = %.sink.split34, %12, %16, %14, %7
  %.1 = phi i32 [ -8, %7 ], [ %11, %12 ], [ %15, %16 ], [ 0, %14 ], [ %.1.ph, %.sink.split34 ]
  ret i32 %.1
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @gsd_util_zero_memory(ptr noundef, i64 noundef) local_unnamed_addr #0

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

attributes #0 = { 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 #1 = { "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 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 }

!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}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass