; LLVM IR from openssl/openssl :: test (ecstresstest)

; 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.16 = external hidden unnamed_addr constant [8 x i8], align 1
@num_repeats = external hidden global i64, align 8
@.str.17 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [21 x i8], align 1
@print_mode = external hidden global i32, align 4
@.str.19 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @setup_tests() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  %4 = call i32 @opt_intmax(ptr noundef @.str.16, ptr noundef @num_repeats)
  %5 = icmp ne i32 %4, 0
  br i1 %5, label %7, label %6

6:                                                ; preds = %0
  call void (ptr, i32, ptr, ...) @test_error(ptr noundef @.str.17, i32 noundef 132, ptr noundef @.str.18)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %27

7:                                                ; preds = %0
  br label %8

8:                                                ; preds = %25, %7
  %9 = call i32 @opt_next()
  store i32 %9, ptr %2, align 4, !tbaa !5
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %26

11:                                               ; preds = %8
  %12 = load i32, ptr %2, align 4, !tbaa !5
  switch i32 %12, label %23 [
    i32 1, label %13
    i32 500, label %22
    i32 501, label %22
    i32 502, label %22
    i32 503, label %22
    i32 504, label %22
    i32 505, label %22
    i32 -1, label %24
  ]

13:                                               ; preds = %11
  %14 = call ptr @opt_arg()
  %15 = call i32 @opt_intmax(ptr noundef %14, ptr noundef @num_repeats)
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %20

17:                                               ; preds = %13
  %18 = load i64, ptr @num_repeats, align 8, !tbaa !9
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %17, %13
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %27

21:                                               ; preds = %17
  store i32 1, ptr @print_mode, align 4, !tbaa !5
  br label %25

22:                                               ; preds = %11, %11, %11, %11, %11, %11
  br label %25

23:                                               ; preds = %11
  br label %24

24:                                               ; preds = %23, %11
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %27

25:                                               ; preds = %22, %21
  br label %8, !llvm.loop !11

26:                                               ; preds = %8
  call void @add_test(ptr noundef @.str.19, ptr noundef @test_curve)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %27

27:                                               ; preds = %26, %24, %20, %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %28 = load i32, ptr %1, align 4
  ret i32 %28
}

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

declare i32 @opt_intmax(ptr noundef, ptr noundef) #2

declare void @test_error(ptr noundef, i32 noundef, ptr noundef, ...) #2

declare i32 @opt_next() #2

declare ptr @opt_arg() #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @test_curve() #0

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

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 }

!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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@.str.16 = external hidden unnamed_addr constant [8 x i8], align 1
@num_repeats = external hidden global i64, align 8
@.str.17 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [21 x i8], align 1
@print_mode = external hidden local_unnamed_addr global i32, align 4
@.str.19 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @setup_tests() local_unnamed_addr #0 {
  %1 = tail call i32 @opt_intmax(ptr noundef nonnull @.str.16, ptr noundef nonnull @num_repeats) #2
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %2, label %.preheader

2:                                                ; preds = %0
  tail call void (ptr, i32, ptr, ...) @test_error(ptr noundef nonnull @.str.17, i32 noundef 132, ptr noundef nonnull @.str.18) #2
  br label %.loopexit

.preheader:                                       ; preds = %0, %.preheader.backedge
  %3 = tail call i32 @opt_next() #2
  switch i32 %3, label %.loopexit [
    i32 0, label %11
    i32 1, label %4
    i32 500, label %.preheader.backedge
    i32 501, label %.preheader.backedge
    i32 502, label %.preheader.backedge
    i32 503, label %.preheader.backedge
    i32 504, label %.preheader.backedge
    i32 505, label %.preheader.backedge
  ]

.preheader.backedge:                              ; preds = %.preheader, %.preheader, %.preheader, %.preheader, %.preheader, %.preheader, %10
  br label %.preheader, !llvm.loop !5

4:                                                ; preds = %.preheader
  %5 = tail call ptr @opt_arg() #2
  %6 = tail call i32 @opt_intmax(ptr noundef %5, ptr noundef nonnull @num_repeats) #2
  %7 = icmp eq i32 %6, 0
  %8 = load i64, ptr @num_repeats, align 8
  %9 = icmp slt i64 %8, 0
  %or.cond = select i1 %7, i1 true, i1 %9
  br i1 %or.cond, label %.loopexit, label %10

10:                                               ; preds = %4
  store i32 1, ptr @print_mode, align 4, !tbaa !7
  br label %.preheader.backedge

11:                                               ; preds = %.preheader
  tail call void @add_test(ptr noundef nonnull @.str.19, ptr noundef nonnull @test_curve) #2
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %4, %11, %2
  %.0 = phi i32 [ 1, %11 ], [ 0, %2 ], [ 0, %4 ], [ 0, %.preheader ]
  ret i32 %.0
}

declare i32 @opt_intmax(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @test_error(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

declare i32 @opt_next() local_unnamed_addr #1

declare ptr @opt_arg() local_unnamed_addr #1

declare void @add_test(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @test_curve() #0

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 = { "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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass