; LLVM IR from introlab/odas :: src/ainjector (ainj_targets)

; 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.ainj_targets_obj = type { ptr, ptr, ptr, ptr }

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

; Function Attrs: nounwind uwtable
define dso_local ptr @ainj_targets_thread(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %8, ptr %4, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %42, %1
  br label %10

10:                                               ; preds = %9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.ainj_targets_obj, ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = call ptr @amsg_hops_filled_pop(ptr noundef %13)
  store ptr %14, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ainj_targets_obj, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = call ptr @amsg_targets_empty_pop(ptr noundef %17)
  store ptr %18, ptr %6, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ainj_targets_obj, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  call void @inj_targets_connect(ptr noundef %21, ptr noundef %22, ptr noundef %23)
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ainj_targets_obj, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !12
  %27 = call i32 @inj_targets_process(ptr noundef %26)
  store i32 %27, ptr %7, align 4, !tbaa !13
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ainj_targets_obj, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !12
  call void @inj_targets_disconnect(ptr noundef %30)
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ainj_targets_obj, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  call void @amsg_hops_empty_push(ptr noundef %33, ptr noundef %34)
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ainj_targets_obj, ptr %35, i32 0, i32 2
  %37 = load ptr, ptr %36, align 8, !tbaa !11
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  call void @amsg_targets_filled_push(ptr noundef %37, ptr noundef %38)
  %39 = load i32, ptr %7, align 4, !tbaa !13
  %40 = icmp eq i32 %39, -1
  br i1 %40, label %41, label %42

41:                                               ; preds = %10
  br label %43

42:                                               ; preds = %10
  br label %9

43:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %44 = load ptr, ptr %2, align 8
  ret ptr %44
}

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

declare ptr @amsg_hops_filled_pop(ptr noundef) #2

declare ptr @amsg_targets_empty_pop(ptr noundef) #2

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

declare i32 @inj_targets_process(ptr noundef) #2

declare void @inj_targets_disconnect(ptr noundef) #2

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

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

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


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

; Function Attrs: nounwind uwtable
define dso_local noalias ptr @ainj_targets_thread(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  br label %4

4:                                                ; preds = %4, %1
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = tail call ptr @amsg_hops_filled_pop(ptr noundef %5) #2
  %7 = load ptr, ptr %3, align 8, !tbaa !10
  %8 = tail call ptr @amsg_targets_empty_pop(ptr noundef %7) #2
  %9 = load ptr, ptr %0, align 8, !tbaa !11
  tail call void @inj_targets_connect(ptr noundef %9, ptr noundef %6, ptr noundef %8) #2
  %10 = load ptr, ptr %0, align 8, !tbaa !11
  %11 = tail call i32 @inj_targets_process(ptr noundef %10) #2
  %12 = load ptr, ptr %0, align 8, !tbaa !11
  tail call void @inj_targets_disconnect(ptr noundef %12) #2
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  tail call void @amsg_hops_empty_push(ptr noundef %13, ptr noundef %6) #2
  %14 = load ptr, ptr %3, align 8, !tbaa !10
  tail call void @amsg_targets_filled_push(ptr noundef %14, ptr noundef %8) #2
  %15 = icmp eq i32 %11, -1
  br i1 %15, label %16, label %4

16:                                               ; preds = %4
  ret ptr undef
}

declare ptr @amsg_hops_filled_pop(ptr noundef) local_unnamed_addr #1

declare ptr @amsg_targets_empty_pop(ptr noundef) local_unnamed_addr #1

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

declare i32 @inj_targets_process(ptr noundef) local_unnamed_addr #1

declare void @inj_targets_disconnect(ptr noundef) local_unnamed_addr #1

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

declare void @amsg_targets_filled_push(ptr noundef, 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 }

!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 8}
!6 = !{!"ainj_targets_obj", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 16}
!11 = !{!6, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass