; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/src (test_threads)

; 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 [3 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @testThread(ptr noundef) #0

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

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

; 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
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 i64, align 8
  %7 = alloca [5 x i64], align 16
  %8 = alloca [5 x i32], align 16
  %9 = alloca ptr, align 8
  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 @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 40, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 20, ptr %8) #4
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %10

10:                                               ; preds = %25, %2
  %11 = load i64, ptr %6, align 8, !tbaa !11
  %12 = icmp ult i64 %11, 5
  br i1 %12, label %13, label %28

13:                                               ; preds = %10
  %14 = load i64, ptr %6, align 8, !tbaa !11
  %15 = trunc i64 %14 to i32
  %16 = load i64, ptr %6, align 8, !tbaa !11
  %17 = getelementptr inbounds [5 x i32], ptr %8, i64 0, i64 %16
  store i32 %15, ptr %17, align 4, !tbaa !5
  %18 = getelementptr inbounds [5 x i64], ptr %7, i64 0, i64 0
  %19 = load i64, ptr %6, align 8, !tbaa !11
  %20 = getelementptr inbounds i64, ptr %18, i64 %19
  %21 = getelementptr inbounds [5 x i32], ptr %8, i64 0, i64 0
  %22 = load i64, ptr %6, align 8, !tbaa !11
  %23 = getelementptr inbounds i32, ptr %21, i64 %22
  %24 = call i32 @pthread_create(ptr noundef %20, ptr noundef null, ptr noundef @testThread, ptr noundef %23) #4
  br label %25

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

28:                                               ; preds = %10
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %29

29:                                               ; preds = %37, %28
  %30 = load i64, ptr %6, align 8, !tbaa !11
  %31 = icmp ult i64 %30, 5
  br i1 %31, label %32, label %40

32:                                               ; preds = %29
  %33 = load i64, ptr %6, align 8, !tbaa !11
  %34 = getelementptr inbounds [5 x i64], ptr %7, i64 0, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !15
  %36 = call i32 @pthread_join(i64 noundef %35, ptr noundef null)
  br label %37

37:                                               ; preds = %32
  %38 = load i64, ptr %6, align 8, !tbaa !11
  %39 = add i64 %38, 1
  store i64 %39, ptr %6, align 8, !tbaa !11
  br label %29, !llvm.loop !17

40:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %41 = call ptr @vl_configuration_to_string_copy()
  store ptr %41, ptr %9, align 8, !tbaa !9
  %42 = load ptr, ptr %9, align 8, !tbaa !9
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %42)
  %44 = load ptr, ptr %9, align 8, !tbaa !9
  call void @vl_free(ptr noundef %44)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 20, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  ret i32 0
}

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

declare i32 @pthread_join(i64 noundef, ptr noundef) #2

declare ptr @vl_configuration_to_string_copy() #2

declare void @vl_free(ptr noundef) #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 = { "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 "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, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = distinct !{!17, !14}


; 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 [3 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @testThread(ptr noundef) #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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; 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
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
.preheader.preheader:
  %2 = alloca [5 x i64], align 16
  %3 = alloca [5 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %3) #5
  store i32 0, ptr %3, align 16, !tbaa !5
  %4 = call i32 @pthread_create(ptr noundef nonnull %2, ptr noundef null, ptr noundef nonnull @testThread, ptr noundef nonnull %3) #5
  %5 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 1, ptr %5, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %7 = call i32 @pthread_create(ptr noundef nonnull %6, ptr noundef null, ptr noundef nonnull @testThread, ptr noundef nonnull %5) #5
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 2, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %2, i64 16
  %10 = call i32 @pthread_create(ptr noundef nonnull %9, ptr noundef null, ptr noundef nonnull @testThread, ptr noundef nonnull %8) #5
  %11 = getelementptr inbounds i8, ptr %3, i64 12
  store i32 3, ptr %11, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %2, i64 24
  %13 = call i32 @pthread_create(ptr noundef nonnull %12, ptr noundef null, ptr noundef nonnull @testThread, ptr noundef nonnull %11) #5
  %14 = getelementptr inbounds i8, ptr %3, i64 16
  store i32 4, ptr %14, align 16, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %2, i64 32
  %16 = call i32 @pthread_create(ptr noundef nonnull %15, ptr noundef null, ptr noundef nonnull @testThread, ptr noundef nonnull %14) #5
  %17 = load i64, ptr %2, align 16, !tbaa !9
  %18 = call i32 @pthread_join(i64 noundef %17, ptr noundef null) #5
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = call i32 @pthread_join(i64 noundef %19, ptr noundef null) #5
  %21 = load i64, ptr %9, align 16, !tbaa !9
  %22 = call i32 @pthread_join(i64 noundef %21, ptr noundef null) #5
  %23 = load i64, ptr %12, align 8, !tbaa !9
  %24 = call i32 @pthread_join(i64 noundef %23, ptr noundef null) #5
  %25 = load i64, ptr %15, align 16, !tbaa !9
  %26 = call i32 @pthread_join(i64 noundef %25, ptr noundef null) #5
  %27 = call ptr @vl_configuration_to_string_copy() #5
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %27)
  call void @vl_free(ptr noundef %27) #5
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %2) #5
  ret i32 0
}

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

declare i32 @pthread_join(i64 noundef, ptr noundef) local_unnamed_addr #4

declare ptr @vl_configuration_to_string_copy() local_unnamed_addr #4

declare void @vl_free(ptr noundef) local_unnamed_addr #4

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 = { 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 "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 = { "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 #5 = { 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}


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