; LLVM IR from ryanlayer/giggle :: test/unit (test_lists)

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

@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1

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

declare void @UnityAssertEqualNumber(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef) #1

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @test_ordered_set_add() #3 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  %4 = call ptr @ordered_set_init(i32 noundef 3, ptr noundef @str_uint_pair_sort_element_cmp, ptr noundef @str_uint_pair_search_element_cmp, ptr noundef @str_uint_pair_search_key_cmp)
  store ptr %4, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %5 = call noalias ptr @malloc(i64 noundef 16) #6
  store ptr %5, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.ordered_set, ptr %6, i32 0, i32 1
  %8 = load i32, ptr %7, align 8, !tbaa !9
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.str_uint_pair, ptr %9, i32 0, i32 1
  store i32 %8, ptr %10, align 8, !tbaa !12
  %11 = call noalias ptr @strdup(ptr noundef @.str.4) #5
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.str_uint_pair, ptr %12, i32 0, i32 0
  store ptr %11, ptr %13, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = call ptr @ordered_set_add(ptr noundef %14, ptr noundef %15)
  store ptr %16, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.str_uint_pair, ptr %17, i32 0, i32 1
  %19 = load i32, ptr %18, align 8, !tbaa !12
  %20 = zext i32 %19 to i64
  call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %20, ptr noundef null, i64 noundef 205, i32 noundef 148)
  %21 = call noalias ptr @malloc(i64 noundef 16) #6
  store ptr %21, ptr %2, align 8, !tbaa !5
  %22 = load ptr, ptr %1, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ordered_set, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.str_uint_pair, ptr %25, i32 0, i32 1
  store i32 %24, ptr %26, align 8, !tbaa !12
  %27 = call noalias ptr @strdup(ptr noundef @.str.5) #5
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.str_uint_pair, ptr %28, i32 0, i32 0
  store ptr %27, ptr %29, align 8, !tbaa !14
  %30 = load ptr, ptr %1, align 8, !tbaa !5
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = call ptr @ordered_set_add(ptr noundef %30, ptr noundef %31)
  store ptr %32, ptr %3, align 8, !tbaa !5
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.str_uint_pair, ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 8, !tbaa !12
  %36 = zext i32 %35 to i64
  call void @UnityAssertEqualNumber(i64 noundef 1, i64 noundef %36, ptr noundef null, i64 noundef 213, i32 noundef 148)
  %37 = call noalias ptr @malloc(i64 noundef 16) #6
  store ptr %37, ptr %2, align 8, !tbaa !5
  %38 = load ptr, ptr %1, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ordered_set, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 8, !tbaa !9
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.str_uint_pair, ptr %41, i32 0, i32 1
  store i32 %40, ptr %42, align 8, !tbaa !12
  %43 = call noalias ptr @strdup(ptr noundef @.str.4) #5
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.str_uint_pair, ptr %44, i32 0, i32 0
  store ptr %43, ptr %45, align 8, !tbaa !14
  %46 = load ptr, ptr %1, align 8, !tbaa !5
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = call ptr @ordered_set_add(ptr noundef %46, ptr noundef %47)
  store ptr %48, ptr %3, align 8, !tbaa !5
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.str_uint_pair, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 8, !tbaa !12
  %52 = zext i32 %51 to i64
  call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %52, ptr noundef null, i64 noundef 220, i32 noundef 148)
  call void @str_uint_pair_free(ptr noundef %2)
  %53 = call noalias ptr @malloc(i64 noundef 16) #6
  store ptr %53, ptr %2, align 8, !tbaa !5
  %54 = load ptr, ptr %1, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ordered_set, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 8, !tbaa !9
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.str_uint_pair, ptr %57, i32 0, i32 1
  store i32 %56, ptr %58, align 8, !tbaa !12
  %59 = call noalias ptr @strdup(ptr noundef @.str.6) #5
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.str_uint_pair, ptr %60, i32 0, i32 0
  store ptr %59, ptr %61, align 8, !tbaa !14
  %62 = load ptr, ptr %1, align 8, !tbaa !5
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = call ptr @ordered_set_add(ptr noundef %62, ptr noundef %63)
  store ptr %64, ptr %3, align 8, !tbaa !5
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.str_uint_pair, ptr %65, i32 0, i32 1
  %67 = load i32, ptr %66, align 8, !tbaa !12
  %68 = zext i32 %67 to i64
  call void @UnityAssertEqualNumber(i64 noundef 2, i64 noundef %68, ptr noundef null, i64 noundef 228, i32 noundef 148)
  %69 = call noalias ptr @malloc(i64 noundef 16) #6
  store ptr %69, ptr %2, align 8, !tbaa !5
  %70 = load ptr, ptr %1, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.ordered_set, ptr %70, i32 0, i32 1
  %72 = load i32, ptr %71, align 8, !tbaa !9
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.str_uint_pair, ptr %73, i32 0, i32 1
  store i32 %72, ptr %74, align 8, !tbaa !12
  %75 = call noalias ptr @strdup(ptr noundef @.str.7) #5
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.str_uint_pair, ptr %76, i32 0, i32 0
  store ptr %75, ptr %77, align 8, !tbaa !14
  %78 = load ptr, ptr %1, align 8, !tbaa !5
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = call ptr @ordered_set_add(ptr noundef %78, ptr noundef %79)
  store ptr %80, ptr %3, align 8, !tbaa !5
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.str_uint_pair, ptr %81, i32 0, i32 1
  %83 = load i32, ptr %82, align 8, !tbaa !12
  %84 = zext i32 %83 to i64
  call void @UnityAssertEqualNumber(i64 noundef 3, i64 noundef %84, ptr noundef null, i64 noundef 235, i32 noundef 148)
  call void @ordered_set_destroy(ptr noundef %1, ptr noundef @str_uint_pair_free)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  ret void
}

declare ptr @ordered_set_init(i32 noundef, ptr noundef, ptr noundef, ptr noundef) #1

declare i32 @str_uint_pair_sort_element_cmp(ptr noundef, ptr noundef) #1

declare i32 @str_uint_pair_search_element_cmp(ptr noundef, ptr noundef) #1

declare i32 @str_uint_pair_search_key_cmp(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #4

declare ptr @ordered_set_add(ptr noundef, ptr noundef) #1

declare void @str_uint_pair_free(ptr noundef) #1

declare void @ordered_set_destroy(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 allocsize(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 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 "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 }
attributes #6 = { nounwind allocsize(0) }

!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, !11, i64 8}
!10 = !{!"ordered_set", !6, i64 0, !11, i64 8, !11, i64 12, !6, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 8}
!13 = !{!"str_uint_pair", !6, i64 0, !11, i64 8}
!14 = !{!13, !6, 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"

@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1

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

declare void @UnityAssertEqualNumber(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_ordered_set_add() local_unnamed_addr #3 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %3 = tail call ptr @ordered_set_init(i32 noundef 3, ptr noundef nonnull @str_uint_pair_sort_element_cmp, ptr noundef nonnull @str_uint_pair_search_element_cmp, ptr noundef nonnull @str_uint_pair_search_key_cmp) #5
  store ptr %3, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %4 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #6
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %6, ptr %7, align 8, !tbaa !12
  %8 = tail call noalias ptr @strdup(ptr noundef nonnull @.str.4) #5
  store ptr %8, ptr %4, align 8, !tbaa !14
  %9 = tail call ptr @ordered_set_add(ptr noundef %3, ptr noundef nonnull %4) #5
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !12
  %12 = zext i32 %11 to i64
  tail call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %12, ptr noundef null, i64 noundef 205, i32 noundef 148) #5
  %13 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #6
  %14 = load i32, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %13, i64 8
  store i32 %14, ptr %15, align 8, !tbaa !12
  %16 = tail call noalias ptr @strdup(ptr noundef nonnull @.str.5) #5
  store ptr %16, ptr %13, align 8, !tbaa !14
  %17 = tail call ptr @ordered_set_add(ptr noundef %3, ptr noundef nonnull %13) #5
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = load i32, ptr %18, align 8, !tbaa !12
  %20 = zext i32 %19 to i64
  tail call void @UnityAssertEqualNumber(i64 noundef 1, i64 noundef %20, ptr noundef null, i64 noundef 213, i32 noundef 148) #5
  %21 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #6
  store ptr %21, ptr %2, align 8, !tbaa !5
  %22 = load i32, ptr %5, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %21, i64 8
  store i32 %22, ptr %23, align 8, !tbaa !12
  %24 = tail call noalias ptr @strdup(ptr noundef nonnull @.str.4) #5
  store ptr %24, ptr %21, align 8, !tbaa !14
  %25 = tail call ptr @ordered_set_add(ptr noundef %3, ptr noundef nonnull %21) #5
  %26 = getelementptr inbounds i8, ptr %25, i64 8
  %27 = load i32, ptr %26, align 8, !tbaa !12
  %28 = zext i32 %27 to i64
  tail call void @UnityAssertEqualNumber(i64 noundef 0, i64 noundef %28, ptr noundef null, i64 noundef 220, i32 noundef 148) #5
  call void @str_uint_pair_free(ptr noundef nonnull %2) #5
  %29 = call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #6
  store ptr %29, ptr %2, align 8, !tbaa !5
  %30 = load i32, ptr %5, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %29, i64 8
  store i32 %30, ptr %31, align 8, !tbaa !12
  %32 = call noalias ptr @strdup(ptr noundef nonnull @.str.6) #5
  store ptr %32, ptr %29, align 8, !tbaa !14
  %33 = call ptr @ordered_set_add(ptr noundef %3, ptr noundef nonnull %29) #5
  %34 = getelementptr inbounds i8, ptr %33, i64 8
  %35 = load i32, ptr %34, align 8, !tbaa !12
  %36 = zext i32 %35 to i64
  call void @UnityAssertEqualNumber(i64 noundef 2, i64 noundef %36, ptr noundef null, i64 noundef 228, i32 noundef 148) #5
  %37 = call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #6
  store ptr %37, ptr %2, align 8, !tbaa !5
  %38 = load i32, ptr %5, align 8, !tbaa !9
  %39 = getelementptr inbounds i8, ptr %37, i64 8
  store i32 %38, ptr %39, align 8, !tbaa !12
  %40 = call noalias ptr @strdup(ptr noundef nonnull @.str.7) #5
  store ptr %40, ptr %37, align 8, !tbaa !14
  %41 = call ptr @ordered_set_add(ptr noundef %3, ptr noundef nonnull %37) #5
  %42 = getelementptr inbounds i8, ptr %41, i64 8
  %43 = load i32, ptr %42, align 8, !tbaa !12
  %44 = zext i32 %43 to i64
  call void @UnityAssertEqualNumber(i64 noundef 3, i64 noundef %44, ptr noundef null, i64 noundef 235, i32 noundef 148) #5
  call void @ordered_set_destroy(ptr noundef nonnull %1, ptr noundef nonnull @str_uint_pair_free) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  ret void
}

declare ptr @ordered_set_init(i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @str_uint_pair_sort_element_cmp(ptr noundef, ptr noundef) #1

declare i32 @str_uint_pair_search_element_cmp(ptr noundef, ptr noundef) #1

declare i32 @str_uint_pair_search_key_cmp(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #4

declare ptr @ordered_set_add(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @str_uint_pair_free(ptr noundef) #1

declare void @ordered_set_destroy(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) 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 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 = { mustprogress nofree nounwind willreturn 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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, !11, i64 8}
!10 = !{!"ordered_set", !6, i64 0, !11, i64 8, !11, i64 12, !6, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 8}
!13 = !{!"str_uint_pair", !6, i64 0, !11, i64 8}
!14 = !{!13, !6, i64 0}


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