; LLVM IR from JessonYue/LeetCodeLearning :: BaseDataStructure/elf (soparse)

; 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.DataOffest = type { i32, i16, i32, i16, i32, i32, i32, i32, i32, i32, i32, i32, i16, i32, i32 }
%struct.Elf32_Sym = type { i32, i32, i32, i8, i8, i16 }

@.str.52 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.54 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [58 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

declare i32 @fseek(ptr noundef, i64 noundef, i32 noundef) #1

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #1

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

; 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
define dso_local void @parseSymtabSection(ptr noundef %0, ptr noundef byval(%struct.DataOffest) align 8 %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %struct.Elf32_Sym, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %10 = getelementptr inbounds %struct.DataOffest, ptr %1, i32 0, i32 13
  %11 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %11, ptr %4, align 4, !tbaa !13
  %12 = getelementptr inbounds %struct.DataOffest, ptr %1, i32 0, i32 14
  %13 = load i32, ptr %12, align 8, !tbaa !14
  store i32 %13, ptr %6, align 4, !tbaa !13
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str.52)
  store i32 0, ptr %9, align 4, !tbaa !13
  br label %15

15:                                               ; preds = %51, %2
  %16 = load i32, ptr %9, align 4, !tbaa !13
  %17 = load i32, ptr %6, align 4, !tbaa !13
  %18 = icmp ult i32 %16, %17
  br i1 %18, label %19, label %54

19:                                               ; preds = %15
  %20 = load i32, ptr %4, align 4, !tbaa !13
  %21 = load i32, ptr %9, align 4, !tbaa !13
  %22 = mul nsw i32 %21, 16
  %23 = add i32 %20, %22
  store i32 %23, ptr %5, align 4, !tbaa !13
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = load i32, ptr %5, align 4, !tbaa !13
  %26 = zext i32 %25 to i64
  %27 = call i32 @fseek(ptr noundef %24, i64 noundef %26, i32 noundef 0)
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = call i64 @fread(ptr noundef %7, i64 noundef 1, i64 noundef 16, ptr noundef %28)
  %30 = getelementptr inbounds %struct.Elf32_Sym, ptr %7, i32 0, i32 0
  %31 = load i32, ptr %30, align 4, !tbaa !15
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.53, i32 noundef %31)
  %33 = getelementptr inbounds %struct.Elf32_Sym, ptr %7, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !17
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.54, i32 noundef %34)
  %36 = getelementptr inbounds %struct.Elf32_Sym, ptr %7, i32 0, i32 2
  %37 = load i32, ptr %36, align 4, !tbaa !18
  %38 = call i32 (ptr, ...) @printf(ptr noundef @.str.55, i32 noundef %37)
  %39 = getelementptr inbounds %struct.Elf32_Sym, ptr %7, i32 0, i32 3
  %40 = load i8, ptr %39, align 4, !tbaa !19
  %41 = zext i8 %40 to i32
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.56, i32 noundef %41)
  %43 = getelementptr inbounds %struct.Elf32_Sym, ptr %7, i32 0, i32 4
  %44 = load i8, ptr %43, align 1, !tbaa !20
  %45 = zext i8 %44 to i32
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.57, i32 noundef %45)
  %47 = getelementptr inbounds %struct.Elf32_Sym, ptr %7, i32 0, i32 5
  %48 = load i16, ptr %47, align 2, !tbaa !21
  %49 = zext i16 %48 to i32
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, i32 noundef %49)
  br label %51

51:                                               ; preds = %19
  %52 = load i32, ptr %9, align 4, !tbaa !13
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %9, align 4, !tbaa !13
  br label %15, !llvm.loop !22

54:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = !{!10, !11, i64 52}
!10 = !{!"DataOffest", !11, i64 0, !12, i64 4, !11, i64 8, !12, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !12, i64 48, !11, i64 52, !11, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 56}
!15 = !{!16, !11, i64 0}
!16 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 12, !7, i64 13, !12, i64 14}
!17 = !{!16, !11, i64 4}
!18 = !{!16, !11, i64 8}
!19 = !{!16, !7, i64 12}
!20 = !{!16, !7, i64 13}
!21 = !{!16, !12, i64 14}
!22 = distinct !{!22, !23}
!23 = !{!"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"

%struct.DataOffest = type { i32, i16, i32, i16, i32, i32, i32, i32, i32, i32, i32, i32, i16, i32, i32 }
%struct.Elf32_Sym = type { i32, i32, i32, i8, i8, i16 }

@.str.52 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.54 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [58 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nofree nounwind
declare noundef i32 @fseek(ptr nocapture noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nofree nounwind uwtable
define dso_local void @parseSymtabSection(ptr nocapture noundef %0, ptr nocapture noundef readonly byval(%struct.DataOffest) align 8 %1) local_unnamed_addr #2 {
  %3 = alloca %struct.Elf32_Sym, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #3
  %4 = getelementptr inbounds i8, ptr %1, i64 52
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 56
  %7 = load i32, ptr %6, align 8, !tbaa !11
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.52)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %9 = getelementptr inbounds i8, ptr %3, i64 4
  %10 = getelementptr inbounds i8, ptr %3, i64 8
  %11 = getelementptr inbounds i8, ptr %3, i64 12
  %12 = getelementptr inbounds i8, ptr %3, i64 13
  %13 = getelementptr inbounds i8, ptr %3, i64 14
  %wide.trip.count = zext i32 %7 to i64
  br label %14

14:                                               ; preds = %.lr.ph, %14
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %14 ]
  %indvars.iv.tr = trunc i64 %indvars.iv to i32
  %15 = shl i32 %indvars.iv.tr, 4
  %16 = add i32 %15, %5
  %17 = zext i32 %16 to i64
  %18 = tail call i32 @fseek(ptr noundef %0, i64 noundef %17, i32 noundef 0)
  %19 = call i64 @fread(ptr noundef nonnull %3, i64 noundef 1, i64 noundef 16, ptr noundef %0)
  %20 = load i32, ptr %3, align 4, !tbaa !12
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.53, i32 noundef %20)
  %22 = load i32, ptr %9, align 4, !tbaa !14
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.54, i32 noundef %22)
  %24 = load i32, ptr %10, align 4, !tbaa !15
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.55, i32 noundef %24)
  %26 = load i8, ptr %11, align 4, !tbaa !16
  %27 = zext i8 %26 to i32
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.56, i32 noundef %27)
  %29 = load i8, ptr %12, align 1, !tbaa !17
  %30 = zext i8 %29 to i32
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.57, i32 noundef %30)
  %32 = load i16, ptr %13, align 2, !tbaa !18
  %33 = zext i16 %32 to i32
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.58, i32 noundef %33)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %14, !llvm.loop !19

._crit_edge:                                      ; preds = %14, %2
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #3
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { nofree 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, !7, i64 52}
!6 = !{!"DataOffest", !7, i64 0, !10, i64 4, !7, i64 8, !10, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !10, i64 48, !7, i64 52, !7, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!6, !7, i64 56}
!12 = !{!13, !7, i64 0}
!13 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12, !8, i64 13, !10, i64 14}
!14 = !{!13, !7, i64 4}
!15 = !{!13, !7, i64 8}
!16 = !{!13, !8, i64 12}
!17 = !{!13, !8, i64 13}
!18 = !{!13, !10, i64 14}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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