; LLVM IR from JessonYue/LeetCodeLearning :: Array/caiweixiong/c (elf)

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

; 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
define dso_local void @getSegmentFlagNameByFlags(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca [12 x i8], align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 1 %8, i8 0, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #4
  %9 = getelementptr inbounds [12 x i8], ptr %5, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 1 %9, i8 0, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = load i32, ptr %7, align 4, !tbaa !5
  %12 = or i32 %11, %10
  store i32 %12, ptr %7, align 4, !tbaa !5
  %13 = load i32, ptr %7, align 4, !tbaa !5
  %14 = and i32 %13, 1
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %21

16:                                               ; preds = %2
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %6, align 4, !tbaa !5
  %19 = sext i32 %17 to i64
  %20 = getelementptr inbounds [12 x i8], ptr %5, i64 0, i64 %19
  store i8 88, ptr %20, align 1, !tbaa !11
  br label %21

21:                                               ; preds = %16, %2
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = and i32 %22, 2
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %30

25:                                               ; preds = %21
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %6, align 4, !tbaa !5
  %28 = sext i32 %26 to i64
  %29 = getelementptr inbounds [12 x i8], ptr %5, i64 0, i64 %28
  store i8 87, ptr %29, align 1, !tbaa !11
  br label %30

30:                                               ; preds = %25, %21
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = and i32 %31, 4
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %39

34:                                               ; preds = %30
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %6, align 4, !tbaa !5
  %37 = sext i32 %35 to i64
  %38 = getelementptr inbounds [12 x i8], ptr %5, i64 0, i64 %37
  store i8 82, ptr %38, align 1, !tbaa !11
  br label %39

39:                                               ; preds = %34, %30
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = and i32 %40, 267386880
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %48

43:                                               ; preds = %39
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %6, align 4, !tbaa !5
  %46 = sext i32 %44 to i64
  %47 = getelementptr inbounds [12 x i8], ptr %5, i64 0, i64 %46
  store i8 83, ptr %47, align 1, !tbaa !11
  br label %48

48:                                               ; preds = %43, %39
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = and i32 %49, -268435456
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %57

52:                                               ; preds = %48
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %6, align 4, !tbaa !5
  %55 = sext i32 %53 to i64
  %56 = getelementptr inbounds [12 x i8], ptr %5, i64 0, i64 %55
  store i8 67, ptr %56, align 1, !tbaa !11
  br label %57

57:                                               ; preds = %52, %48
  %58 = load ptr, ptr %4, align 8, !tbaa !9
  %59 = getelementptr inbounds [12 x i8], ptr %5, i64 0, i64 0
  %60 = call ptr @strcpy(ptr noundef %58, ptr noundef %59) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #4
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!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"

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @getSegmentFlagNameByFlags(i32 noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca [12 x i8], align 1
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(12) %1, i8 0, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(12) %3, i8 0, i64 12, i1 false)
  %4 = and i32 %0, 1
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %6, label %5

5:                                                ; preds = %2
  store i8 88, ptr %3, align 1, !tbaa !5
  br label %6

6:                                                ; preds = %5, %2
  %.0 = phi i32 [ 1, %5 ], [ 0, %2 ]
  %7 = and i32 %0, 2
  %.not13 = icmp eq i32 %7, 0
  br i1 %.not13, label %12, label %8

8:                                                ; preds = %6
  %9 = add nuw nsw i32 %.0, 1
  %10 = zext nneg i32 %.0 to i64
  %11 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 %10
  store i8 87, ptr %11, align 1, !tbaa !5
  br label %12

12:                                               ; preds = %8, %6
  %.1 = phi i32 [ %9, %8 ], [ %.0, %6 ]
  %13 = and i32 %0, 4
  %.not14 = icmp eq i32 %13, 0
  br i1 %.not14, label %18, label %14

14:                                               ; preds = %12
  %15 = add nuw nsw i32 %.1, 1
  %16 = zext nneg i32 %.1 to i64
  %17 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 %16
  store i8 82, ptr %17, align 1, !tbaa !5
  br label %18

18:                                               ; preds = %14, %12
  %.2 = phi i32 [ %15, %14 ], [ %.1, %12 ]
  %19 = and i32 %0, 267386880
  %.not15 = icmp eq i32 %19, 0
  br i1 %.not15, label %24, label %20

20:                                               ; preds = %18
  %21 = add nuw nsw i32 %.2, 1
  %22 = zext nneg i32 %.2 to i64
  %23 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 %22
  store i8 83, ptr %23, align 1, !tbaa !5
  br label %24

24:                                               ; preds = %20, %18
  %.3 = phi i32 [ %21, %20 ], [ %.2, %18 ]
  %.not16 = icmp ult i32 %0, 268435456
  br i1 %.not16, label %28, label %25

25:                                               ; preds = %24
  %26 = zext nneg i32 %.3 to i64
  %27 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 %26
  store i8 67, ptr %27, align 1, !tbaa !5
  br label %28

28:                                               ; preds = %25, %24
  %29 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %3) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #4
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #3

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


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