; LLVM IR from Gottox/sqsh-tools :: fuzzer (simple)

; 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.SqshConfig = type { i64, i64, ptr, i32, i32, i32, i64, i32, i32, [128 x i8] }

@sqsh_mapper_impl_static = external constant ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @LLVMFuzzerTestOneInput(ptr noundef %0, i64 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.SqshConfig, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store ptr null, ptr %9, align 8, !tbaa !5
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %10, i8 0, i64 184, i1 false)
  %16 = getelementptr inbounds %struct.SqshConfig, ptr %10, i32 0, i32 0
  %17 = getelementptr inbounds %struct.SqshConfig, ptr %10, i32 0, i32 1
  %18 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %18, ptr %17, align 8, !tbaa !13
  %19 = getelementptr inbounds %struct.SqshConfig, ptr %10, i32 0, i32 2
  %20 = load ptr, ptr @sqsh_mapper_impl_static, align 8, !tbaa !5
  store ptr %20, ptr %19, align 8, !tbaa !15
  %21 = getelementptr inbounds %struct.SqshConfig, ptr %10, i32 0, i32 3
  %22 = getelementptr inbounds %struct.SqshConfig, ptr %10, i32 0, i32 4
  %23 = getelementptr inbounds %struct.SqshConfig, ptr %10, i32 0, i32 5
  %24 = getelementptr inbounds %struct.SqshConfig, ptr %10, i32 0, i32 6
  %25 = getelementptr inbounds %struct.SqshConfig, ptr %10, i32 0, i32 7
  %26 = getelementptr inbounds %struct.SqshConfig, ptr %10, i32 0, i32 8
  %27 = getelementptr inbounds %struct.SqshConfig, ptr %10, i32 0, i32 9
  %28 = call ptr @sqsh_archive_open(ptr noundef %15, ptr noundef %10, ptr noundef %5)
  store ptr %28, ptr %6, align 8, !tbaa !5
  %29 = load i32, ptr %5, align 4, !tbaa !11
  %30 = icmp slt i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %2
  br label %75

32:                                               ; preds = %2
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = call ptr @sqsh_archive_superblock(ptr noundef %33)
  store ptr %34, ptr %9, align 8, !tbaa !5
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = call i64 @sqsh_superblock_inode_root_ref(ptr noundef %35)
  store i64 %36, ptr %11, align 8, !tbaa !9
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load i64, ptr %11, align 8, !tbaa !9
  %39 = call ptr @sqsh_open_by_ref(ptr noundef %37, i64 noundef %38, ptr noundef %5)
  store ptr %39, ptr %7, align 8, !tbaa !5
  %40 = load i32, ptr %5, align 4, !tbaa !11
  %41 = icmp slt i32 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %32
  br label %75

43:                                               ; preds = %32
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = call ptr @sqsh_tree_traversal_new(ptr noundef %44, ptr noundef %5)
  store ptr %45, ptr %8, align 8, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !11
  %47 = icmp slt i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %43
  br label %75

49:                                               ; preds = %43
  br label %50

50:                                               ; preds = %73, %49
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = call zeroext i1 @sqsh_tree_traversal_next(ptr noundef %51, ptr noundef %5)
  br i1 %52, label %53, label %74

53:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %54

54:                                               ; preds = %65, %53
  %55 = load i64, ptr %12, align 8, !tbaa !9
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = call i64 @sqsh_tree_traversal_depth(ptr noundef %56)
  %58 = icmp ult i64 %55, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %68

60:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 0, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = load i64, ptr %12, align 8, !tbaa !9
  %63 = call ptr @sqsh_tree_traversal_path_segment(ptr noundef %61, ptr noundef %13, i64 noundef %62)
  store ptr %63, ptr %14, align 8, !tbaa !5
  %64 = load ptr, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %65

65:                                               ; preds = %60
  %66 = load i64, ptr %12, align 8, !tbaa !9
  %67 = add i64 %66, 1
  store i64 %67, ptr %12, align 8, !tbaa !9
  br label %54, !llvm.loop !16

68:                                               ; preds = %59
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = call i32 @read_file(ptr noundef %69)
  %71 = icmp slt i32 %70, 0
  br i1 %71, label %72, label %73

72:                                               ; preds = %68
  br label %74

73:                                               ; preds = %68
  br label %50, !llvm.loop !18

74:                                               ; preds = %72, %50
  br label %75

75:                                               ; preds = %74, %48, %42, %31
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = call i32 @sqsh_tree_traversal_free(ptr noundef %76)
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = call i32 @sqsh_close(ptr noundef %78)
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = call i32 @sqsh_archive_close(ptr noundef %80)
  %82 = load i32, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret i32 0
}

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

