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

%struct.metadata_index = type { ptr, ptr, ptr, i8, i16, i64, ptr, ptr, ptr, i64 }
%struct.metadata_type = type { i32, i8, [32 x i8] }

@.str.82 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.84 = external hidden unnamed_addr constant [57 x i8], align 1

; 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 signext i8 @data_type_enum_to_char(i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @print_metadata_index(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.metadata_index, ptr %6, i32 0, i32 0
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %8, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.metadata_index, ptr %9, i32 0, i32 3
  %11 = load i8, ptr %10, align 8, !tbaa !13
  %12 = zext i8 %11 to i32
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.metadata_index, ptr %13, i32 0, i32 5
  %15 = load i64, ptr %14, align 8, !tbaa !14
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.metadata_index, ptr %16, i32 0, i32 4
  %18 = load i16, ptr %17, align 2, !tbaa !15
  %19 = zext i16 %18 to i32
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.metadata_index, ptr %20, i32 0, i32 9
  %22 = load i64, ptr %21, align 8, !tbaa !16
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str.82, i32 noundef %12, i64 noundef %15, i32 noundef %19, i64 noundef %22)
  store i32 0, ptr %3, align 4, !tbaa !17
  br label %24

24:                                               ; preds = %84, %1
  %25 = load i32, ptr %3, align 4, !tbaa !17
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.metadata_index, ptr %26, i32 0, i32 3
  %28 = load i8, ptr %27, align 8, !tbaa !13
  %29 = zext i8 %28 to i32
  %30 = icmp slt i32 %25, %29
  br i1 %30, label %31, label %87

31:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.metadata_index, ptr %32, i32 0, i32 8
  %34 = load ptr, ptr %33, align 8, !tbaa !19
  %35 = load i32, ptr %3, align 4, !tbaa !17
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds ptr, ptr %34, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  store ptr %38, ptr %5, align 8, !tbaa !5
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %65

41:                                               ; preds = %31
  %42 = load i32, ptr %3, align 4, !tbaa !17
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load i32, ptr %3, align 4, !tbaa !17
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i8, ptr %43, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !20
  %48 = zext i8 %47 to i32
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.metadata_type, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 4, !tbaa !21
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.metadata_type, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 4, !tbaa !21
  %55 = call signext i8 @data_type_enum_to_char(i32 noundef %54)
  %56 = sext i8 %55 to i32
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.metadata_type, ptr %57, i32 0, i32 2
  %59 = getelementptr inbounds [32 x i8], ptr %58, i64 0, i64 0
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.metadata_type, ptr %60, i32 0, i32 1
  %62 = load i8, ptr %61, align 4, !tbaa !23
  %63 = zext i8 %62 to i32
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.83, i32 noundef %42, i32 noundef %48, i32 noundef %51, i32 noundef %56, ptr noundef %59, i32 noundef %63)
  br label %83

65:                                               ; preds = %31
  %66 = load i32, ptr %3, align 4, !tbaa !17
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.metadata_type, ptr %67, i32 0, i32 0
  %69 = load i32, ptr %68, align 4, !tbaa !21
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.metadata_type, ptr %70, i32 0, i32 0
  %72 = load i32, ptr %71, align 4, !tbaa !21
  %73 = call signext i8 @data_type_enum_to_char(i32 noundef %72)
  %74 = sext i8 %73 to i32
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.metadata_type, ptr %75, i32 0, i32 2
  %77 = getelementptr inbounds [32 x i8], ptr %76, i64 0, i64 0
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.metadata_type, ptr %78, i32 0, i32 1
  %80 = load i8, ptr %79, align 4, !tbaa !23
  %81 = zext i8 %80 to i32
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.84, i32 noundef %66, i32 noundef %69, i32 noundef %74, ptr noundef %77, i32 noundef %81)
  br label %83

83:                                               ; preds = %65, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %84

84:                                               ; preds = %83
  %85 = load i32, ptr %3, align 4, !tbaa !17
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %3, align 4, !tbaa !17
  br label %24, !llvm.loop !24

87:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  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 = { "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 = !{!10, !6, i64 0}
!10 = !{!"metadata_index", !6, i64 0, !6, i64 8, !6, i64 16, !7, i64 24, !11, i64 26, !12, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !12, i64 64}
!11 = !{!"short", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !7, i64 24}
!14 = !{!10, !12, i64 32}
!15 = !{!10, !11, i64 26}
!16 = !{!10, !12, i64 64}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!10, !6, i64 56}
!20 = !{!7, !7, i64 0}
!21 = !{!22, !18, i64 0}
!22 = !{!"metadata_type", !18, i64 0, !7, i64 4, !7, i64 5}
!23 = !{!22, !7, i64 4}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


; 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.82 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.84 = external hidden unnamed_addr constant [57 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @data_type_enum_to_char(i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @print_metadata_index(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load i8, ptr %3, align 8, !tbaa !12
  %5 = zext i8 %4 to i32
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = load i64, ptr %6, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 26
  %9 = load i16, ptr %8, align 2, !tbaa !14
  %10 = zext i16 %9 to i32
  %11 = getelementptr inbounds i8, ptr %0, i64 64
  %12 = load i64, ptr %11, align 8, !tbaa !15
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.82, i32 noundef %5, i64 noundef %7, i32 noundef %10, i64 noundef %12)
  %14 = load i8, ptr %3, align 8, !tbaa !12
  %.not24 = icmp eq i8 %14, 0
  br i1 %.not24, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %15 = getelementptr inbounds i8, ptr %0, i64 56
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %indvars.iv27 = phi i64 [ %indvars.iv.next28, %.lr.ph.split.us ], [ 0, %.lr.ph ]
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  %17 = getelementptr inbounds ptr, ptr %16, i64 %indvars.iv27
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = load i32, ptr %18, align 4, !tbaa !18
  %20 = tail call signext i8 @data_type_enum_to_char(i32 noundef %19)
  %21 = sext i8 %20 to i32
  %22 = getelementptr inbounds i8, ptr %18, i64 5
  %23 = getelementptr inbounds i8, ptr %18, i64 4
  %24 = load i8, ptr %23, align 4, !tbaa !21
  %25 = zext i8 %24 to i32
  %26 = trunc nuw nsw i64 %indvars.iv27 to i32
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.84, i32 noundef %26, i32 noundef %19, i32 noundef %21, ptr noundef nonnull %22, i32 noundef %25)
  %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1
  %28 = load i8, ptr %3, align 8, !tbaa !12
  %29 = zext i8 %28 to i64
  %30 = icmp ult i64 %indvars.iv.next28, %29
  br i1 %30, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !22

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.split
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph.split ], [ 0, %.lr.ph ]
  %31 = load ptr, ptr %15, align 8, !tbaa !16
  %32 = getelementptr inbounds ptr, ptr %31, i64 %indvars.iv
  %33 = load ptr, ptr %32, align 8, !tbaa !17
  %34 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv
  %35 = load i8, ptr %34, align 1, !tbaa !24
  %36 = zext i8 %35 to i32
  %37 = load i32, ptr %33, align 4, !tbaa !18
  %38 = tail call signext i8 @data_type_enum_to_char(i32 noundef %37)
  %39 = sext i8 %38 to i32
  %40 = getelementptr inbounds i8, ptr %33, i64 5
  %41 = getelementptr inbounds i8, ptr %33, i64 4
  %42 = load i8, ptr %41, align 4, !tbaa !21
  %43 = zext i8 %42 to i32
  %44 = trunc nuw nsw i64 %indvars.iv to i32
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.83, i32 noundef %44, i32 noundef %36, i32 noundef %37, i32 noundef %39, ptr noundef nonnull %40, i32 noundef %43)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %46 = load i8, ptr %3, align 8, !tbaa !12
  %47 = zext i8 %46 to i64
  %48 = icmp ult i64 %indvars.iv.next, %47
  br i1 %48, label %.lr.ph.split, label %._crit_edge, !llvm.loop !22

._crit_edge:                                      ; preds = %.lr.ph.split, %.lr.ph.split.us, %1
  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" }
attributes #1 = { 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" }

!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_index", !7, i64 0, !7, i64 8, !7, i64 16, !8, i64 24, !10, i64 26, !11, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !11, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !8, i64 24}
!13 = !{!6, !11, i64 32}
!14 = !{!6, !10, i64 26}
!15 = !{!6, !11, i64 64}
!16 = !{!6, !7, i64 56}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !20, i64 0}
!19 = !{!"metadata_type", !20, i64 0, !8, i64 4, !8, i64 5}
!20 = !{!"int", !8, i64 0}
!21 = !{!19, !8, i64 4}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!8, !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass