; LLVM IR from ryanlayer/giggle :: src (disk_store)

; 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.disk_store = type { ptr, ptr, ptr, ptr, i32, i32, i64, i64, ptr, ptr, i8, ptr }

@.str.4 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) #0

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @disk_store_sync(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.disk_store, ptr %3, i32 0, i32 2
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.disk_store, ptr %6, i32 0, i32 6
  %8 = load i64, ptr %7, align 8, !tbaa !13
  %9 = call i32 @fseek(ptr noundef %5, i64 noundef %8, i32 noundef 0)
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %15

11:                                               ; preds = %1
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.disk_store, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.13, ptr noundef %14) #3
  unreachable

15:                                               ; preds = %1
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.disk_store, ptr %16, i32 0, i32 4
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.disk_store, ptr %18, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = call i64 @fwrite(ptr noundef %17, i64 noundef 4, i64 noundef 1, ptr noundef %20)
  %22 = icmp ne i64 %21, 1
  br i1 %22, label %23, label %27

23:                                               ; preds = %15
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.disk_store, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.4, ptr noundef %26) #3
  unreachable

27:                                               ; preds = %15
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.disk_store, ptr %28, i32 0, i32 5
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.disk_store, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = call i64 @fwrite(ptr noundef %29, i64 noundef 4, i64 noundef 1, ptr noundef %32)
  %34 = icmp ne i64 %33, 1
  br i1 %34, label %35, label %39

35:                                               ; preds = %27
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.disk_store, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.5, ptr noundef %38) #3
  unreachable

39:                                               ; preds = %27
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.disk_store, ptr %40, i32 0, i32 8
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.disk_store, ptr %43, i32 0, i32 4
  %45 = load i32, ptr %44, align 8, !tbaa !16
  %46 = zext i32 %45 to i64
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.disk_store, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = call i64 @fwrite(ptr noundef %42, i64 noundef 8, i64 noundef %46, ptr noundef %49)
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.disk_store, ptr %51, i32 0, i32 4
  %53 = load i32, ptr %52, align 8, !tbaa !16
  %54 = zext i32 %53 to i64
  %55 = icmp ne i64 %50, %54
  br i1 %55, label %56, label %60

56:                                               ; preds = %39
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.disk_store, ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !14
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.14, ptr noundef %59) #3
  unreachable

60:                                               ; preds = %39
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.disk_store, ptr %61, i32 0, i32 10
  %63 = load i8, ptr %62, align 8, !tbaa !17
  %64 = icmp ne i8 %63, 0
  br i1 %64, label %65, label %87

65:                                               ; preds = %60
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.disk_store, ptr %66, i32 0, i32 9
  %68 = load ptr, ptr %67, align 8, !tbaa !18
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.disk_store, ptr %69, i32 0, i32 4
  %71 = load i32, ptr %70, align 8, !tbaa !16
  %72 = zext i32 %71 to i64
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.disk_store, ptr %73, i32 0, i32 2
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  %76 = call i64 @fwrite(ptr noundef %68, i64 noundef 4, i64 noundef %72, ptr noundef %75)
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.disk_store, ptr %77, i32 0, i32 4
  %79 = load i32, ptr %78, align 8, !tbaa !16
  %80 = zext i32 %79 to i64
  %81 = icmp ne i64 %76, %80
  br i1 %81, label %82, label %86

82:                                               ; preds = %65
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.disk_store, ptr %83, i32 0, i32 0
  %85 = load ptr, ptr %84, align 8, !tbaa !14
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.15, ptr noundef %85) #3
  unreachable

86:                                               ; preds = %65
  br label %87

87:                                               ; preds = %86, %60
  ret void
}

declare i32 @fseek(ptr noundef, i64 noundef, i32 noundef) #1

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

!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 16}
!10 = !{!"disk_store", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !12, i64 40, !12, i64 48, !6, i64 56, !6, i64 64, !7, i64 72, !6, i64 80}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, i64 40}
!14 = !{!10, !6, i64 0}
!15 = !{!10, !6, i64 56}
!16 = !{!10, !11, i64 32}
!17 = !{!10, !7, i64 72}
!18 = !{!10, !6, i64 64}


; 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.4 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @disk_store_sync(ptr nocapture noundef %0) local_unnamed_addr #2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load i64, ptr %4, align 8, !tbaa !12
  %6 = tail call i32 @fseek(ptr noundef %3, i64 noundef %5, i32 noundef 0)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %9, label %7

7:                                                ; preds = %1
  %8 = load ptr, ptr %0, align 8, !tbaa !13
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.13, ptr noundef %8) #3
  unreachable

9:                                                ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = tail call i64 @fwrite(ptr noundef nonnull %10, i64 noundef 4, i64 noundef 1, ptr noundef %11)
  %.not20 = icmp eq i64 %12, 1
  br i1 %.not20, label %15, label %13

13:                                               ; preds = %9
  %14 = load ptr, ptr %0, align 8, !tbaa !13
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.4, ptr noundef %14) #3
  unreachable

15:                                               ; preds = %9
  %16 = getelementptr inbounds i8, ptr %0, i64 36
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = tail call i64 @fwrite(ptr noundef nonnull %16, i64 noundef 4, i64 noundef 1, ptr noundef %17)
  %.not21 = icmp eq i64 %18, 1
  br i1 %.not21, label %21, label %19

19:                                               ; preds = %15
  %20 = load ptr, ptr %0, align 8, !tbaa !13
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.5, ptr noundef %20) #3
  unreachable

21:                                               ; preds = %15
  %22 = getelementptr inbounds i8, ptr %0, i64 56
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = load i32, ptr %10, align 8, !tbaa !15
  %25 = zext i32 %24 to i64
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = tail call i64 @fwrite(ptr noundef %23, i64 noundef 8, i64 noundef %25, ptr noundef %26)
  %28 = load i32, ptr %10, align 8, !tbaa !15
  %29 = zext i32 %28 to i64
  %.not22 = icmp eq i64 %27, %29
  br i1 %.not22, label %32, label %30

30:                                               ; preds = %21
  %31 = load ptr, ptr %0, align 8, !tbaa !13
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.14, ptr noundef %31) #3
  unreachable

32:                                               ; preds = %21
  %33 = getelementptr inbounds i8, ptr %0, i64 72
  %34 = load i8, ptr %33, align 8, !tbaa !16
  %.not23 = icmp eq i8 %34, 0
  br i1 %.not23, label %44, label %35

35:                                               ; preds = %32
  %36 = getelementptr inbounds i8, ptr %0, i64 64
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = tail call i64 @fwrite(ptr noundef %37, i64 noundef 4, i64 noundef %27, ptr noundef %38)
  %40 = load i32, ptr %10, align 8, !tbaa !15
  %41 = zext i32 %40 to i64
  %.not24 = icmp eq i64 %39, %41
  br i1 %.not24, label %44, label %42

42:                                               ; preds = %35
  %43 = load ptr, ptr %0, align 8, !tbaa !13
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.15, ptr noundef %43) #3
  unreachable

44:                                               ; preds = %35, %32
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @fseek(ptr nocapture noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { noreturn "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 = { 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 #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 = { noreturn 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 16}
!6 = !{!"disk_store", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !11, i64 40, !11, i64 48, !7, i64 56, !7, i64 64, !8, i64 72, !7, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !11, i64 40}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !7, i64 56}
!15 = !{!6, !10, i64 32}
!16 = !{!6, !8, i64 72}
!17 = !{!6, !7, i64 64}


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