; LLVM IR from jermp/2i_bench :: external/CRoaring/tests/vendor/cmocka/cmocka.ll (mock)

; 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.ListNode = type { ptr, i32, ptr, ptr }
%struct.SourceLocation = type { ptr, i32 }
%struct.SymbolValue = type { %struct.SourceLocation, i64 }

@global_function_result_map_head = external hidden global %struct.ListNode, align 8
@global_last_mock_value_location = external hidden global %struct.SourceLocation, align 8
@.str.1 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [62 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @cm_print_error(ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
declare hidden void @exit_test(i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i64 @_mock(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %13 = call i32 @get_symbol_value(ptr noundef @global_function_result_map_head, ptr noundef %5, i64 noundef 1, ptr noundef %8)
  store i32 %13, ptr %9, align 4, !tbaa !9
  %14 = load i32, ptr %9, align 4, !tbaa !9
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %29

16:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %17, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %18 = load ptr, ptr %10, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.SymbolValue, ptr %18, i32 0, i32 1
  %20 = load i64, ptr %19, align 8, !tbaa !11
  store i64 %20, ptr %11, align 8, !tbaa !15
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.SymbolValue, ptr %21, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @global_last_mock_value_location, ptr align 8 %22, i64 16, i1 false), !tbaa.struct !16
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 1
  br i1 %24, label %25, label %27

25:                                               ; preds = %16
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %26) #4
  br label %27

27:                                               ; preds = %25, %16
  %28 = load i64, ptr %11, align 8, !tbaa !15
  store i64 %28, ptr %4, align 8
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %41

29:                                               ; preds = %3
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  call void (ptr, ...) @cm_print_error(ptr noundef @.str.1, ptr noundef %30, i32 noundef %31, ptr noundef %32)
  %33 = call i32 @source_location_is_set(ptr noundef @global_last_mock_value_location)
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %38

35:                                               ; preds = %29
  %36 = load ptr, ptr @global_last_mock_value_location, align 8, !tbaa !17
  %37 = load i32, ptr getelementptr inbounds (%struct.SourceLocation, ptr @global_last_mock_value_location, i32 0, i32 1), align 8, !tbaa !18
  call void (ptr, ...) @cm_print_error(ptr noundef @.str.2, ptr noundef %36, i32 noundef %37)
  br label %39

38:                                               ; preds = %29
  call void (ptr, ...) @cm_print_error(ptr noundef @.str.3)
  br label %39

39:                                               ; preds = %38, %35
  call void @exit_test(i32 noundef 1)
  br label %40

40:                                               ; preds = %39
  store i64 0, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %41

41:                                               ; preds = %40, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %42 = load i64, ptr %4, align 8
  ret i64 %42
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @get_symbol_value(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #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) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; 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 @source_location_is_set(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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !14, i64 16}
!12 = !{!"SymbolValue", !13, i64 0, !14, i64 16}
!13 = !{!"SourceLocation", !6, i64 0, !10, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = !{!14, !14, i64 0}
!16 = !{i64 0, i64 8, !5, i64 8, i64 4, !9}
!17 = !{!13, !6, i64 0}
!18 = !{!13, !10, i64 8}


; 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.ListNode = type { ptr, i32, ptr, ptr }
%struct.SourceLocation = type { ptr, i32 }

@global_function_result_map_head = external hidden global %struct.ListNode, align 8
@global_last_mock_value_location = external hidden global %struct.SourceLocation, align 8
@.str.1 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [62 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @cm_print_error(ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @exit_test(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i64 @_mock(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %6 = call i32 @get_symbol_value(ptr noundef nonnull @global_function_result_map_head, ptr noundef nonnull %4, i64 noundef 1, ptr noundef nonnull %5)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %13, label %7

7:                                                ; preds = %3
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  %10 = load i64, ptr %9, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) @global_last_mock_value_location, ptr noundef nonnull align 8 dereferenceable(16) %8, i64 16, i1 false), !tbaa.struct !14
  %11 = icmp eq i32 %6, 1
  br i1 %11, label %12, label %21

12:                                               ; preds = %7
  call void @free(ptr noundef nonnull %8) #4
  br label %21

13:                                               ; preds = %3
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  call void (ptr, ...) @cm_print_error(ptr noundef nonnull @.str.1, ptr noundef %1, i32 noundef %2, ptr noundef %14)
  %15 = call i32 @source_location_is_set(ptr noundef nonnull @global_last_mock_value_location)
  %.not9 = icmp eq i32 %15, 0
  br i1 %.not9, label %19, label %16

16:                                               ; preds = %13
  %17 = load ptr, ptr @global_last_mock_value_location, align 8, !tbaa !16
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @global_last_mock_value_location, i64 8), align 8, !tbaa !17
  call void (ptr, ...) @cm_print_error(ptr noundef nonnull @.str.2, ptr noundef %17, i32 noundef %18)
  br label %20

19:                                               ; preds = %13
  call void (ptr, ...) @cm_print_error(ptr noundef nonnull @.str.3)
  br label %20

20:                                               ; preds = %19, %16
  call void @exit_test(i32 noundef 1)
  br label %21

21:                                               ; preds = %7, %12, %20
  %.0 = phi i64 [ 0, %20 ], [ %10, %12 ], [ %10, %7 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret i64 %.0
}

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

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

; 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) #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

; 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 @source_location_is_set(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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #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, !13, i64 16}
!10 = !{!"SymbolValue", !11, i64 0, !13, i64 16}
!11 = !{!"SourceLocation", !6, i64 0, !12, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{i64 0, i64 8, !5, i64 8, i64 4, !15}
!15 = !{!12, !12, i64 0}
!16 = !{!11, !6, i64 0}
!17 = !{!11, !12, i64 8}


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