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

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

@mu_____string438 = external dso_local global %struct.string__, align 8
@mu_____string303 = external dso_local global %struct.string__, align 8

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @CGenerator__genForeignCall__(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 %3, ptr %4, ptr noundef %5) #1 {
  %7 = alloca %struct.Node__, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i8, align 1
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  %15 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 0
  store i32 %3, ptr %15, align 8
  %16 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 1
  store ptr %4, ptr %16, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %5, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #2
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.tag_____FunctionDef__, ptr %17, i32 0, i32 12
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = and i32 %19, 32
  %21 = icmp ne i32 %20, 0
  %22 = zext i1 %21 to i32
  %23 = trunc i32 %22 to i8
  store i8 %23, ptr %12, align 1, !tbaa !15
  %24 = load i8, ptr %12, align 1, !tbaa !15
  %25 = icmp ne i8 %24, 0
  br i1 %25, label %26, label %37

26:                                               ; preds = %6
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.tag_____FunctionDef__, ptr %27, i32 0, i32 16
  %29 = getelementptr inbounds %struct.tag_____Tag__, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = getelementptr inbounds %struct.tag_____Namespace__, ptr %30, i32 0, i32 3
  %32 = load i32, ptr %31, align 4, !tbaa !17
  %33 = and i32 %32, 256
  %34 = icmp ne i32 %33, 0
  %35 = zext i1 %34 to i32
  %36 = trunc i32 %35 to i8
  store i8 %36, ptr %12, align 1, !tbaa !15
  br label %37

37:                                               ; preds = %26, %6
  %38 = load i8, ptr %12, align 1, !tbaa !15
  %39 = icmp ne i8 %38, 0
  br i1 %39, label %40, label %49

40:                                               ; preds = %37
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 0
  %46 = load i32, ptr %45, align 8
  %47 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8
  call void @CGenerator__genForeignMarshalStructReturnTypeCall__(ptr noundef %41, ptr noundef %42, ptr noundef %43, i32 %46, ptr %48, ptr noundef %44)
  br label %113

49:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #2
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.tag_____FunctionDef__, ptr %50, i32 0, i32 16
  %52 = getelementptr inbounds %struct.tag_____Tag__, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !16
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.tag_____GenerateContext__, ptr %54, i32 0, i32 4
  %56 = load ptr, ptr %55, align 8, !tbaa !19
  %57 = getelementptr inbounds %struct.tag_____CommonTags__, ptr %56, i32 0, i32 0
  %58 = getelementptr inbounds %struct.tag_____Tag__, ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !21
  %60 = icmp eq ptr %53, %59
  %61 = zext i1 %60 to i32
  %62 = trunc i32 %61 to i8
  store i8 %62, ptr %13, align 1, !tbaa !15
  %63 = load i8, ptr %13, align 1, !tbaa !15
  %64 = icmp ne i8 %63, 0
  br i1 %64, label %87, label %65

65:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #2
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.tag_____GenerateContext__, ptr %66, i32 0, i32 16
  %68 = load ptr, ptr %67, align 8, !tbaa !23
  %69 = icmp ne ptr %68, null
  %70 = zext i1 %69 to i32
  %71 = trunc i32 %70 to i8
  store i8 %71, ptr %14, align 1, !tbaa !15
  %72 = load i8, ptr %14, align 1, !tbaa !15
  %73 = icmp ne i8 %72, 0
  br i1 %73, label %74, label %85

74:                                               ; preds = %65
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.tag_____GenerateContext__, ptr %75, i32 0, i32 16
  %77 = load ptr, ptr %76, align 8, !tbaa !23
  %78 = getelementptr inbounds %struct.tag_____ExpressionStatement__, ptr %77, i32 0, i32 0
  %79 = getelementptr inbounds %struct.Node__, ptr %78, i32 0, i32 1
  %80 = load ptr, ptr %79, align 8, !tbaa !24
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = icmp eq ptr %80, %81
  %83 = zext i1 %82 to i32
  %84 = trunc i32 %83 to i8
  store i8 %84, ptr %14, align 1, !tbaa !15
  br label %85

85:                                               ; preds = %74, %65
  %86 = load i8, ptr %14, align 1, !tbaa !15
  store i8 %86, ptr %13, align 1, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #2
  br label %87

87:                                               ; preds = %85, %49
  %88 = load i8, ptr %13, align 1, !tbaa !15
  %89 = icmp ne i8 %88, 0
  br i1 %89, label %104, label %90

90:                                               ; preds = %87
  %91 = load ptr, ptr %11, align 8, !tbaa !5
  %92 = load ptr, ptr @mu_____string438, align 8
  %93 = load i32, ptr getelementptr inbounds ({ ptr, i32 }, ptr @mu_____string438, i32 0, i32 1), align 8
  call void @StringBuilder__write__(ptr noundef %91, ptr %92, i32 %93)
  %94 = load ptr, ptr %11, align 8, !tbaa !5
  %95 = load ptr, ptr %9, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.tag_____FunctionDef__, ptr %95, i32 0, i32 16
  %97 = getelementptr inbounds { ptr, ptr }, ptr %96, i32 0, i32 0
  %98 = load ptr, ptr %97, align 8
  %99 = getelementptr inbounds { ptr, ptr }, ptr %96, i32 0, i32 1
  %100 = load ptr, ptr %99, align 8
  call void @CGenerator__writeTag__(ptr noundef %94, ptr %98, ptr %100)
  %101 = load ptr, ptr %11, align 8, !tbaa !5
  %102 = load ptr, ptr @mu_____string303, align 8
  %103 = load i32, ptr getelementptr inbounds ({ ptr, i32 }, ptr @mu_____string303, i32 0, i32 1), align 8
  call void @StringBuilder__write__(ptr noundef %101, ptr %102, i32 %103)
  br label %104

104:                                              ; preds = %90, %87
  %105 = load ptr, ptr %8, align 8, !tbaa !5
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  %107 = load ptr, ptr %10, align 8, !tbaa !5
  %108 = load ptr, ptr %11, align 8, !tbaa !5
  %109 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 0
  %110 = load i32, ptr %109, align 8
  %111 = getelementptr inbounds { i32, ptr }, ptr %7, i32 0, i32 1
  %112 = load ptr, ptr %111, align 8
  call void @CGenerator__genForeignCallImpl__(ptr noundef %105, ptr noundef %106, ptr noundef %107, i32 %110, ptr %112, ptr noundef %108)
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #2
  br label %113

113:                                              ; preds = %104, %40
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #2
  ret void
}

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, !12, i64 104}
!10 = !{!"tag_____FunctionDef__", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !12, i64 104, !6, i64 112, !13, i64 120, !13, i64 136, !14, i64 152, !12, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !13, i64 208}
!11 = !{!"", !12, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !6, i64 0, !12, i64 8}
!14 = !{!"tag_____Tag__", !6, i64 0, !6, i64 8}
!15 = !{!7, !7, i64 0}
!16 = !{!10, !6, i64 152}
!17 = !{!18, !12, i64 28}
!18 = !{!"tag_____Namespace__", !13, i64 0, !6, i64 16, !12, i64 24, !12, 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, !12, i64 104}
!19 = !{!20, !6, i64 32}
!20 = !{!"tag_____GenerateContext__", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 52, !6, i64 56, !6, i64 64, !6, i64 72, !13, i64 80, !12, i64 96, !13, i64 104, !12, i64 120, !6, i64 128, !6, i64 136, !7, i64 144}
!21 = !{!22, !6, i64 0}
!22 = !{!"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, !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}
!23 = !{!20, !6, i64 136}
!24 = !{!25, !6, i64 8}
!25 = !{!"tag_____ExpressionStatement__", !11, 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.string__ = type { ptr, i32 }

@mu_____string438 = external dso_local local_unnamed_addr global %struct.string__, align 8
@mu_____string303 = external dso_local local_unnamed_addr global %struct.string__, align 8

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @CGenerator__genForeignCall__(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 %3, ptr %4, ptr noundef %5) local_unnamed_addr #0 {
  %7 = getelementptr inbounds i8, ptr %1, i64 104
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = and i32 %8, 32
  %.not = icmp eq i32 %9, 0
  %.phi.trans.insert = getelementptr inbounds i8, ptr %1, i64 152
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !14
  br i1 %.not, label %.critedge, label %10

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %.pre, i64 28
  %12 = load i32, ptr %11, align 4, !tbaa !15
  %13 = and i32 %12, 256
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %.critedge, label %15

15:                                               ; preds = %10
  tail call void @CGenerator__genForeignMarshalStructReturnTypeCall__(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %2, i32 %3, ptr %4, ptr noundef %5)
  br label %34

.critedge:                                        ; preds = %6, %10
  %16 = getelementptr inbounds i8, ptr %1, i64 152
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %20 = icmp eq ptr %.pre, %19
  br i1 %20, label %.critedge35, label %21

21:                                               ; preds = %.critedge
  %22 = getelementptr inbounds i8, ptr %0, i64 136
  %23 = load ptr, ptr %22, align 8, !tbaa !21
  %.not32 = icmp eq ptr %23, null
  br i1 %.not32, label %.critedge37, label %24

24:                                               ; preds = %21
  %25 = getelementptr inbounds i8, ptr %23, i64 8
  %26 = load ptr, ptr %25, align 8, !tbaa !22
  %.not38 = icmp eq ptr %26, %2
  br i1 %.not38, label %.critedge35, label %.critedge37

.critedge37:                                      ; preds = %21, %24
  %27 = load ptr, ptr @mu_____string438, align 8
  %28 = load i32, ptr getelementptr inbounds (i8, ptr @mu_____string438, i64 8), align 8
  tail call void @StringBuilder__write__(ptr noundef %5, ptr %27, i32 %28)
  %29 = load ptr, ptr %16, align 8
  %30 = getelementptr inbounds i8, ptr %1, i64 160
  %31 = load ptr, ptr %30, align 8
  tail call void @CGenerator__writeTag__(ptr noundef %5, ptr %29, ptr %31)
  %32 = load ptr, ptr @mu_____string303, align 8
  %33 = load i32, ptr getelementptr inbounds (i8, ptr @mu_____string303, i64 8), align 8
  tail call void @StringBuilder__write__(ptr noundef %5, ptr %32, i32 %33)
  br label %.critedge35

.critedge35:                                      ; preds = %.critedge, %.critedge37, %24
  tail call void @CGenerator__genForeignCallImpl__(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, i32 %3, ptr %4, ptr noundef %5)
  br label %34

34:                                               ; preds = %.critedge35, %15
  ret void
}

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, !11, i64 104}
!6 = !{!"tag_____FunctionDef__", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !11, i64 104, !7, i64 112, !12, i64 120, !12, i64 136, !13, i64 152, !11, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200, !12, i64 208}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !7, i64 8}
!11 = !{!"int", !8, i64 0}
!12 = !{!"", !7, i64 0, !11, i64 8}
!13 = !{!"tag_____Tag__", !7, i64 0, !7, i64 8}
!14 = !{!6, !7, i64 152}
!15 = !{!16, !11, i64 28}
!16 = !{!"tag_____Namespace__", !12, i64 0, !7, i64 16, !11, i64 24, !11, i64 28, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !11, i64 104}
!17 = !{!18, !7, i64 32}
!18 = !{!"tag_____GenerateContext__", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !11, i64 48, !11, i64 52, !7, i64 56, !7, i64 64, !7, i64 72, !12, i64 80, !11, i64 96, !12, i64 104, !11, i64 120, !7, i64 128, !7, i64 136, !8, i64 144}
!19 = !{!20, !7, i64 0}
!20 = !{!"tag_____CommonTags__", !13, i64 0, !13, i64 16, !13, i64 32, !13, i64 48, !13, i64 64, !13, i64 80, !13, i64 96, !13, i64 112, !13, i64 128, !13, i64 144, !13, i64 160, !13, i64 176, !13, i64 192, !13, i64 208, !13, i64 224, !13, i64 240, !13, i64 256, !13, i64 272, !13, 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}
!21 = !{!18, !7, i64 136}
!22 = !{!23, !7, i64 8}
!23 = !{!"tag_____ExpressionStatement__", !10, i64 0}


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