; LLVM IR from lolosssss/leetcode :: c (25_reverse_nodes_in_k_group)

; 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.2 = external hidden unnamed_addr constant [18 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 ptr @reverseKGroup(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @createList(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @printList(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca [20 x i32], align 16
  %3 = alloca [18 x ptr], align 16
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 80, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 144, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %18, %0
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 20
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %21

12:                                               ; preds = %8
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = add nsw i32 %13, 1
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [20 x i32], ptr %2, i64 0, i64 %16
  store i32 %14, ptr %17, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %12
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %4, align 4, !tbaa !5
  br label %8, !llvm.loop !9

21:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %32, %21
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = icmp slt i32 %23, 18
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %35

26:                                               ; preds = %22
  %27 = getelementptr inbounds [20 x i32], ptr %2, i64 0, i64 0
  %28 = call ptr @createList(ptr noundef %27, i32 noundef 20)
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [18 x ptr], ptr %3, i64 0, i64 %30
  store ptr %28, ptr %31, align 8, !tbaa !11
  br label %32

32:                                               ; preds = %26
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %5, align 4, !tbaa !5
  br label %22, !llvm.loop !13

35:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %51, %35
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = icmp slt i32 %37, 18
  br i1 %38, label %40, label %39

39:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %54

40:                                               ; preds = %36
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [18 x ptr], ptr %3, i64 0, i64 %42
  %44 = load ptr, ptr %43, align 8, !tbaa !11
  %45 = load i32, ptr %6, align 4, !tbaa !5
  %46 = add nsw i32 %45, 2
  %47 = call ptr @reverseKGroup(ptr noundef %44, i32 noundef %46)
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [18 x ptr], ptr %3, i64 0, i64 %49
  store ptr %47, ptr %50, align 8, !tbaa !11
  br label %51

51:                                               ; preds = %40
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %6, align 4, !tbaa !5
  br label %36, !llvm.loop !14

54:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %67, %54
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = icmp slt i32 %56, 18
  br i1 %57, label %59, label %58

58:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %70

59:                                               ; preds = %55
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %61)
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [18 x ptr], ptr %3, i64 0, i64 %64
  %66 = load ptr, ptr %65, align 8, !tbaa !11
  call void @printList(ptr noundef %66)
  br label %67

67:                                               ; preds = %59
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %7, align 4, !tbaa !5
  br label %55, !llvm.loop !15

70:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 144, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 80, ptr %2) #3
  ret i32 0
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


; 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.2 = external hidden unnamed_addr constant [18 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: mustprogress 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 ptr @reverseKGroup(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @createList(ptr noundef, i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
.preheader20.preheader:
  %0 = alloca [20 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %0) #3
  store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, ptr %0, align 16, !tbaa !5
  %1 = getelementptr inbounds i8, ptr %0, i64 16
  store <4 x i32> <i32 5, i32 6, i32 7, i32 8>, ptr %1, align 16, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  store <4 x i32> <i32 9, i32 10, i32 11, i32 12>, ptr %2, align 16, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  store <4 x i32> <i32 13, i32 14, i32 15, i32 16>, ptr %3, align 16, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 64
  store <4 x i32> <i32 17, i32 18, i32 19, i32 20>, ptr %4, align 16, !tbaa !5
  %5 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %6 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %7 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %8 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %9 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %10 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %11 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %12 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %13 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %14 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %15 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %16 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %17 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %18 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %19 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %20 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %21 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %22 = call ptr @createList(ptr noundef nonnull %0, i32 noundef 20)
  %23 = call ptr @reverseKGroup(ptr noundef %5, i32 noundef 2)
  %24 = call ptr @reverseKGroup(ptr noundef %6, i32 noundef 3)
  %25 = call ptr @reverseKGroup(ptr noundef %7, i32 noundef 4)
  %26 = call ptr @reverseKGroup(ptr noundef %8, i32 noundef 5)
  %27 = call ptr @reverseKGroup(ptr noundef %9, i32 noundef 6)
  %28 = call ptr @reverseKGroup(ptr noundef %10, i32 noundef 7)
  %29 = call ptr @reverseKGroup(ptr noundef %11, i32 noundef 8)
  %30 = call ptr @reverseKGroup(ptr noundef %12, i32 noundef 9)
  %31 = call ptr @reverseKGroup(ptr noundef %13, i32 noundef 10)
  %32 = call ptr @reverseKGroup(ptr noundef %14, i32 noundef 11)
  %33 = call ptr @reverseKGroup(ptr noundef %15, i32 noundef 12)
  %34 = call ptr @reverseKGroup(ptr noundef %16, i32 noundef 13)
  %35 = call ptr @reverseKGroup(ptr noundef %17, i32 noundef 14)
  %36 = call ptr @reverseKGroup(ptr noundef %18, i32 noundef 15)
  %37 = call ptr @reverseKGroup(ptr noundef %19, i32 noundef 16)
  %38 = call ptr @reverseKGroup(ptr noundef %20, i32 noundef 17)
  %39 = call ptr @reverseKGroup(ptr noundef %21, i32 noundef 18)
  %40 = call ptr @reverseKGroup(ptr noundef %22, i32 noundef 19)
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 1)
  call void @printList(ptr noundef %23)
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 2)
  call void @printList(ptr noundef %24)
  %43 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 3)
  call void @printList(ptr noundef %25)
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 4)
  call void @printList(ptr noundef %26)
  %45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 5)
  call void @printList(ptr noundef %27)
  %46 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 6)
  call void @printList(ptr noundef %28)
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 7)
  call void @printList(ptr noundef %29)
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 8)
  call void @printList(ptr noundef %30)
  %49 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 9)
  call void @printList(ptr noundef %31)
  %50 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 10)
  call void @printList(ptr noundef %32)
  %51 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 11)
  call void @printList(ptr noundef %33)
  %52 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 12)
  call void @printList(ptr noundef %34)
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 13)
  call void @printList(ptr noundef %35)
  %54 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 14)
  call void @printList(ptr noundef %36)
  %55 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 15)
  call void @printList(ptr noundef %37)
  %56 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 16)
  call void @printList(ptr noundef %38)
  %57 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 17)
  call void @printList(ptr noundef %39)
  %58 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 18)
  call void @printList(ptr noundef %40)
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %0) #3
  ret i32 0
}

attributes #0 = { mustprogress 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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass