; LLVM IR from alexzheng42/sDMD :: src (ToolFunctions)

; 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.ConstraintStr = type { i32, double, ptr, double, ptr }

@potentialPairCollision = external global [33 x [33 x %struct.ConstraintStr]], align 16

; 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 i32 @AtomTypeChange(i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @RightPair(i32 noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr @potentialPairCollision, i64 0, i64 %10
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [33 x %struct.ConstraintStr], ptr %11, i64 0, i64 %13
  %15 = getelementptr inbounds %struct.ConstraintStr, ptr %14, i32 0, i32 1
  %16 = load double, ptr %15, align 8, !tbaa !9
  %17 = fcmp ogt double %16, 0.000000e+00
  br i1 %17, label %18, label %25

18:                                               ; preds = %3
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr @potentialPairCollision, i64 0, i64 %20
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [33 x %struct.ConstraintStr], ptr %21, i64 0, i64 %23
  store ptr %24, ptr %4, align 8
  br label %56

25:                                               ; preds = %3
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  store ptr null, ptr %4, align 8
  br label %56

29:                                               ; preds = %25
  br label %30

30:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store ptr null, ptr %8, align 8, !tbaa !13
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = call i32 @AtomTypeChange(i32 noundef %31, i32 noundef 0)
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = call ptr @RightPair(i32 noundef %32, i32 noundef %33, i32 noundef 1)
  store ptr %34, ptr %8, align 8, !tbaa !13
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  br label %54

37:                                               ; preds = %30
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = call i32 @AtomTypeChange(i32 noundef %39, i32 noundef 0)
  %41 = call ptr @RightPair(i32 noundef %38, i32 noundef %40, i32 noundef 1)
  store ptr %41, ptr %8, align 8, !tbaa !13
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %44

43:                                               ; preds = %37
  br label %53

44:                                               ; preds = %37
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = call i32 @AtomTypeChange(i32 noundef %45, i32 noundef 0)
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = call i32 @AtomTypeChange(i32 noundef %47, i32 noundef 0)
  %49 = call ptr @RightPair(i32 noundef %46, i32 noundef %48, i32 noundef 1)
  store ptr %49, ptr %8, align 8, !tbaa !13
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %52

51:                                               ; preds = %44
  br label %52

52:                                               ; preds = %51, %44
  br label %53

53:                                               ; preds = %52, %43
  br label %54

54:                                               ; preds = %53, %36
  %55 = load ptr, ptr %8, align 8, !tbaa !13
  store ptr %55, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %56

56:                                               ; preds = %54, %28, %18
  %57 = load ptr, ptr %4, align 8
  ret ptr %57
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"ConstraintStr", !6, i64 0, !11, i64 8, !12, i64 16, !11, i64 24, !12, i64 32}
!11 = !{!"double", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!12, !12, 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"

%struct.ConstraintStr = type { i32, double, ptr, double, ptr }

@potentialPairCollision = external global [33 x [33 x %struct.ConstraintStr]], align 16

; Function Attrs: nounwind uwtable
declare dso_local i32 @AtomTypeChange(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @RightPair(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = sext i32 %0 to i64
  %5 = sext i32 %1 to i64
  %6 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr @potentialPairCollision, i64 0, i64 %4, i64 %5
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = fcmp ogt double %8, 0.000000e+00
  br i1 %9, label %RightPair.exit, label %10

10:                                               ; preds = %3
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %11, label %RightPair.exit

11:                                               ; preds = %10
  %12 = tail call i32 @AtomTypeChange(i32 noundef %0, i32 noundef 0)
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr @potentialPairCollision, i64 0, i64 %13, i64 %5
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fcmp ogt double %16, 0.000000e+00
  br i1 %17, label %RightPair.exit, label %18

18:                                               ; preds = %11
  %19 = tail call i32 @AtomTypeChange(i32 noundef %1, i32 noundef 0)
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr @potentialPairCollision, i64 0, i64 %4, i64 %20
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = fcmp ogt double %23, 0.000000e+00
  br i1 %24, label %RightPair.exit, label %25

25:                                               ; preds = %18
  %26 = tail call i32 @AtomTypeChange(i32 noundef %0, i32 noundef 0)
  %27 = tail call i32 @AtomTypeChange(i32 noundef %1, i32 noundef 0)
  %28 = sext i32 %26 to i64
  %29 = sext i32 %27 to i64
  %30 = getelementptr inbounds [33 x [33 x %struct.ConstraintStr]], ptr @potentialPairCollision, i64 0, i64 %28, i64 %29
  %31 = getelementptr inbounds i8, ptr %30, i64 8
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = fcmp ogt double %32, 0.000000e+00
  br i1 %33, label %RightPair.exit, label %34

34:                                               ; preds = %25
  br label %RightPair.exit

RightPair.exit:                                   ; preds = %34, %25, %18, %11, %10, %3
  %.012 = phi ptr [ %6, %3 ], [ null, %10 ], [ %14, %11 ], [ %21, %18 ], [ %30, %25 ], [ null, %34 ]
  ret ptr %.012
}

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" }

!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 8}
!6 = !{!"ConstraintStr", !7, i64 0, !10, i64 8, !11, i64 16, !10, i64 24, !11, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InlinerPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass