; LLVM IR from nickmqb/muon :: bootstrap/mu.ll_TypeChecker (promoteUnaryOperatorIntvalArgument__)

; 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.tag_____Tag__ = type { ptr, ptr }
%struct.tag_____Namespace__ = type { %struct.string__, ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32 }
%struct.string__ = type { ptr, i32 }
%struct.tag_____CommonTags__ = type { %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, %struct.tag_____Tag__, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

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

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

15:                                               ; preds = %3
  %16 = getelementptr inbounds %struct.tag_____Tag__, ptr %5, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.tag_____Namespace__, ptr %17, i32 0, i32 13
  %19 = load i32, ptr %18, align 8, !tbaa !15
  %20 = icmp slt i32 %19, 4
  br i1 %20, label %21, label %24

21:                                               ; preds = %15
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.tag_____CommonTags__, ptr %22, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %23, i64 16, i1 false), !tbaa.struct !16
  br label %36

24:                                               ; preds = %15
  br label %35

25:                                               ; preds = %3
  %26 = getelementptr inbounds %struct.tag_____Tag__, ptr %5, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.tag_____Namespace__, ptr %27, i32 0, i32 13
  %29 = load i32, ptr %28, align 8, !tbaa !15
  %30 = icmp slt i32 %29, 4
  br i1 %30, label %31, label %34

31:                                               ; preds = %25
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.tag_____CommonTags__, ptr %32, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %33, i64 16, i1 false), !tbaa.struct !16
  br label %36

34:                                               ; preds = %25
  br label %35

35:                                               ; preds = %34, %24
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %5, i64 16, i1 false), !tbaa.struct !16
  br label %36

36:                                               ; preds = %35, %31, %21
  %37 = load { ptr, ptr }, ptr %4, align 8
  ret { ptr, ptr } %37
}

attributes #0 = { nocallback nofree 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" }

!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, !6, i64 0}
!10 = !{!"tag_____Tag__", !6, i64 0, !6, i64 8}
!11 = !{!12, !14, i64 28}
!12 = !{!"tag_____Namespace__", !13, i64 0, !6, i64 16, !14, i64 24, !14, i64 28, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !14, i64 104}
!13 = !{!"", !6, i64 0, !14, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !14, i64 104}
!16 = !{i64 0, i64 8, !5, i64 8, i64 8, !5}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local { ptr, ptr } @TypeChecker__promoteUnaryOperatorIntvalArgument__(ptr nocapture noundef readonly %0, ptr %1, ptr %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %1, i64 104
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp slt i32 %5, 4
  br i1 %6, label %.sink.split, label %11

.sink.split:                                      ; preds = %3
  %7 = getelementptr inbounds i8, ptr %1, i64 28
  %8 = load i32, ptr %7, align 4, !tbaa !12
  %9 = and i32 %8, 2
  %.not = icmp eq i32 %9, 0
  %.10 = select i1 %.not, i64 88, i64 104
  %. = select i1 %.not, i64 80, i64 96
  %10 = getelementptr inbounds i8, ptr %0, i64 %.
  %.sroa.04.0.copyload5 = load ptr, ptr %10, align 8, !tbaa !13
  %.sroa.4.0..sroa_idx6 = getelementptr inbounds i8, ptr %0, i64 %.10
  %.sroa.4.0.copyload7 = load ptr, ptr %.sroa.4.0..sroa_idx6, align 8, !tbaa !13
  br label %11

11:                                               ; preds = %3, %.sink.split
  %.sroa.04.0 = phi ptr [ %.sroa.04.0.copyload5, %.sink.split ], [ %1, %3 ]
  %.sroa.4.0 = phi ptr [ %.sroa.4.0.copyload7, %.sink.split ], [ %2, %3 ]
  %.fca.0.insert = insertvalue { ptr, ptr } poison, ptr %.sroa.04.0, 0
  %.fca.1.insert = insertvalue { ptr, ptr } %.fca.0.insert, ptr %.sroa.4.0, 1
  ret { ptr, ptr } %.fca.1.insert
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !11, i64 104}
!6 = !{!"tag_____Namespace__", !7, i64 0, !8, i64 16, !11, i64 24, !11, i64 28, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !8, i64 64, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !11, i64 104}
!7 = !{!"", !8, i64 0, !11, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!6, !11, i64 28}
!13 = !{!8, !8, i64 0}


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