; LLVM IR from JessonYue/LeetCodeLearning :: Array/caiweixiong/temp (main)

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

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca [64 x i8], align 16
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %10 = call ptr (...) @newArray()
  store ptr %10, ptr %2, align 8, !tbaa !5
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = call ptr @newString(ptr noundef @.str)
  %13 = call ptr @newInteger(i32 noundef 43)
  %14 = call ptr @newPerson(ptr noundef %12, ptr noundef %13)
  call void @addElement(ptr noundef %11, ptr noundef %14)
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = call ptr @newString(ptr noundef @.str.1)
  %17 = call ptr @newInteger(i32 noundef 21)
  %18 = call ptr @newPerson(ptr noundef %16, ptr noundef %17)
  call void @addElement(ptr noundef %15, ptr noundef %18)
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = call ptr @newString(ptr noundef @.str.2)
  %21 = call ptr @newInteger(i32 noundef 90)
  %22 = call ptr @newPerson(ptr noundef %20, ptr noundef %21)
  call void @addElement(ptr noundef %19, ptr noundef %22)
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = call ptr @newString(ptr noundef @.str.3)
  %25 = call ptr @newInteger(i32 noundef 77)
  %26 = call ptr @newPerson(ptr noundef %24, ptr noundef %25)
  call void @addElement(ptr noundef %23, ptr noundef %26)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store ptr @printPerson, ptr %3, align 8, !tbaa !5
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  call void @printArray(ptr noundef %27, ptr noundef %28)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store ptr @.str.4, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store ptr @.str.5, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store ptr null, ptr %7, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = call noalias ptr @fopen(ptr noundef %29, ptr noundef @.str.6)
  store ptr %30, ptr %6, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %74

33:                                               ; preds = %0
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  call void @writeMessageToFile(ptr noundef %34, ptr noundef %35)
  store ptr @releasePerson, ptr %3, align 8, !tbaa !5
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  call void @removeAll(ptr noundef %36, ptr noundef %37)
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = call noalias ptr @fopen(ptr noundef %38, ptr noundef @.str.6)
  store ptr %39, ptr %7, align 8, !tbaa !5
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %69

42:                                               ; preds = %33
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  call void @rewind(ptr noundef %43)
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  call void @rewind(ptr noundef %44)
  call void @llvm.lifetime.start.p0(i64 64, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %54, %42
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  %49 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %47, ptr noundef @.str.7, ptr noundef %9, ptr noundef %48)
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = call i32 @feof(ptr noundef %50) #4
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %46
  br label %61

54:                                               ; preds = %46
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  %57 = call ptr @newString(ptr noundef %56)
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = call ptr @newInteger(i32 noundef %58)
  %60 = call ptr @newPerson(ptr noundef %57, ptr noundef %59)
  call void @addElement(ptr noundef %55, ptr noundef %60)
  br label %45

61:                                               ; preds = %53
  store ptr @printPerson, ptr %3, align 8, !tbaa !5
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  call void @printArray(ptr noundef %62, ptr noundef %63)
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  call void @sortNameByArray(ptr noundef %64)
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  call void @writeMessageToFile(ptr noundef %65, ptr noundef %66)
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = call i32 @fclose(ptr noundef %67)
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %8) #4
  br label %71

69:                                               ; preds = %33
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %71

71:                                               ; preds = %69, %61
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = call i32 @fclose(ptr noundef %72)
  store ptr null, ptr %6, align 8, !tbaa !5
  br label %76

74:                                               ; preds = %0
  %75 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %76

76:                                               ; preds = %74, %71
  store ptr @releasePerson, ptr %3, align 8, !tbaa !5
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  call void @removeAll(ptr noundef %77, ptr noundef %78)
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  call void @destroyArray(ptr noundef %79)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  ret i32 0
}

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

declare ptr @newArray(...) #2

declare void @addElement(ptr noundef, ptr noundef) #2

declare ptr @newPerson(ptr noundef, ptr noundef) #2

declare ptr @newString(ptr noundef) #2

declare ptr @newInteger(i32 noundef) #2

declare void @printPerson(ptr noundef) #2

declare void @printArray(ptr noundef, ptr noundef) #2

declare noalias ptr @fopen(ptr noundef, ptr noundef) #2

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

declare void @releasePerson(ptr noundef) #2

declare void @removeAll(ptr noundef, ptr noundef) #2

declare void @rewind(ptr noundef) #2

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

; Function Attrs: nounwind
declare i32 @feof(ptr noundef) #3

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

declare i32 @fclose(ptr noundef) #2

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

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

declare void @destroyArray(ptr noundef) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 #4 = { 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}


; 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 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [64 x i8], align 16
  %2 = alloca i32, align 4
  %3 = tail call ptr (...) @newArray() #4
  %4 = tail call ptr @newString(ptr noundef nonnull @.str) #4
  %5 = tail call ptr @newInteger(i32 noundef 43) #4
  %6 = tail call ptr @newPerson(ptr noundef %4, ptr noundef %5) #4
  tail call void @addElement(ptr noundef %3, ptr noundef %6) #4
  %7 = tail call ptr @newString(ptr noundef nonnull @.str.1) #4
  %8 = tail call ptr @newInteger(i32 noundef 21) #4
  %9 = tail call ptr @newPerson(ptr noundef %7, ptr noundef %8) #4
  tail call void @addElement(ptr noundef %3, ptr noundef %9) #4
  %10 = tail call ptr @newString(ptr noundef nonnull @.str.2) #4
  %11 = tail call ptr @newInteger(i32 noundef 90) #4
  %12 = tail call ptr @newPerson(ptr noundef %10, ptr noundef %11) #4
  tail call void @addElement(ptr noundef %3, ptr noundef %12) #4
  %13 = tail call ptr @newString(ptr noundef nonnull @.str.3) #4
  %14 = tail call ptr @newInteger(i32 noundef 77) #4
  %15 = tail call ptr @newPerson(ptr noundef %13, ptr noundef %14) #4
  tail call void @addElement(ptr noundef %3, ptr noundef %15) #4
  tail call void @printArray(ptr noundef %3, ptr noundef nonnull @printPerson) #4
  %16 = tail call noalias ptr @fopen(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.6)
  %.not = icmp eq ptr %16, null
  br i1 %.not, label %33, label %17

17:                                               ; preds = %0
  tail call void @writeMessageToFile(ptr noundef nonnull %16, ptr noundef %3)
  tail call void @removeAll(ptr noundef %3, ptr noundef nonnull @releasePerson) #4
  %18 = tail call noalias ptr @fopen(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6)
  %.not30 = icmp eq ptr %18, null
  br i1 %.not30, label %29, label %19

19:                                               ; preds = %17
  tail call void @rewind(ptr noundef nonnull %16)
  tail call void @rewind(ptr noundef nonnull %18)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  %20 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %16, ptr noundef nonnull @.str.7, ptr noundef nonnull %2, ptr noundef nonnull %1) #4
  %21 = call i32 @feof(ptr noundef nonnull %16) #4
  %.not3132 = icmp eq i32 %21, 0
  br i1 %.not3132, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %19, %.lr.ph
  %22 = call ptr @newString(ptr noundef nonnull %1) #4
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = call ptr @newInteger(i32 noundef %23) #4
  %25 = call ptr @newPerson(ptr noundef %22, ptr noundef %24) #4
  call void @addElement(ptr noundef %3, ptr noundef %25) #4
  %26 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %16, ptr noundef nonnull @.str.7, ptr noundef nonnull %2, ptr noundef nonnull %1) #4
  %27 = call i32 @feof(ptr noundef nonnull %16) #4
  %.not31 = icmp eq i32 %27, 0
  br i1 %.not31, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %19
  call void @printArray(ptr noundef %3, ptr noundef nonnull @printPerson) #4
  call void @sortNameByArray(ptr noundef %3)
  call void @writeMessageToFile(ptr noundef nonnull %18, ptr noundef %3)
  %28 = call i32 @fclose(ptr noundef nonnull %18)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %1) #4
  br label %31

29:                                               ; preds = %17
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  br label %31

31:                                               ; preds = %29, %._crit_edge
  %32 = call i32 @fclose(ptr noundef nonnull %16)
  br label %35

33:                                               ; preds = %0
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  br label %35

35:                                               ; preds = %33, %31
  call void @removeAll(ptr noundef %3, ptr noundef nonnull @releasePerson) #4
  call void @destroyArray(ptr noundef %3) #4
  ret i32 0
}

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

declare ptr @newArray(...) local_unnamed_addr #2

declare void @addElement(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @newPerson(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @newString(ptr noundef) local_unnamed_addr #2

declare ptr @newInteger(i32 noundef) local_unnamed_addr #2

declare void @printPerson(ptr noundef) #2

declare void @printArray(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #3

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

declare void @releasePerson(ptr noundef) #2

declare void @removeAll(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare void @rewind(ptr nocapture noundef) local_unnamed_addr #3

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @feof(ptr nocapture noundef) local_unnamed_addr #3

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #3

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

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

declare void @destroyArray(ptr noundef) local_unnamed_addr #2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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