; LLVM IR from nickmqb/muon :: bootstrap/mu.ll_CGenerator (genForeignArgImpl__)

; 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.Node__ = type { i32, ptr }
%struct.tag_____Tag__ = type { ptr, ptr }
%struct.tag_____Param__ = type { ptr, %struct.Node__, ptr, %struct.tag_____Tag__, i32, %struct.string__ }
%struct.string__ = type { ptr, i32 }
%struct.tag_____GenerateContext__ = type { ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, ptr, %struct.string__, i32, %struct.string__, i32, ptr, ptr, i8 }
%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 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: 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) #1

; Function Attrs: nounwind uwtable
declare dso_local void @CGenerator__genConverted__(ptr noundef, i32, ptr, ptr noundef, ptr, ptr) #2

; Function Attrs: nounwind uwtable
declare dso_local { ptr, ptr } @CGenerator__nodeTag__(ptr noundef, i32, ptr) #2

; Function Attrs: nounwind uwtable
define dso_local void @CGenerator__genForeignArgImpl__(ptr noundef %0, i32 %1, ptr %2, ptr noundef %3, i8 noundef zeroext %4, ptr noundef %5) #2 {
  %7 = alloca %struct.Node__, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca %struct.tag_____Tag__, align 8
  %13 = alloca %struct.tag_____Tag__, align 8
  %14 = alloca i8, align 1
  %15 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 0
  store i32 %1, ptr %15, align 8
  %16 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 1
  store ptr %2, ptr %16, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i8 %4, ptr %10, align 1, !tbaa !9
  store ptr %5, ptr %11, align 8, !tbaa !5
  %17 = load i8, ptr %10, align 1, !tbaa !9
  %18 = icmp ne i8 %17, 0
  br i1 %18, label %19, label %81

19:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #3
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.tag_____Param__, ptr %20, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %21, i64 16, i1 false), !tbaa.struct !10
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #3
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 0
  %24 = load i32, ptr %23, align 8
  %25 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8
  %27 = call { ptr, ptr } @CGenerator__nodeTag__(ptr noundef %22, i32 %24, ptr %26)
  %28 = getelementptr inbounds { ptr, ptr }, ptr %13, i32 0, i32 0
  %29 = extractvalue { ptr, ptr } %27, 0
  store ptr %29, ptr %28, align 8
  %30 = getelementptr inbounds { ptr, ptr }, ptr %13, i32 0, i32 1
  %31 = extractvalue { ptr, ptr } %27, 1
  store ptr %31, ptr %30, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #3
  %32 = getelementptr inbounds %struct.tag_____Tag__, ptr %12, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.tag_____GenerateContext__, ptr %34, i32 0, i32 4
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = getelementptr inbounds %struct.tag_____CommonTags__, ptr %36, i32 0, i32 19
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  %39 = icmp eq ptr %33, %38
  %40 = zext i1 %39 to i32
  %41 = trunc i32 %40 to i8
  store i8 %41, ptr %14, align 1, !tbaa !9
  %42 = load i8, ptr %14, align 1, !tbaa !9
  %43 = icmp ne i8 %42, 0
  br i1 %43, label %44, label %55

44:                                               ; preds = %19
  %45 = getelementptr inbounds %struct.tag_____Tag__, ptr %13, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !11
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.tag_____GenerateContext__, ptr %47, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = getelementptr inbounds %struct.tag_____CommonTags__, ptr %49, i32 0, i32 19
  %51 = load ptr, ptr %50, align 8, !tbaa !17
  %52 = icmp ne ptr %46, %51
  %53 = zext i1 %52 to i32
  %54 = trunc i32 %53 to i8
  store i8 %54, ptr %14, align 1, !tbaa !9
  br label %55

55:                                               ; preds = %44, %19
  %56 = load i8, ptr %14, align 1, !tbaa !9
  %57 = icmp ne i8 %56, 0
  br i1 %57, label %58, label %69

58:                                               ; preds = %55
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 0
  %62 = load i32, ptr %61, align 8
  %63 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8
  %65 = getelementptr inbounds { ptr, ptr }, ptr %13, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8
  %67 = getelementptr inbounds { ptr, ptr }, ptr %13, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8
  call void @CGenerator__genLvalueRefExpression__(ptr noundef %59, i32 %62, ptr %64, ptr %66, ptr %68, ptr noundef %60)
  br label %80

69:                                               ; preds = %55
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 0
  %73 = load i32, ptr %72, align 8
  %74 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8
  %76 = getelementptr inbounds { ptr, ptr }, ptr %12, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8
  %78 = getelementptr inbounds { ptr, ptr }, ptr %12, i32 0, i32 1
  %79 = load ptr, ptr %78, align 8
  call void @CGenerator__genConverted__(ptr noundef %70, i32 %73, ptr %75, ptr noundef %71, ptr %77, ptr %79)
  br label %80

80:                                               ; preds = %69, %58
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #3
  br label %94

81:                                               ; preds = %6
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = load ptr, ptr %11, align 8, !tbaa !5
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.tag_____Param__, ptr %84, i32 0, i32 3
  %86 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 0
  %87 = load i32, ptr %86, align 8
  %88 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 1
  %89 = load ptr, ptr %88, align 8
  %90 = getelementptr inbounds { ptr, ptr }, ptr %85, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8
  %92 = getelementptr inbounds { ptr, ptr }, ptr %85, i32 0, i32 1
  %93 = load ptr, ptr %92, align 8
  call void @CGenerator__genConverted__(ptr noundef %82, i32 %87, ptr %89, ptr noundef %83, ptr %91, ptr %93)
  br label %94

94:                                               ; preds = %81, %80
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @CGenerator__genLvalueRefExpression__(ptr noundef, i32, ptr, ptr, ptr, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 = !{!7, !7, i64 0}
!10 = !{i64 0, i64 8, !5, i64 8, i64 8, !5}
!11 = !{!12, !6, i64 0}
!12 = !{!"tag_____Tag__", !6, i64 0, !6, i64 8}
!13 = !{!14, !6, i64 32}
!14 = !{!"tag_____GenerateContext__", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !15, i64 48, !15, i64 52, !6, i64 56, !6, i64 64, !6, i64 72, !16, i64 80, !15, i64 96, !16, i64 104, !15, i64 120, !6, i64 128, !6, i64 136, !7, i64 144}
!15 = !{!"int", !7, i64 0}
!16 = !{!"", !6, i64 0, !15, i64 8}
!17 = !{!18, !6, i64 304}
!18 = !{!"tag_____CommonTags__", !12, i64 0, !12, i64 16, !12, i64 32, !12, i64 48, !12, i64 64, !12, i64 80, !12, i64 96, !12, i64 112, !12, i64 128, !12, i64 144, !12, i64 160, !12, i64 176, !12, i64 192, !12, i64 208, !12, i64 224, !12, i64 240, !12, i64 256, !12, i64 272, !12, i64 288, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368, !6, i64 376}


; 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: nounwind uwtable
declare dso_local void @CGenerator__genConverted__(ptr noundef, i32, ptr, ptr noundef, ptr, ptr) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local { ptr, ptr } @CGenerator__nodeTag__(ptr noundef, i32, ptr) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @CGenerator__genForeignArgImpl__(ptr noundef %0, i32 %1, ptr %2, ptr nocapture noundef readonly %3, i8 noundef zeroext %4, ptr noundef %5) local_unnamed_addr #0 {
  %.not = icmp eq i8 %4, 0
  %7 = getelementptr inbounds i8, ptr %3, i64 32
  %8 = load ptr, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr %3, i64 40
  %10 = load ptr, ptr %9, align 8
  br i1 %.not, label %22, label %11

11:                                               ; preds = %6
  %12 = tail call { ptr, ptr } @CGenerator__nodeTag__(ptr noundef %0, i32 %1, ptr %2)
  %13 = extractvalue { ptr, ptr } %12, 0
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 304
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  %18 = icmp ne ptr %8, %17
  %.not27 = icmp eq ptr %13, %17
  %spec.select = select i1 %18, i1 true, i1 %.not27
  br i1 %spec.select, label %21, label %19

19:                                               ; preds = %11
  %20 = extractvalue { ptr, ptr } %12, 1
  tail call void @CGenerator__genLvalueRefExpression__(ptr noundef nonnull %0, i32 %1, ptr %2, ptr %13, ptr %20, ptr noundef %5)
  br label %23

21:                                               ; preds = %11
  tail call void @CGenerator__genConverted__(ptr noundef nonnull %0, i32 %1, ptr %2, ptr noundef %5, ptr %8, ptr %10)
  br label %23

22:                                               ; preds = %6
  tail call void @CGenerator__genConverted__(ptr noundef %0, i32 %1, ptr %2, ptr noundef %5, ptr %8, ptr %10)
  br label %23

23:                                               ; preds = %19, %21, %22
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @CGenerator__genLvalueRefExpression__(ptr noundef, i32, ptr, ptr, ptr, 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" }

!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, !7, i64 32}
!6 = !{!"tag_____GenerateContext__", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !10, i64 52, !7, i64 56, !7, i64 64, !7, i64 72, !11, i64 80, !10, i64 96, !11, i64 104, !10, i64 120, !7, i64 128, !7, i64 136, !8, i64 144}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"", !7, i64 0, !10, i64 8}
!12 = !{!13, !7, i64 304}
!13 = !{!"tag_____CommonTags__", !14, i64 0, !14, i64 16, !14, i64 32, !14, i64 48, !14, i64 64, !14, i64 80, !14, i64 96, !14, i64 112, !14, i64 128, !14, i64 144, !14, i64 160, !14, i64 176, !14, i64 192, !14, i64 208, !14, i64 224, !14, i64 240, !14, i64 256, !14, i64 272, !14, i64 288, !7, i64 304, !7, i64 312, !7, i64 320, !7, i64 328, !7, i64 336, !7, i64 344, !7, i64 352, !7, i64 360, !7, i64 368, !7, i64 376}
!14 = !{!"tag_____Tag__", !7, i64 0, !7, i64 8}


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