; LLVM IR from facebook/redex :: libredex/Warning.ll (Z21print_warning_summaryv)

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

@g_warning_level = external dso_local global i32, align 4
@s_warning_text = external dso_local global [6 x ptr], align 16
@s_warning_counts = external dso_local global [6 x i64], align 16
@stderr = external global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [43 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: nounwind
declare i32 @fprintf(ptr noundef, 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: mustprogress nounwind uwtable
define dso_local void @_Z21print_warning_summaryv() #2 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = load i32, ptr @g_warning_level, align 4, !tbaa !5
  %4 = icmp ne i32 %3, 1
  br i1 %4, label %5, label %6

5:                                                ; preds = %0
  br label %28

6:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  store i64 0, ptr %1, align 8, !tbaa !9
  br label %7

7:                                                ; preds = %25, %6
  %8 = load i64, ptr %1, align 8, !tbaa !9
  %9 = icmp ult i64 %8, 6
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  br label %28

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %12 = load i64, ptr %1, align 8, !tbaa !9
  %13 = getelementptr inbounds [6 x i64], ptr @s_warning_counts, i64 0, i64 %12
  %14 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %14, ptr %2, align 8, !tbaa !9
  %15 = load i64, ptr %2, align 8, !tbaa !9
  %16 = icmp ugt i64 %15, 0
  br i1 %16, label %17, label %24

17:                                               ; preds = %11
  %18 = load ptr, ptr @stderr, align 8, !tbaa !11
  %19 = load i64, ptr %1, align 8, !tbaa !9
  %20 = getelementptr inbounds [6 x ptr], ptr @s_warning_text, i64 0, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = load i64, ptr %2, align 8, !tbaa !9
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.7, ptr noundef %21, i64 noundef %22) #3
  br label %24

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

25:                                               ; preds = %24
  %26 = load i64, ptr %1, align 8, !tbaa !9
  %27 = add i64 %26, 1
  store i64 %27, ptr %1, align 8, !tbaa !9
  br label %7, !llvm.loop !13

28:                                               ; preds = %10, %5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { mustprogress 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 = !{!"_ZTS15OptWarningLevel", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@g_warning_level = external dso_local local_unnamed_addr global i32, align 4
@s_warning_text = external dso_local local_unnamed_addr global [6 x ptr], align 16
@s_warning_counts = external dso_local local_unnamed_addr global [6 x i64], align 16
@stderr = external local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [43 x i8], align 1

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

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_Z21print_warning_summaryv() local_unnamed_addr #1 {
  %1 = load i32, ptr @g_warning_level, align 4, !tbaa !5
  %.not = icmp eq i32 %1, 1
  br i1 %.not, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %0
  %2 = load i64, ptr @s_warning_counts, align 16, !tbaa !9
  %.not7 = icmp eq i64 %2, 0
  br i1 %.not7, label %.preheader.1, label %3

3:                                                ; preds = %.preheader.preheader
  %4 = load ptr, ptr @stderr, align 8, !tbaa !11
  %5 = load ptr, ptr @s_warning_text, align 16, !tbaa !11
  %6 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef nonnull @.str.7, ptr noundef %5, i64 noundef %2) #2
  br label %.preheader.1

.preheader.1:                                     ; preds = %3, %.preheader.preheader
  %7 = load i64, ptr getelementptr inbounds (i8, ptr @s_warning_counts, i64 8), align 8, !tbaa !9
  %.not7.1 = icmp eq i64 %7, 0
  br i1 %.not7.1, label %.preheader.2, label %8

8:                                                ; preds = %.preheader.1
  %9 = load ptr, ptr @stderr, align 8, !tbaa !11
  %10 = load ptr, ptr getelementptr inbounds (i8, ptr @s_warning_text, i64 8), align 8, !tbaa !11
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.7, ptr noundef %10, i64 noundef %7) #2
  br label %.preheader.2

.preheader.2:                                     ; preds = %8, %.preheader.1
  %12 = load i64, ptr getelementptr inbounds (i8, ptr @s_warning_counts, i64 16), align 16, !tbaa !9
  %.not7.2 = icmp eq i64 %12, 0
  br i1 %.not7.2, label %.preheader.3, label %13

13:                                               ; preds = %.preheader.2
  %14 = load ptr, ptr @stderr, align 8, !tbaa !11
  %15 = load ptr, ptr getelementptr inbounds (i8, ptr @s_warning_text, i64 16), align 16, !tbaa !11
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.7, ptr noundef %15, i64 noundef %12) #2
  br label %.preheader.3

.preheader.3:                                     ; preds = %13, %.preheader.2
  %17 = load i64, ptr getelementptr inbounds (i8, ptr @s_warning_counts, i64 24), align 8, !tbaa !9
  %.not7.3 = icmp eq i64 %17, 0
  br i1 %.not7.3, label %.preheader.4, label %18

18:                                               ; preds = %.preheader.3
  %19 = load ptr, ptr @stderr, align 8, !tbaa !11
  %20 = load ptr, ptr getelementptr inbounds (i8, ptr @s_warning_text, i64 24), align 8, !tbaa !11
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.7, ptr noundef %20, i64 noundef %17) #2
  br label %.preheader.4

.preheader.4:                                     ; preds = %18, %.preheader.3
  %22 = load i64, ptr getelementptr inbounds (i8, ptr @s_warning_counts, i64 32), align 16, !tbaa !9
  %.not7.4 = icmp eq i64 %22, 0
  br i1 %.not7.4, label %.preheader.5, label %23

23:                                               ; preds = %.preheader.4
  %24 = load ptr, ptr @stderr, align 8, !tbaa !11
  %25 = load ptr, ptr getelementptr inbounds (i8, ptr @s_warning_text, i64 32), align 16, !tbaa !11
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef nonnull @.str.7, ptr noundef %25, i64 noundef %22) #2
  br label %.preheader.5

.preheader.5:                                     ; preds = %23, %.preheader.4
  %27 = load i64, ptr getelementptr inbounds (i8, ptr @s_warning_counts, i64 40), align 8, !tbaa !9
  %.not7.5 = icmp eq i64 %27, 0
  br i1 %.not7.5, label %.loopexit, label %28

28:                                               ; preds = %.preheader.5
  %29 = load ptr, ptr @stderr, align 8, !tbaa !11
  %30 = load ptr, ptr getelementptr inbounds (i8, ptr @s_warning_text, i64 40), align 8, !tbaa !11
  %31 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.7, ptr noundef %30, i64 noundef %27) #2
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.5, %28, %0
  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 = { mustprogress 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 #2 = { cold 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 = !{!"_ZTS15OptWarningLevel", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass