; LLVM IR from AllAlgorithms/c :: algorithms/queue (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.queue_node = type { ptr, ptr }
%struct.node_data = type { [20 x i8], i8, i32 }

@.str = external hidden unnamed_addr constant [18 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1

; 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 i32, align 4
  %5 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  %6 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %7 = call ptr @queue_init(i32 noundef 10)
  store ptr %7, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %19, %0
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = icmp slt i32 %9, 5
  br i1 %10, label %11, label %22

11:                                               ; preds = %8
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = sext i32 %12 to i64
  %14 = inttoptr i64 %13 to ptr
  %15 = call ptr @queue_node_init(ptr noundef %14, ptr noundef null)
  store ptr %15, ptr %3, align 8, !tbaa !5
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = call i32 @queue_enqueue(ptr noundef %16, ptr noundef %17)
  br label %19

19:                                               ; preds = %11
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %4, align 4, !tbaa !9
  br label %8, !llvm.loop !11

22:                                               ; preds = %8
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %31, %22
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = icmp slt i32 %24, 5
  br i1 %25, label %26, label %34

26:                                               ; preds = %23
  %27 = call ptr @queue_node_init(ptr noundef null, ptr noundef @node_data_init)
  store ptr %27, ptr %3, align 8, !tbaa !5
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = call i32 @queue_enqueue(ptr noundef %28, ptr noundef %29)
  br label %31

31:                                               ; preds = %26
  %32 = load i32, ptr %4, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %4, align 4, !tbaa !9
  br label %23, !llvm.loop !13

34:                                               ; preds = %23
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %47, %34
  %36 = load i32, ptr %4, align 4, !tbaa !9
  %37 = icmp slt i32 %36, 5
  br i1 %37, label %38, label %50

38:                                               ; preds = %35
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = call ptr @queue_dequeue(ptr noundef %39)
  store ptr %40, ptr %3, align 8, !tbaa !5
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.queue_node, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  %44 = ptrtoint ptr %43 to i32
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %44)
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  call void @queue_node_destroy(ptr noundef %46, ptr noundef null)
  br label %47

47:                                               ; preds = %38
  %48 = load i32, ptr %4, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %4, align 4, !tbaa !9
  br label %35, !llvm.loop !16

50:                                               ; preds = %35
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %72, %50
  %52 = load i32, ptr %4, align 4, !tbaa !9
  %53 = icmp slt i32 %52, 5
  br i1 %53, label %54, label %75

54:                                               ; preds = %51
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = call ptr @queue_dequeue(ptr noundef %55)
  store ptr %56, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.queue_node, ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !14
  store ptr %59, ptr %5, align 8, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.node_data, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds [20 x i8], ptr %61, i64 0, i64 0
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.node_data, ptr %63, i32 0, i32 1
  %65 = load i8, ptr %64, align 4, !tbaa !17
  %66 = sext i8 %65 to i32
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.node_data, ptr %67, i32 0, i32 2
  %69 = load i32, ptr %68, align 4, !tbaa !19
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %62, i32 noundef %66, i32 noundef %69)
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  call void @queue_node_destroy(ptr noundef %71, ptr noundef @node_data_destroy)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %72

72:                                               ; preds = %54
  %73 = load i32, ptr %4, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %4, align 4, !tbaa !9
  br label %51, !llvm.loop !20

75:                                               ; preds = %51
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  call void @queue_destroy(ptr noundef %76, ptr noundef null)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  ret i32 0
}

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

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

declare ptr @queue_init(i32 noundef) #1

declare ptr @queue_node_init(ptr noundef, ptr noundef) #1

declare i32 @queue_enqueue(ptr noundef, ptr noundef) #1

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

declare ptr @queue_dequeue(ptr noundef) #1

declare void @queue_node_destroy(ptr noundef, ptr noundef) #1

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

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

declare void @queue_destroy(ptr noundef, ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !6, i64 0}
!15 = !{!"queue_node", !6, i64 0, !6, i64 8}
!16 = distinct !{!16, !12}
!17 = !{!18, !7, i64 20}
!18 = !{!"node_data", !7, i64 0, !7, i64 20, !10, i64 24}
!19 = !{!18, !10, i64 24}
!20 = distinct !{!20, !12}


; 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 [18 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader23.preheader:
  %0 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %1 = tail call ptr @queue_init(i32 noundef 10) #3
  %2 = tail call ptr @queue_node_init(ptr noundef null, ptr noundef null) #3
  %3 = tail call i32 @queue_enqueue(ptr noundef %1, ptr noundef %2) #3
  %4 = tail call ptr @queue_node_init(ptr noundef nonnull inttoptr (i64 1 to ptr), ptr noundef null) #3
  %5 = tail call i32 @queue_enqueue(ptr noundef %1, ptr noundef %4) #3
  %6 = tail call ptr @queue_node_init(ptr noundef nonnull inttoptr (i64 2 to ptr), ptr noundef null) #3
  %7 = tail call i32 @queue_enqueue(ptr noundef %1, ptr noundef %6) #3
  %8 = tail call ptr @queue_node_init(ptr noundef nonnull inttoptr (i64 3 to ptr), ptr noundef null) #3
  %9 = tail call i32 @queue_enqueue(ptr noundef %1, ptr noundef %8) #3
  %10 = tail call ptr @queue_node_init(ptr noundef nonnull inttoptr (i64 4 to ptr), ptr noundef null) #3
  %11 = tail call i32 @queue_enqueue(ptr noundef %1, ptr noundef %10) #3
  %12 = tail call ptr @queue_node_init(ptr noundef null, ptr noundef nonnull @node_data_init) #3
  %13 = tail call i32 @queue_enqueue(ptr noundef %1, ptr noundef %12) #3
  %14 = tail call ptr @queue_node_init(ptr noundef null, ptr noundef nonnull @node_data_init) #3
  %15 = tail call i32 @queue_enqueue(ptr noundef %1, ptr noundef %14) #3
  %16 = tail call ptr @queue_node_init(ptr noundef null, ptr noundef nonnull @node_data_init) #3
  %17 = tail call i32 @queue_enqueue(ptr noundef %1, ptr noundef %16) #3
  %18 = tail call ptr @queue_node_init(ptr noundef null, ptr noundef nonnull @node_data_init) #3
  %19 = tail call i32 @queue_enqueue(ptr noundef %1, ptr noundef %18) #3
  %20 = tail call ptr @queue_node_init(ptr noundef null, ptr noundef nonnull @node_data_init) #3
  %21 = tail call i32 @queue_enqueue(ptr noundef %1, ptr noundef %20) #3
  %22 = tail call ptr @queue_dequeue(ptr noundef %1) #3
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %24 = ptrtoint ptr %23 to i64
  %25 = trunc i64 %24 to i32
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %25)
  tail call void @queue_node_destroy(ptr noundef nonnull %22, ptr noundef null) #3
  %27 = tail call ptr @queue_dequeue(ptr noundef %1) #3
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = ptrtoint ptr %28 to i64
  %30 = trunc i64 %29 to i32
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %30)
  tail call void @queue_node_destroy(ptr noundef nonnull %27, ptr noundef null) #3
  %32 = tail call ptr @queue_dequeue(ptr noundef %1) #3
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = ptrtoint ptr %33 to i64
  %35 = trunc i64 %34 to i32
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %35)
  tail call void @queue_node_destroy(ptr noundef nonnull %32, ptr noundef null) #3
  %37 = tail call ptr @queue_dequeue(ptr noundef %1) #3
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = ptrtoint ptr %38 to i64
  %40 = trunc i64 %39 to i32
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %40)
  tail call void @queue_node_destroy(ptr noundef nonnull %37, ptr noundef null) #3
  %42 = tail call ptr @queue_dequeue(ptr noundef %1) #3
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %44 = ptrtoint ptr %43 to i64
  %45 = trunc i64 %44 to i32
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %45)
  tail call void @queue_node_destroy(ptr noundef nonnull %42, ptr noundef null) #3
  %47 = tail call ptr @queue_dequeue(ptr noundef %1) #3
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 20
  %50 = load i8, ptr %49, align 4, !tbaa !10
  %51 = sext i8 %50 to i32
  %52 = getelementptr inbounds i8, ptr %48, i64 24
  %53 = load i32, ptr %52, align 4, !tbaa !13
  %54 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %48, i32 noundef %51, i32 noundef %53)
  tail call void @queue_node_destroy(ptr noundef nonnull %47, ptr noundef nonnull @node_data_destroy) #3
  %55 = tail call ptr @queue_dequeue(ptr noundef %1) #3
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i64 20
  %58 = load i8, ptr %57, align 4, !tbaa !10
  %59 = sext i8 %58 to i32
  %60 = getelementptr inbounds i8, ptr %56, i64 24
  %61 = load i32, ptr %60, align 4, !tbaa !13
  %62 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %56, i32 noundef %59, i32 noundef %61)
  tail call void @queue_node_destroy(ptr noundef nonnull %55, ptr noundef nonnull @node_data_destroy) #3
  %63 = tail call ptr @queue_dequeue(ptr noundef %1) #3
  %64 = load ptr, ptr %63, align 8, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %64, i64 20
  %66 = load i8, ptr %65, align 4, !tbaa !10
  %67 = sext i8 %66 to i32
  %68 = getelementptr inbounds i8, ptr %64, i64 24
  %69 = load i32, ptr %68, align 4, !tbaa !13
  %70 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %64, i32 noundef %67, i32 noundef %69)
  tail call void @queue_node_destroy(ptr noundef nonnull %63, ptr noundef nonnull @node_data_destroy) #3
  %71 = tail call ptr @queue_dequeue(ptr noundef %1) #3
  %72 = load ptr, ptr %71, align 8, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %72, i64 20
  %74 = load i8, ptr %73, align 4, !tbaa !10
  %75 = sext i8 %74 to i32
  %76 = getelementptr inbounds i8, ptr %72, i64 24
  %77 = load i32, ptr %76, align 4, !tbaa !13
  %78 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %72, i32 noundef %75, i32 noundef %77)
  tail call void @queue_node_destroy(ptr noundef nonnull %71, ptr noundef nonnull @node_data_destroy) #3
  %79 = tail call ptr @queue_dequeue(ptr noundef %1) #3
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  %81 = getelementptr inbounds i8, ptr %80, i64 20
  %82 = load i8, ptr %81, align 4, !tbaa !10
  %83 = sext i8 %82 to i32
  %84 = getelementptr inbounds i8, ptr %80, i64 24
  %85 = load i32, ptr %84, align 4, !tbaa !13
  %86 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %80, i32 noundef %83, i32 noundef %85)
  tail call void @queue_node_destroy(ptr noundef nonnull %79, ptr noundef nonnull @node_data_destroy) #3
  tail call void @queue_destroy(ptr noundef %1, ptr noundef null) #3
  ret i32 0
}

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

declare ptr @queue_init(i32 noundef) local_unnamed_addr #2

declare ptr @queue_node_init(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @queue_enqueue(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare ptr @queue_dequeue(ptr noundef) local_unnamed_addr #2

declare void @queue_node_destroy(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare void @queue_destroy(ptr noundef, ptr noundef) local_unnamed_addr #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 = { 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 #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, !7, i64 0}
!6 = !{!"queue_node", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !8, i64 20}
!11 = !{!"node_data", !8, i64 0, !8, i64 20, !12, i64 24}
!12 = !{!"int", !8, i64 0}
!13 = !{!11, !12, i64 24}


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