; LLVM IR from openappsec/openappsec :: external/picojson/picotest (picotest)

; 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.test_t = type { i32, i32 }

@cur_tests = external dso_local global ptr, align 8
@test_level = external hidden global i32, align 4
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @note(ptr noundef, ...) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @_ok(i32 noundef, ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @done_testing() #0

; Function Attrs: nounwind uwtable
define dso_local void @subtest(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.test_t, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.memset.p0.i64(ptr align 4 %5, i8 0, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %7 = load ptr, ptr @cur_tests, align 8, !tbaa !5
  store ptr %7, ptr %6, align 8, !tbaa !5
  store ptr %5, ptr @cur_tests, align 8, !tbaa !5
  %8 = load i32, ptr @test_level, align 4, !tbaa !9
  %9 = add nsw i32 %8, 1
  store i32 %9, ptr @test_level, align 4, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, ...) @note(ptr noundef @.str.6, ptr noundef %10)
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  call void %11()
  %12 = call i32 @done_testing()
  %13 = load i32, ptr @test_level, align 4, !tbaa !9
  %14 = add nsw i32 %13, -1
  store i32 %14, ptr @test_level, align 4, !tbaa !9
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %15, ptr @cur_tests, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.test_t, ptr %5, i32 0, i32 1
  %17 = load i32, ptr %16, align 4, !tbaa !11
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %22

19:                                               ; preds = %2
  %20 = load ptr, ptr @cur_tests, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.test_t, ptr %20, i32 0, i32 1
  store i32 1, ptr %21, align 4, !tbaa !11
  br label %22

22:                                               ; preds = %19, %2
  %23 = getelementptr inbounds %struct.test_t, ptr %5, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = icmp ne i32 %24, 0
  %26 = xor i1 %25, true
  %27 = zext i1 %26 to i32
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  call void (i32, ptr, ...) @_ok(i32 noundef %27, ptr noundef @.str.7, ptr noundef %28)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  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

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


; 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.test_t = type { i32, i32 }

@cur_tests = external dso_local local_unnamed_addr global ptr, align 8
@test_level = external hidden local_unnamed_addr global i32, align 4
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @note(ptr noundef, ...) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @_ok(i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @done_testing() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @subtest(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.test_t, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #2
  store i64 0, ptr %3, align 8
  %4 = load ptr, ptr @cur_tests, align 8, !tbaa !5
  store ptr %3, ptr @cur_tests, align 8, !tbaa !5
  %5 = load i32, ptr @test_level, align 4, !tbaa !9
  %6 = add nsw i32 %5, 1
  store i32 %6, ptr @test_level, align 4, !tbaa !9
  call void (ptr, ...) @note(ptr noundef nonnull @.str.6, ptr noundef %0)
  call void %1() #2
  %7 = call i32 @done_testing()
  %8 = load i32, ptr @test_level, align 4, !tbaa !9
  %9 = add nsw i32 %8, -1
  store i32 %9, ptr @test_level, align 4, !tbaa !9
  store ptr %4, ptr @cur_tests, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %3, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %14, label %12

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 1, ptr %13, align 4, !tbaa !11
  br label %14

14:                                               ; preds = %12, %2
  %15 = zext i1 %.not to i32
  call void (i32, ptr, ...) @_ok(i32 noundef %15, ptr noundef nonnull @.str.7, ptr noundef %0)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #2
  ret void
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass