; LLVM IR from JessonYue/LeetCodeLearning :: Array/zhangjunwei/elf (parseElf)

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

@.str.28 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.54 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.59 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.60 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.61 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.62 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.63 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.64 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.66 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.68 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.69 = external hidden unnamed_addr constant [26 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @print_symbol_table(ptr noundef %0, i32 noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %8 = call i32 (ptr, ...) @printf(ptr noundef @.str.53)
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %74, %3
  %10 = load i32, ptr %7, align 4, !tbaa !9
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %13, label %77

13:                                               ; preds = %9
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = call i32 (ptr, ...) @printf(ptr noundef @.str.54, i32 noundef %14)
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds %struct.Elf32_Sym, ptr %17, i64 %19
  %21 = getelementptr inbounds %struct.Elf32_Sym, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 4, !tbaa !11
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds i8, ptr %16, i64 %23
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.55, ptr noundef %24)
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds %struct.Elf32_Sym, ptr %26, i64 %28
  %30 = getelementptr inbounds %struct.Elf32_Sym, ptr %29, i32 0, i32 2
  %31 = load i32, ptr %30, align 4, !tbaa !14
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.56, i32 noundef %31)
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds %struct.Elf32_Sym, ptr %33, i64 %35
  %37 = getelementptr inbounds %struct.Elf32_Sym, ptr %36, i32 0, i32 1
  %38 = load i32, ptr %37, align 4, !tbaa !15
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.57, i32 noundef %38)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds %struct.Elf32_Sym, ptr %40, i64 %42
  %44 = getelementptr inbounds %struct.Elf32_Sym, ptr %43, i32 0, i32 3
  %45 = load i8, ptr %44, align 4, !tbaa !16
  %46 = zext i8 %45 to i32
  %47 = and i32 %46, 15
  switch i32 %47, label %70 [
    i32 0, label %48
    i32 1, label %50
    i32 2, label %52
    i32 3, label %54
    i32 4, label %56
    i32 5, label %58
    i32 10, label %60
    i32 11, label %62
    i32 12, label %64
    i32 13, label %66
    i32 15, label %68
  ]

48:                                               ; preds = %13
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, ptr noundef @.str.59)
  br label %72

50:                                               ; preds = %13
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, ptr noundef @.str.60)
  br label %72

52:                                               ; preds = %13
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, ptr noundef @.str.61)
  br label %72

54:                                               ; preds = %13
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, ptr noundef @.str.62)
  br label %72

56:                                               ; preds = %13
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, ptr noundef @.str.63)
  br label %72

58:                                               ; preds = %13
  %59 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, ptr noundef @.str.64)
  br label %72

60:                                               ; preds = %13
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, ptr noundef @.str.65)
  br label %72

62:                                               ; preds = %13
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, ptr noundef @.str.66)
  br label %72

64:                                               ; preds = %13
  %65 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, ptr noundef @.str.67)
  br label %72

66:                                               ; preds = %13
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, ptr noundef @.str.68)
  br label %72

68:                                               ; preds = %13
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, ptr noundef @.str.69)
  br label %72

70:                                               ; preds = %13
  %71 = call i32 (ptr, ...) @printf(ptr noundef @.str.58, ptr noundef @.str.28)
  br label %72

72:                                               ; preds = %70, %68, %66, %64, %62, %60, %58, %56, %54, %52, %50, %48
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.37)
  br label %74

74:                                               ; preds = %72
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %7, align 4, !tbaa !9
  br label %9, !llvm.loop !17

77:                                               ; preds = %9
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.37)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

attributes #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 = { nocallback nofree nosync 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12, !7, i64 13, !13, i64 14}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 4}
!16 = !{!12, !7, i64 12}
!17 = distinct !{!17, !18}
!18 = !{!"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.Elf32_Sym = type { i32, i32, i32, i8, i8, i16 }

@.str.28 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.54 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.59 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.60 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.61 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.62 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.63 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.64 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.66 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.68 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.69 = external hidden unnamed_addr constant [26 x i8], align 1
@switch.table.print_symbol_table = private unnamed_addr constant [16 x ptr] [ptr @.str.59, ptr @.str.60, ptr @.str.61, ptr @.str.62, ptr @.str.63, ptr @.str.64, ptr @.str.28, ptr @.str.28, ptr @.str.28, ptr @.str.28, ptr @.str.65, ptr @.str.66, ptr @.str.67, ptr @.str.68, ptr @.str.28, ptr @.str.69], align 8

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @print_symbol_table(ptr nocapture noundef readonly %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.53)
  %5 = icmp sgt i32 %1, 0
  br i1 %5, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %3
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %6 = trunc nuw nsw i64 %indvars.iv to i32
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.54, i32 noundef %6)
  %8 = getelementptr inbounds %struct.Elf32_Sym, ptr %0, i64 %indvars.iv
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = zext i32 %9 to i64
  %11 = getelementptr inbounds i8, ptr %2, i64 %10
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.55, ptr noundef %11)
  %13 = getelementptr inbounds i8, ptr %8, i64 8
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.56, i32 noundef %14)
  %16 = getelementptr inbounds i8, ptr %8, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !12
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.57, i32 noundef %17)
  %19 = getelementptr inbounds i8, ptr %8, i64 12
  %20 = load i8, ptr %19, align 4, !tbaa !13
  %21 = and i8 %20, 15
  %22 = zext nneg i8 %21 to i64
  %switch.gep = getelementptr inbounds [16 x ptr], ptr @switch.table.print_symbol_table, i64 0, i64 %22
  %switch.load = load ptr, ptr %switch.gep, align 8
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.58, ptr noundef nonnull %switch.load)
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  %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 %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %3
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37)
  ret void
}

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

!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 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12, !8, i64 13, !10, i64 14}
!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 8}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !8, i64 12}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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