; LLVM IR from vmware-archive/vmmfuzzer :: src/lib (iofuzzer)

; 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.iofuzzer = type { %union.pthread_mutex_t, i64, ptr, ptr, [8 x i8], ptr, ptr, ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

; Function Attrs: nounwind uwtable
declare dso_local ptr @iofuzzer_free(ptr 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: nounwind willreturn memory(none)
declare ptr @__errno_location() #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
define dso_local ptr @iofuzzer_new() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %5 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 96) #7
  store ptr %5, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %0
  store ptr null, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %81

9:                                                ; preds = %0
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.iofuzzer, ptr %10, i32 0, i32 0
  %12 = call i32 @pthread_mutex_init(ptr noundef %11, ptr noundef null) #6
  %13 = call ptr @__errno_location() #8
  store i32 %12, ptr %13, align 4, !tbaa !9
  %14 = call ptr @__errno_location() #8
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %9
  br label %78

18:                                               ; preds = %9
  %19 = call ptr @random_new()
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.iofuzzer, ptr %20, i32 0, i32 3
  store ptr %19, ptr %21, align 8, !tbaa !11
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.iofuzzer, ptr %22, i32 0, i32 3
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %18
  br label %78

27:                                               ; preds = %18
  %28 = call noalias ptr @calloc(i64 noundef 256, i64 noundef 1) #7
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.iofuzzer, ptr %29, i32 0, i32 5
  store ptr %28, ptr %30, align 8, !tbaa !14
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.iofuzzer, ptr %31, i32 0, i32 5
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %36

35:                                               ; preds = %27
  br label %78

36:                                               ; preds = %27
  %37 = call noalias ptr @calloc(i64 noundef 256, i64 noundef 1) #7
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.iofuzzer, ptr %38, i32 0, i32 6
  store ptr %37, ptr %39, align 8, !tbaa !15
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.iofuzzer, ptr %40, i32 0, i32 6
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = icmp eq ptr %42, null
  br i1 %43, label %44, label %45

44:                                               ; preds = %36
  br label %78

45:                                               ; preds = %36
  %46 = call ptr @array_new_with_length(i64 noundef 8, i64 noundef 7)
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.iofuzzer, ptr %47, i32 0, i32 7
  store ptr %46, ptr %48, align 8, !tbaa !16
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.iofuzzer, ptr %49, i32 0, i32 7
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  %52 = icmp eq ptr %51, null
  br i1 %52, label %53, label %54

53:                                               ; preds = %45
  br label %78

54:                                               ; preds = %45
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.iofuzzer, ptr %55, i32 0, i32 7
  %57 = load ptr, ptr %56, align 8, !tbaa !16
  %58 = getelementptr inbounds ptr, ptr %57, i64 0
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = getelementptr inbounds i64, ptr %59, i64 0
  store ptr %60, ptr %3, align 8, !tbaa !5
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.iofuzzer, ptr %61, i32 0, i32 5
  %63 = load ptr, ptr %62, align 8, !tbaa !14
  %64 = ptrtoint ptr %63 to i64
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds i64, ptr %65, i64 5
  store i64 %64, ptr %66, align 8, !tbaa !17
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.iofuzzer, ptr %67, i32 0, i32 6
  %69 = load ptr, ptr %68, align 8, !tbaa !15
  %70 = ptrtoint ptr %69 to i64
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds i64, ptr %71, i64 6
  store i64 %70, ptr %72, align 8, !tbaa !17
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = call ptr @_iofuzzer_randomize(ptr noundef %73)
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = call ptr @iofuzzer_ref(ptr noundef %75)
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %77, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %81

78:                                               ; preds = %53, %44, %35, %26, %17
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = call ptr @iofuzzer_free(ptr noundef %79)
  store ptr null, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %81

81:                                               ; preds = %78, %54, %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  %82 = load ptr, ptr %1, align 8
  ret ptr %82
}

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

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

declare ptr @random_new() #5

declare ptr @array_new_with_length(i64 noundef, i64 noundef) #5

; Function Attrs: nounwind uwtable
declare hidden ptr @_iofuzzer_randomize(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @iofuzzer_ref(ptr noundef) #0

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 = { nounwind willreturn memory(none) "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,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 #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 = { "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { nounwind willreturn memory(none) }

!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, !6, i64 56}
!12 = !{!"iofuzzer", !7, i64 0, !13, i64 40, !6, i64 48, !6, i64 56, !7, i64 64, !6, i64 72, !6, i64 80, !6, i64 88}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !6, i64 72}
!15 = !{!12, !6, i64 80}
!16 = !{!12, !6, i64 88}
!17 = !{!13, !13, 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: nounwind uwtable
declare dso_local ptr @iofuzzer_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @iofuzzer_new() local_unnamed_addr #0 {
  %1 = tail call noalias dereferenceable_or_null(96) ptr @calloc(i64 noundef 1, i64 noundef 96) #5
  %2 = icmp eq ptr %1, null
  br i1 %2, label %31, label %3

3:                                                ; preds = %0
  %4 = tail call i32 @pthread_mutex_init(ptr noundef nonnull %1, ptr noundef null) #6
  %5 = tail call ptr @__errno_location() #7
  store i32 %4, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %6, label %29

6:                                                ; preds = %3
  %7 = tail call ptr @random_new() #6
  %8 = getelementptr inbounds i8, ptr %1, i64 56
  store ptr %7, ptr %8, align 8, !tbaa !9
  %9 = icmp eq ptr %7, null
  br i1 %9, label %29, label %10

10:                                               ; preds = %6
  %11 = tail call noalias dereferenceable_or_null(256) ptr @calloc(i64 noundef 256, i64 noundef 1) #5
  %12 = getelementptr inbounds i8, ptr %1, i64 72
  store ptr %11, ptr %12, align 8, !tbaa !13
  %13 = icmp eq ptr %11, null
  br i1 %13, label %29, label %14

14:                                               ; preds = %10
  %15 = tail call noalias dereferenceable_or_null(256) ptr @calloc(i64 noundef 256, i64 noundef 1) #5
  %16 = getelementptr inbounds i8, ptr %1, i64 80
  store ptr %15, ptr %16, align 8, !tbaa !14
  %17 = icmp eq ptr %15, null
  br i1 %17, label %29, label %18

18:                                               ; preds = %14
  %19 = tail call ptr @array_new_with_length(i64 noundef 8, i64 noundef 7) #6
  %20 = getelementptr inbounds i8, ptr %1, i64 88
  store ptr %19, ptr %20, align 8, !tbaa !15
  %21 = icmp eq ptr %19, null
  br i1 %21, label %29, label %22

22:                                               ; preds = %18
  %23 = load ptr, ptr %19, align 8, !tbaa !16
  %24 = getelementptr inbounds i8, ptr %23, i64 40
  %25 = load <2 x ptr>, ptr %12, align 8, !tbaa !16
  %26 = ptrtoint <2 x ptr> %25 to <2 x i64>
  store <2 x i64> %26, ptr %24, align 8, !tbaa !17
  %27 = tail call ptr @_iofuzzer_randomize(ptr noundef nonnull %1)
  %28 = tail call ptr @iofuzzer_ref(ptr noundef nonnull %1)
  br label %31

29:                                               ; preds = %18, %14, %10, %6, %3
  %30 = tail call ptr @iofuzzer_free(ptr noundef nonnull %1)
  br label %31

31:                                               ; preds = %0, %29, %22
  %.0 = phi ptr [ null, %29 ], [ %1, %22 ], [ null, %0 ]
  ret ptr %.0
}

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

; Function Attrs: nounwind
declare i32 @pthread_mutex_init(ptr noundef, ptr noundef) local_unnamed_addr #3

declare ptr @random_new() local_unnamed_addr #4

declare ptr @array_new_with_length(i64 noundef, i64 noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @iofuzzer_ref(ptr noundef) local_unnamed_addr #0

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 nofree nosync nounwind willreturn memory(none) "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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(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 #3 = { 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 #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 allocsize(0,1) }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

!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, !12, i64 56}
!10 = !{!"iofuzzer", !7, i64 0, !11, i64 40, !12, i64 48, !12, i64 56, !7, i64 64, !12, i64 72, !12, i64 80, !12, i64 88}
!11 = !{!"long", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!10, !12, i64 72}
!14 = !{!10, !12, i64 80}
!15 = !{!10, !12, i64 88}
!16 = !{!12, !12, i64 0}
!17 = !{!11, !11, i64 0}


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