declare ptr @sqsh_archive_open(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare ptr @sqsh_archive_superblock(ptr noundef) #2

declare i64 @sqsh_superblock_inode_root_ref(ptr noundef) #2

declare ptr @sqsh_open_by_ref(ptr noundef, i64 noundef, ptr noundef) #2

declare ptr @sqsh_tree_traversal_new(ptr noundef, ptr noundef) #2

declare zeroext i1 @sqsh_tree_traversal_next(ptr noundef, ptr noundef) #2

declare i64 @sqsh_tree_traversal_depth(ptr noundef) #2

declare ptr @sqsh_tree_traversal_path_segment(ptr noundef, ptr noundef, i64 noundef) #2

; 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
declare hidden i32 @read_file(ptr noundef) #0

declare i32 @sqsh_tree_traversal_free(ptr noundef) #2

declare i32 @sqsh_close(ptr noundef) #2

declare i32 @sqsh_archive_close(ptr noundef) #2

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"SqshConfig", !10, i64 0, !10, i64 8, !6, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !10, i64 40, !12, i64 48, !12, i64 52, !7, i64 56}
!15 = !{!14, !6, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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.SqshConfig = type { i64, i64, ptr, i32, i32, i32, i64, i32, i32, [128 x i8] }

@sqsh_mapper_impl_static = external local_unnamed_addr constant ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @LLVMFuzzerTestOneInput(ptr noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = alloca %struct.SqshConfig, align 8
  %5 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(184) %4, i8 0, i64 184, i1 false)
  %6 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %1, ptr %6, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %4, i64 16
  %8 = load ptr, ptr @sqsh_mapper_impl_static, align 8, !tbaa !13
  store ptr %8, ptr %7, align 8, !tbaa !14
  %9 = call ptr @sqsh_archive_open(ptr noundef %0, ptr noundef nonnull %4, ptr noundef nonnull %3) #4
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 0
  br i1 %11, label %.loopexit, label %12

12:                                               ; preds = %2
  %13 = call ptr @sqsh_archive_superblock(ptr noundef %9) #4
  %14 = call i64 @sqsh_superblock_inode_root_ref(ptr noundef %13) #4
  %15 = call ptr @sqsh_open_by_ref(ptr noundef %9, i64 noundef %14, ptr noundef nonnull %3) #4
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 0
  br i1 %17, label %.loopexit, label %18

18:                                               ; preds = %12
  %19 = call ptr @sqsh_tree_traversal_new(ptr noundef %15, ptr noundef nonnull %3) #4
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %.loopexit, label %.preheader19

.preheader19:                                     ; preds = %18, %._crit_edge
  %22 = call zeroext i1 @sqsh_tree_traversal_next(ptr noundef %19, ptr noundef nonnull %3) #4
  br i1 %22, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %.preheader19
  %23 = call i64 @sqsh_tree_traversal_depth(ptr noundef %19) #4
  %.not = icmp eq i64 %23, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %24 = call i32 @read_file(ptr noundef %19)
  %25 = icmp slt i32 %24, 0
  br i1 %25, label %.loopexit, label %.preheader19, !llvm.loop !15

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.020 = phi i64 [ %27, %.lr.ph ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store i64 0, ptr %5, align 8, !tbaa !17
  %26 = call ptr @sqsh_tree_traversal_path_segment(ptr noundef %19, ptr noundef nonnull %5, i64 noundef %.020) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  %27 = add nuw i64 %.020, 1
  %28 = call i64 @sqsh_tree_traversal_depth(ptr noundef %19) #4
  %29 = icmp ult i64 %27, %28
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !18

.loopexit:                                        ; preds = %.preheader19, %._crit_edge, %18, %12, %2
  %.018 = phi ptr [ null, %2 ], [ null, %12 ], [ %19, %18 ], [ %19, %._crit_edge ], [ %19, %.preheader19 ]
  %.017 = phi ptr [ null, %2 ], [ %15, %12 ], [ %15, %18 ], [ %15, %._crit_edge ], [ %15, %.preheader19 ]
  %30 = call i32 @sqsh_tree_traversal_free(ptr noundef %.018) #4
  %31 = call i32 @sqsh_close(ptr noundef %.017) #4
  %32 = call i32 @sqsh_archive_close(ptr noundef %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  ret i32 0
}

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

declare ptr @sqsh_archive_open(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare ptr @sqsh_archive_superblock(ptr noundef) local_unnamed_addr #2

declare i64 @sqsh_superblock_inode_root_ref(ptr noundef) local_unnamed_addr #2

declare ptr @sqsh_open_by_ref(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

declare ptr @sqsh_tree_traversal_new(ptr noundef, ptr noundef) local_unnamed_addr #2

declare zeroext i1 @sqsh_tree_traversal_next(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i64 @sqsh_tree_traversal_depth(ptr noundef) local_unnamed_addr #2

declare ptr @sqsh_tree_traversal_path_segment(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; 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
declare hidden i32 @read_file(ptr noundef) local_unnamed_addr #0

declare i32 @sqsh_tree_traversal_free(ptr noundef) local_unnamed_addr #2

declare i32 @sqsh_close(ptr noundef) local_unnamed_addr #2

declare i32 @sqsh_archive_close(ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"SqshConfig", !11, i64 0, !11, i64 8, !12, i64 16, !6, i64 24, !6, i64 28, !6, i64 32, !11, i64 40, !6, i64 48, !6, i64 52, !7, i64 56}
!11 = !{!"long", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !12, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!11, !11, i64 0}
!18 = distinct !{!18, !16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass