; LLVM IR from pmwkaa/monotone :: test (test)

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

%struct.TestSuite = type { ptr, ptr, ptr, ptr, i32, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, i32, %struct.List, ptr, ptr, ptr, ptr, ptr, i32, %struct.List, %struct.List }
%struct.List = type { ptr, ptr }

@suite = external dso_local global %struct.TestSuite, align 8
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@optarg = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [58 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @test_suite_init(ptr noundef @suite)
  store ptr @.str, ptr getelementptr inbounds (%struct.TestSuite, ptr @suite, i32 0, i32 16), align 8, !tbaa !11
  store ptr @.str.1, ptr getelementptr inbounds (%struct.TestSuite, ptr @suite, i32 0, i32 17), align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  br label %9

9:                                                ; preds = %29, %2
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !9
  %12 = call i32 @getopt(i32 noundef %10, ptr noundef %11, ptr noundef @.str.2) #4
  store i32 %12, ptr %6, align 4, !tbaa !5
  %13 = icmp ne i32 %12, -1
  br i1 %13, label %14, label %30

14:                                               ; preds = %9
  %15 = load i32, ptr %6, align 4, !tbaa !5
  switch i32 %15, label %24 [
    i32 111, label %16
    i32 102, label %18
    i32 116, label %19
    i32 103, label %21
    i32 104, label %23
  ]

16:                                               ; preds = %14
  %17 = load ptr, ptr @optarg, align 8, !tbaa !9
  store ptr %17, ptr getelementptr inbounds (%struct.TestSuite, ptr @suite, i32 0, i32 16), align 8, !tbaa !11
  br label %29

18:                                               ; preds = %14
  store i32 1, ptr getelementptr inbounds (%struct.TestSuite, ptr @suite, i32 0, i32 20), align 8, !tbaa !15
  br label %29

19:                                               ; preds = %14
  %20 = load ptr, ptr @optarg, align 8, !tbaa !9
  store ptr %20, ptr getelementptr inbounds (%struct.TestSuite, ptr @suite, i32 0, i32 18), align 8, !tbaa !16
  br label %29

21:                                               ; preds = %14
  %22 = load ptr, ptr @optarg, align 8, !tbaa !9
  store ptr %22, ptr getelementptr inbounds (%struct.TestSuite, ptr @suite, i32 0, i32 19), align 8, !tbaa !17
  br label %29

23:                                               ; preds = %14
  br label %24

24:                                               ; preds = %23, %14
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = getelementptr inbounds ptr, ptr %25, i64 0
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, ptr noundef %27)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %37

29:                                               ; preds = %21, %19, %18, %16
  br label %9, !llvm.loop !18

30:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %31 = call i32 @test_suite_run(ptr noundef @suite)
  store i32 %31, ptr %8, align 4, !tbaa !5
  %32 = load i32, ptr %8, align 4, !tbaa !5
  %33 = icmp eq i32 %32, -1
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %36

35:                                               ; preds = %30
  call void @test_suite_cleanup(ptr noundef @suite)
  call void @test_suite_free(ptr noundef @suite)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %36

36:                                               ; preds = %35, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %37

37:                                               ; preds = %36, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %38 = load i32, ptr %3, align 4
  ret i32 %38
}

declare void @test_suite_init(ptr noundef) #1

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

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

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

declare i32 @test_suite_run(ptr noundef) #1

declare void @test_suite_cleanup(ptr noundef) #1

declare void @test_suite_free(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!12, !10, i64 128}
!12 = !{!"TestSuite", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !6, i64 32, !10, i64 40, !10, i64 48, !6, i64 56, !6, i64 60, !6, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !6, i64 96, !13, i64 104, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !6, i64 160, !13, i64 168, !13, i64 184}
!13 = !{!"List", !10, i64 0, !10, i64 8}
!14 = !{!12, !10, i64 136}
!15 = !{!12, !6, i64 160}
!16 = !{!12, !10, i64 144}
!17 = !{!12, !10, i64 152}
!18 = distinct !{!18, !19}
!19 = !{!"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"

%struct.TestSuite = type { ptr, ptr, ptr, ptr, i32, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, i32, %struct.List, ptr, ptr, ptr, ptr, ptr, i32, %struct.List, %struct.List }
%struct.List = type { ptr, ptr }

@suite = external dso_local global %struct.TestSuite, align 8
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@optarg = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [58 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  tail call void @test_suite_init(ptr noundef nonnull @suite) #4
  store ptr @.str, ptr getelementptr inbounds (i8, ptr @suite, i64 128), align 8, !tbaa !5
  store ptr @.str.1, ptr getelementptr inbounds (i8, ptr @suite, i64 136), align 8, !tbaa !12
  br label %3

3:                                                ; preds = %.backedge, %2
  %4 = tail call i32 @getopt(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str.2) #4
  switch i32 %4, label %12 [
    i32 -1, label %15
    i32 111, label %5
    i32 102, label %7
    i32 116, label %8
    i32 103, label %10
  ]

5:                                                ; preds = %3
  %6 = load ptr, ptr @optarg, align 8, !tbaa !13
  store ptr %6, ptr getelementptr inbounds (i8, ptr @suite, i64 128), align 8, !tbaa !5
  br label %.backedge

7:                                                ; preds = %3
  store i32 1, ptr getelementptr inbounds (i8, ptr @suite, i64 160), align 8, !tbaa !14
  br label %.backedge

8:                                                ; preds = %3
  %9 = load ptr, ptr @optarg, align 8, !tbaa !13
  store ptr %9, ptr getelementptr inbounds (i8, ptr @suite, i64 144), align 8, !tbaa !15
  br label %.backedge

10:                                               ; preds = %3
  %11 = load ptr, ptr @optarg, align 8, !tbaa !13
  store ptr %11, ptr getelementptr inbounds (i8, ptr @suite, i64 152), align 8, !tbaa !16
  br label %.backedge

.backedge:                                        ; preds = %10, %8, %7, %5
  br label %3, !llvm.loop !17

12:                                               ; preds = %3
  %13 = load ptr, ptr %1, align 8, !tbaa !13
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, ptr noundef %13)
  br label %19

15:                                               ; preds = %3
  %16 = tail call i32 @test_suite_run(ptr noundef nonnull @suite) #4
  %17 = icmp eq i32 %16, -1
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  tail call void @test_suite_cleanup(ptr noundef nonnull @suite) #4
  tail call void @test_suite_free(ptr noundef nonnull @suite) #4
  br label %19

19:                                               ; preds = %18, %15, %12
  %.1 = phi i32 [ 0, %12 ], [ 0, %18 ], [ -1, %15 ]
  ret i32 %.1
}

declare void @test_suite_init(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @getopt(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare i32 @test_suite_run(ptr noundef) local_unnamed_addr #1

declare void @test_suite_cleanup(ptr noundef) local_unnamed_addr #1

declare void @test_suite_free(ptr noundef) local_unnamed_addr #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 = { "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 "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, !7, i64 128}
!6 = !{!"TestSuite", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !10, i64 96, !11, i64 104, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !10, i64 160, !11, i64 168, !11, i64 184}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"List", !7, i64 0, !7, i64 8}
!12 = !{!6, !7, i64 136}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !10, i64 160}
!15 = !{!6, !7, i64 144}
!16 = !{!6, !7, i64 152}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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