; LLVM IR from MakeContributions/DSA :: algorithms/C/linked-lists (gl-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"

%struct.person = type { [30 x i8], i32, i32, i32, %struct.glthread_node_ }
%struct.glthread_node_ = type { ptr, ptr }
%struct.gldll = type { ptr, i64, ptr, i32 }

@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @glthread_pushfront(ptr noundef, 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 @glthread_popfront(ptr noundef) #0

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

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

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

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

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

10:                                               ; preds = %0
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @exit(i32 noundef 0) #8
  unreachable

12:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %13 = call ptr @allocate()
  store ptr %13, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %14 = call ptr @allocate()
  store ptr %14, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.person, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds [30 x i8], ptr %16, i64 0, i64 0
  %18 = call ptr @strcpy(ptr noundef %17, ptr noundef @.str.6) #6
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.person, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds [30 x i8], ptr %20, i64 0, i64 0
  %22 = call ptr @strcpy(ptr noundef %21, ptr noundef @.str.7) #6
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.person, ptr %23, i32 0, i32 1
  store i32 19, ptr %24, align 8, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.person, ptr %25, i32 0, i32 1
  store i32 23, ptr %26, align 8, !tbaa !9
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.person, ptr %27, i32 0, i32 3
  store i32 170, ptr %28, align 8, !tbaa !13
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.person, ptr %29, i32 0, i32 3
  store i32 174, ptr %30, align 8, !tbaa !13
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.person, ptr %31, i32 0, i32 2
  store i32 60, ptr %32, align 4, !tbaa !14
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.person, ptr %33, i32 0, i32 2
  store i32 67, ptr %34, align 4, !tbaa !14
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  call void @init_glthread_list(ptr noundef %35, i32 noundef ptrtoint (ptr getelementptr inbounds (%struct.person, ptr null, i32 0, i32 4) to i32))
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.person, ptr %36, i32 0, i32 4
  call void @init_glthread_node(ptr noundef %37)
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.person, ptr %38, i32 0, i32 4
  call void @init_glthread_node(ptr noundef %39)
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.person, ptr %41, i32 0, i32 4
  call void @glthread_pushfront(ptr noundef %40, ptr noundef %42)
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.person, ptr %44, i32 0, i32 4
  call void @glthread_pushfront(ptr noundef %43, ptr noundef %45)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = call ptr @get_addresses(ptr noundef %46)
  store ptr %47, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !15
  br label %48

48:                                               ; preds = %62, %12
  %49 = load i32, ptr %6, align 4, !tbaa !15
  %50 = sext i32 %49 to i64
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.gldll, ptr %51, i32 0, i32 1
  %53 = load i64, ptr %52, align 8, !tbaa !16
  %54 = icmp ult i64 %50, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %65

56:                                               ; preds = %48
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = load i32, ptr %6, align 4, !tbaa !15
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds ptr, ptr %57, i64 %59
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  call void @print(ptr noundef %61)
  br label %62

62:                                               ; preds = %56
  %63 = load i32, ptr %6, align 4, !tbaa !15
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %6, align 4, !tbaa !15
  br label %48, !llvm.loop !19

65:                                               ; preds = %55
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  call void @glthread_popfront(ptr noundef %66)
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  call void @test(ptr noundef %67)
  call void @destructor(ptr noundef %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  ret i32 0
}

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
declare hidden void @test(ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind allocsize(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 #3 = { "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 = { noreturn 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { noreturn 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, !11, i64 32}
!10 = !{!"", !7, i64 0, !11, i64 32, !11, i64 36, !11, i64 40, !12, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!"glthread_node_", !6, i64 0, !6, i64 8}
!13 = !{!10, !11, i64 40}
!14 = !{!10, !11, i64 36}
!15 = !{!11, !11, i64 0}
!16 = !{!17, !18, i64 8}
!17 = !{!"", !6, i64 0, !18, i64 8, !6, i64 16, !11, i64 24}
!18 = !{!"long", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @glthread_pushfront(ptr noundef, 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 @glthread_popfront(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @allocate() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %2 = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
  store ptr %2, ptr %1, align 8, !tbaa !5
  %3 = icmp eq ptr %2, null
  br i1 %3, label %4, label %6

4:                                                ; preds = %0
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  tail call void @exit(i32 noundef 0) #8
  unreachable

6:                                                ; preds = %0
  %7 = tail call ptr @allocate()
  %8 = tail call ptr @allocate()
  %9 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) @.str.6) #6
  %10 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) @.str.7) #6
  %11 = getelementptr inbounds i8, ptr %7, i64 32
  store i32 19, ptr %11, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %8, i64 32
  store i32 23, ptr %12, align 8, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %7, i64 40
  store i32 170, ptr %13, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %8, i64 40
  store i32 174, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %7, i64 36
  store i32 60, ptr %15, align 4, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %8, i64 36
  store i32 67, ptr %16, align 4, !tbaa !14
  tail call void @init_glthread_list(ptr noundef nonnull %2, i32 noundef 48)
  %17 = getelementptr inbounds i8, ptr %7, i64 48
  tail call void @init_glthread_node(ptr noundef nonnull %17)
  %18 = getelementptr inbounds i8, ptr %8, i64 48
  tail call void @init_glthread_node(ptr noundef nonnull %18)
  tail call void @glthread_pushfront(ptr noundef nonnull %2, ptr noundef nonnull %18)
  tail call void @glthread_pushfront(ptr noundef nonnull %2, ptr noundef nonnull %17)
  %19 = tail call ptr @get_addresses(ptr noundef nonnull %2)
  %20 = getelementptr inbounds i8, ptr %2, i64 8
  %21 = load i64, ptr %20, align 8, !tbaa !15
  %.not = icmp eq i64 %21, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %6
  tail call void @glthread_popfront(ptr noundef nonnull %2)
  tail call void @test(ptr noundef nonnull %2)
  call void @destructor(ptr noundef nonnull %1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  ret i32 0

.lr.ph:                                           ; preds = %6, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %6 ]
  %22 = getelementptr inbounds ptr, ptr %19, i64 %indvars.iv
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  tail call void @print(ptr noundef %23)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = load i64, ptr %20, align 8, !tbaa !15
  %25 = icmp ugt i64 %24, %indvars.iv.next
  br i1 %25, label %.lr.ph, label %._crit_edge, !llvm.loop !18
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden void @test(ptr noundef) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { noreturn 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 #5 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { noreturn 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, !11, i64 32}
!10 = !{!"", !7, i64 0, !11, i64 32, !11, i64 36, !11, i64 40, !12, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!"glthread_node_", !6, i64 0, !6, i64 8}
!13 = !{!10, !11, i64 40}
!14 = !{!10, !11, i64 36}
!15 = !{!16, !17, i64 8}
!16 = !{!"", !6, i64 0, !17, i64 8, !6, i64 16, !11, i64 24}
!17 = !{!"long", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass