; LLVM IR from LeoVen/C-Macro-Collections :: tests (types)

; 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.sortedlist1 = type { ptr, i64, i64, i8, i32, ptr, ptr }
%struct.sortedlist1_fval = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.struct_s = type { i32, i32, ptr, ptr, [10 x double] }

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @sl1_sort(ptr noundef) #1

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

15:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %52

16:                                               ; preds = %2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  call void @sl1_sort(ptr noundef %17)
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  call void @sl1_sort(ptr noundef %18)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store i64 0, ptr %6, align 8, !tbaa !14
  br label %19

19:                                               ; preds = %46, %16
  %20 = load i64, ptr %6, align 8, !tbaa !14
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.sortedlist1, ptr %21, i32 0, i32 2
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = icmp ult i64 %20, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %19
  store i32 2, ptr %7, align 4
  br label %49

26:                                               ; preds = %19
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.sortedlist1, ptr %27, i32 0, i32 5
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = getelementptr inbounds %struct.sortedlist1_fval, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.sortedlist1, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !18
  %35 = load i64, ptr %6, align 8, !tbaa !14
  %36 = getelementptr inbounds %struct.struct_s, ptr %34, i64 %35
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.sortedlist1, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !18
  %40 = load i64, ptr %6, align 8, !tbaa !14
  %41 = getelementptr inbounds %struct.struct_s, ptr %39, i64 %40
  %42 = call i32 %31(ptr noundef byval(%struct.struct_s) align 8 %36, ptr noundef byval(%struct.struct_s) align 8 %41)
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %45

44:                                               ; preds = %26
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %49

45:                                               ; preds = %26
  br label %46

46:                                               ; preds = %45
  %47 = load i64, ptr %6, align 8, !tbaa !14
  %48 = add i64 %47, 1
  store i64 %48, ptr %6, align 8, !tbaa !14
  br label %19, !llvm.loop !19

49:                                               ; preds = %44, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %50 = load i32, ptr %7, align 4
  switch i32 %50, label %54 [
    i32 2, label %51
    i32 1, label %52
  ]

51:                                               ; preds = %49
  store i1 true, ptr %3, align 1
  br label %52

52:                                               ; preds = %51, %49, %15
  %53 = load i1, ptr %3, align 1
  ret i1 %53

54:                                               ; preds = %49
  unreachable
}

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


; 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.struct_s = type { i32, i32, ptr, ptr, [10 x double] }

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

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @sl1_equals(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i64 %4, %6
  br i1 %.not, label %7, label %.loopexit

7:                                                ; preds = %2
  tail call void @sl1_sort(ptr noundef nonnull %0)
  tail call void @sl1_sort(ptr noundef nonnull %1)
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load i64, ptr %3, align 8, !tbaa !5
  %10 = icmp eq i64 %9, 0
  br i1 %10, label %.loopexit, label %.lr.ph

11:                                               ; preds = %.lr.ph
  %12 = add nuw i64 %.01316, 1
  %13 = load i64, ptr %3, align 8, !tbaa !5
  %.not19 = icmp ult i64 %12, %13
  br i1 %.not19, label %.lr.ph, label %.loopexit, !llvm.loop !13

.lr.ph:                                           ; preds = %7, %11
  %.01316 = phi i64 [ %12, %11 ], [ 0, %7 ]
  %14 = load ptr, ptr %8, align 8, !tbaa !15
  %15 = load ptr, ptr %14, align 8, !tbaa !16
  %16 = load ptr, ptr %0, align 8, !tbaa !18
  %17 = getelementptr inbounds %struct.struct_s, ptr %16, i64 %.01316
  %18 = load ptr, ptr %1, align 8, !tbaa !18
  %19 = getelementptr inbounds %struct.struct_s, ptr %18, i64 %.01316
  %20 = tail call i32 %15(ptr noundef byval(%struct.struct_s) align 8 %17, ptr noundef byval(%struct.struct_s) align 8 %19) #1
  %.not15 = icmp eq i32 %20, 0
  br i1 %.not15, label %11, label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %11, %7, %2
  %.1 = phi i1 [ false, %2 ], [ true, %7 ], [ %.not15, %11 ], [ %.not15, %.lr.ph ]
  ret i1 %.1
}

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 = { 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, !10, i64 16}
!6 = !{!"sortedlist1", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !12, i64 28, !7, i64 32, !7, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!6, !7, i64 32}
!16 = !{!17, !7, i64 0}
!17 = !{!"sortedlist1_fval", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!18 = !{!6, !7, i64 0}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass