; LLVM IR from ryanlayer/giggle :: src (metadata_index)

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

%union.metadata_data = type { i64 }
%struct.metadata_type = type { i32, i8, [32 x i8] }

@.str.10 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.69 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.70 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.71 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.72 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.73 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.74 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.75 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.76 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.77 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local void @print_metadata_data(ptr noundef %0, i64 %1) #1 {
  %3 = alloca %union.metadata_data, align 8
  %4 = alloca ptr, align 8
  %5 = getelementptr inbounds %union.metadata_data, ptr %3, i32 0, i32 0
  store i64 %1, ptr %5, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.metadata_type, ptr %6, i32 0, i32 2
  %8 = getelementptr inbounds [32 x i8], ptr %7, i64 0, i64 0
  %9 = call i32 (ptr, ...) @printf(ptr noundef @.str.69, ptr noundef %8)
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.metadata_type, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 4, !tbaa !9
  switch i32 %12, label %41 [
    i32 0, label %13
    i32 1, label %17
    i32 2, label %21
    i32 3, label %25
    i32 4, label %28
    i32 5, label %31
    i32 6, label %35
    i32 7, label %38
  ]

13:                                               ; preds = %2
  %14 = load i8, ptr %3, align 8, !tbaa !12
  %15 = sext i8 %14 to i32
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str.70, i32 noundef %15)
  br label %45

17:                                               ; preds = %2
  %18 = load i8, ptr %3, align 8, !tbaa !12
  %19 = sext i8 %18 to i32
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.71, i32 noundef %19)
  br label %45

21:                                               ; preds = %2
  %22 = load i16, ptr %3, align 8, !tbaa !12
  %23 = sext i16 %22 to i32
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.72, i32 noundef %23)
  br label %45

25:                                               ; preds = %2
  %26 = load i32, ptr %3, align 8, !tbaa !12
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.73, i32 noundef %26)
  br label %45

28:                                               ; preds = %2
  %29 = load i64, ptr %3, align 8, !tbaa !12
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str.74, i64 noundef %29)
  br label %45

31:                                               ; preds = %2
  %32 = load float, ptr %3, align 8, !tbaa !12
  %33 = fpext float %32 to double
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.75, double noundef %33)
  br label %45

35:                                               ; preds = %2
  %36 = load double, ptr %3, align 8, !tbaa !12
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.76, double noundef %36)
  br label %45

38:                                               ; preds = %2
  %39 = load ptr, ptr %3, align 8, !tbaa !12
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.77, ptr noundef %39)
  br label %45

41:                                               ; preds = %2
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.metadata_type, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 4, !tbaa !9
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.10, i32 noundef %44) #3
  unreachable

45:                                               ; preds = %38, %35, %31, %28, %25, %21, %17, %13
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

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

!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 0}
!10 = !{!"metadata_type", !11, i64 0, !7, i64 4, !7, i64 5}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, 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"

@.str.10 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.69 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.70 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.71 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.72 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.73 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.74 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.75 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.76 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.77 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @print_metadata_data(ptr noundef %0, i64 %1) local_unnamed_addr #1 {
  %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc = trunc i64 %1 to i8
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift87 = lshr i64 %1, 8
  %.sroa.0.sroa.0.sroa.9.0.extract.shift88 = lshr i64 %1, 16
  %3 = getelementptr inbounds i8, ptr %0, i64 5
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.69, ptr noundef nonnull %3)
  %5 = load i32, ptr %0, align 4, !tbaa !5
  switch i32 %5, label %35 [
    i32 0, label %6
    i32 1, label %9
    i32 2, label %12
    i32 3, label %16
    i32 4, label %20
    i32 5, label %22
    i32 6, label %29
    i32 7, label %32
  ]

6:                                                ; preds = %2
  %7 = sext i8 %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc to i32
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.70, i32 noundef %7)
  br label %36

9:                                                ; preds = %2
  %10 = sext i8 %.sroa.0.sroa.0.sroa.0.sroa.0.0.extract.trunc to i32
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.71, i32 noundef %10)
  br label %36

12:                                               ; preds = %2
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.trunc = trunc i64 %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift87 to i16
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext = shl i16 %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.trunc, 8
  %13 = trunc i64 %1 to i16
  %.sroa.0.sroa.0.sroa.0.sroa.0.0.insert.ext = and i16 %13, 255
  %.sroa.0.sroa.0.sroa.0.sroa.0.0.insert.insert = or disjoint i16 %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext, %.sroa.0.sroa.0.sroa.0.sroa.0.0.insert.ext
  %14 = sext i16 %.sroa.0.sroa.0.sroa.0.sroa.0.0.insert.insert to i32
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.72, i32 noundef %14)
  br label %36

16:                                               ; preds = %2
  %.sroa.0.sroa.0.sroa.9.0.extract.trunc = trunc i64 %.sroa.0.sroa.0.sroa.9.0.extract.shift88 to i32
  %17 = trunc i64 %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift87 to i32
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext71 = shl i32 %17, 8
  %18 = trunc i64 %1 to i32
  %.sroa.0.sroa.0.sroa.0.sroa.0.0.insert.ext55 = and i32 %18, 255
  %.sroa.0.sroa.0.sroa.9.0.insert.ext36 = shl i32 %.sroa.0.sroa.0.sroa.9.0.extract.trunc, 16
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext71.masked = and i32 %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext71, 65280
  %.sroa.0.sroa.0.sroa.0.0.insert.ext24 = or disjoint i32 %.sroa.0.sroa.0.sroa.0.sroa.0.0.insert.ext55, %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext71.masked
  %.sroa.0.sroa.0.sroa.0.0.insert.insert26 = or disjoint i32 %.sroa.0.sroa.0.sroa.0.0.insert.ext24, %.sroa.0.sroa.0.sroa.9.0.insert.ext36
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.73, i32 noundef %.sroa.0.sroa.0.sroa.0.0.insert.insert26)
  br label %36

20:                                               ; preds = %2
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.74, i64 noundef %1)
  br label %36

22:                                               ; preds = %2
  %23 = trunc i64 %.sroa.0.sroa.0.sroa.0.sroa.9.0.extract.shift87 to i32
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext67 = shl i32 %23, 8
  %24 = trunc i64 %1 to i32
  %.sroa.0.sroa.0.sroa.0.sroa.0.0.insert.ext52 = and i32 %24, 255
  %25 = trunc i64 %.sroa.0.sroa.0.sroa.9.0.extract.shift88 to i32
  %.sroa.0.sroa.0.sroa.9.0.insert.ext = shl i32 %25, 16
  %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext67.masked = and i32 %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext67, 65280
  %.sroa.0.sroa.0.sroa.0.0.insert.ext = or disjoint i32 %.sroa.0.sroa.0.sroa.0.sroa.0.0.insert.ext52, %.sroa.0.sroa.0.sroa.0.sroa.9.0.insert.ext67.masked
  %.sroa.0.sroa.0.sroa.0.0.insert.insert = or disjoint i32 %.sroa.0.sroa.0.sroa.0.0.insert.ext, %.sroa.0.sroa.0.sroa.9.0.insert.ext
  %26 = bitcast i32 %.sroa.0.sroa.0.sroa.0.0.insert.insert to float
  %27 = fpext float %26 to double
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.75, double noundef %27)
  br label %36

29:                                               ; preds = %2
  %30 = bitcast i64 %1 to double
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.76, double noundef %30)
  br label %36

32:                                               ; preds = %2
  %33 = inttoptr i64 %1 to ptr
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.77, ptr noundef %33)
  br label %36

35:                                               ; preds = %2
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.10, i32 noundef %5) #3
  unreachable

36:                                               ; preds = %32, %29, %22, %20, %16, %12, %9, %6
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

attributes #0 = { noreturn "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 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 = { nofree nounwind "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 = { noreturn 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, !7, i64 0}
!6 = !{!"metadata_type", !7, i64 0, !8, i64 4, !8, i64 5}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,TailCallElimPass