; LLVM IR from rociodellasala/TP3_SO :: Kernel (mutex)

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @printQueue(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  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 4, ptr %5) #3
  call void @print_stringColor(ptr noundef @.str, ptr noundef @.str.1)
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  call void @print_stringColor(ptr noundef %6, ptr noundef @.str.1)
  call void @print_stringColor(ptr noundef @.str.2, ptr noundef @.str.1)
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %33, %2
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = icmp slt i32 %8, 10
  br i1 %9, label %10, label %36

10:                                               ; preds = %7
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds i32, ptr %11, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %17, label %24

17:                                               ; preds = %10
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr %18, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  call void @print_intColor(i64 noundef %23, ptr noundef @.str.1)
  call void @print_stringColor(ptr noundef @.str.3, ptr noundef @.str.1)
  br label %32

24:                                               ; preds = %10
  call void @print_stringColor(ptr noundef @.str.4, ptr noundef @.str.1)
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr %25, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = mul nsw i32 %29, -1
  %31 = sext i32 %30 to i64
  call void @print_intColor(i64 noundef %31, ptr noundef @.str.1)
  br label %32

32:                                               ; preds = %24, %17
  br label %33

33:                                               ; preds = %32
  %34 = load i32, ptr %5, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %5, align 4, !tbaa !9
  br label %7, !llvm.loop !11

36:                                               ; preds = %7
  call void (...) @nextLineAnyway()
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

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

declare void @print_intColor(i64 noundef, ptr noundef) #2

declare void @nextLineAnyway(...) #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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 [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @printQueue(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  tail call void @print_stringColor(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1) #2
  tail call void @print_stringColor(ptr noundef %1, ptr noundef nonnull @.str.1) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1) #2
  %3 = load i32, ptr %0, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %5, label %7

5:                                                ; preds = %2
  %6 = zext nneg i32 %3 to i64
  tail call void @print_intColor(i64 noundef %6, ptr noundef nonnull @.str.1) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1) #2
  br label %11

7:                                                ; preds = %2
  tail call void @print_stringColor(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1) #2
  %8 = load i32, ptr %0, align 4, !tbaa !5
  %9 = sub nsw i32 0, %8
  %10 = sext i32 %9 to i64
  tail call void @print_intColor(i64 noundef %10, ptr noundef nonnull @.str.1) #2
  br label %11

11:                                               ; preds = %5, %7
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %19, label %15

15:                                               ; preds = %11
  tail call void @print_stringColor(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1) #2
  %16 = load i32, ptr %12, align 4, !tbaa !5
  %17 = sub nsw i32 0, %16
  %18 = sext i32 %17 to i64
  tail call void @print_intColor(i64 noundef %18, ptr noundef nonnull @.str.1) #2
  br label %21

19:                                               ; preds = %11
  %20 = zext nneg i32 %13 to i64
  tail call void @print_intColor(i64 noundef %20, ptr noundef nonnull @.str.1) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1) #2
  br label %21

21:                                               ; preds = %19, %15
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %29, label %25

25:                                               ; preds = %21
  tail call void @print_stringColor(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1) #2
  %26 = load i32, ptr %22, align 4, !tbaa !5
  %27 = sub nsw i32 0, %26
  %28 = sext i32 %27 to i64
  tail call void @print_intColor(i64 noundef %28, ptr noundef nonnull @.str.1) #2
  br label %31

29:                                               ; preds = %21
  %30 = zext nneg i32 %23 to i64
  tail call void @print_intColor(i64 noundef %30, ptr noundef nonnull @.str.1) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1) #2
  br label %31

31:                                               ; preds = %29, %25
  %32 = getelementptr inbounds i8, ptr %0, i64 12
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = icmp sgt i32 %33, 0
  br i1 %34, label %39, label %35

35:                                               ; preds = %31
  tail call void @print_stringColor(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1) #2
  %36 = load i32, ptr %32, align 4, !tbaa !5
  %37 = sub nsw i32 0, %36
  %38 = sext i32 %37 to i64
  tail call void @print_intColor(i64 noundef %38, ptr noundef nonnull @.str.1) #2
  br label %41

39:                                               ; preds = %31
  %40 = zext nneg i32 %33 to i64
  tail call void @print_intColor(i64 noundef %40, ptr noundef nonnull @.str.1) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1) #2
  br label %41

41:                                               ; preds = %39, %35
  %42 = getelementptr inbounds i8, ptr %0, i64 16
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = icmp sgt i32 %43, 0
  br i1 %44, label %49, label %45

45:                                               ; preds = %41
  tail call void @print_stringColor(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1) #2
  %46 = load i32, ptr %42, align 4, !tbaa !5
  %47 = sub nsw i32 0, %46
  %48 = sext i32 %47 to i64
  tail call void @print_intColor(i64 noundef %48, ptr noundef nonnull @.str.1) #2
  br label %51

49:                                               ; preds = %41
  %50 = zext nneg i32 %43 to i64
  tail call void @print_intColor(i64 noundef %50, ptr noundef nonnull @.str.1) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1) #2
  br label %51

51:                                               ; preds = %49, %45
  %52 = getelementptr inbounds i8, ptr %0, i64 20
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = icmp sgt i32 %53, 0
  br i1 %54, label %59, label %55

55:                                               ; preds = %51
  tail call void @print_stringColor(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1) #2
  %56 = load i32, ptr %52, align 4, !tbaa !5
  %57 = sub nsw i32 0, %56
  %58 = sext i32 %57 to i64
  tail call void @print_intColor(i64 noundef %58, ptr noundef nonnull @.str.1) #2
  br label %61

59:                                               ; preds = %51
  %60 = zext nneg i32 %53 to i64
  tail call void @print_intColor(i64 noundef %60, ptr noundef nonnull @.str.1) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1) #2
  br label %61

61:                                               ; preds = %59, %55
  %62 = getelementptr inbounds i8, ptr %0, i64 24
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = icmp sgt i32 %63, 0
  br i1 %64, label %69, label %65

65:                                               ; preds = %61
  tail call void @print_stringColor(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1) #2
  %66 = load i32, ptr %62, align 4, !tbaa !5
  %67 = sub nsw i32 0, %66
  %68 = sext i32 %67 to i64
  tail call void @print_intColor(i64 noundef %68, ptr noundef nonnull @.str.1) #2
  br label %71

69:                                               ; preds = %61
  %70 = zext nneg i32 %63 to i64
  tail call void @print_intColor(i64 noundef %70, ptr noundef nonnull @.str.1) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1) #2
  br label %71

71:                                               ; preds = %69, %65
  %72 = getelementptr inbounds i8, ptr %0, i64 28
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = icmp sgt i32 %73, 0
  br i1 %74, label %79, label %75

75:                                               ; preds = %71
  tail call void @print_stringColor(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1) #2
  %76 = load i32, ptr %72, align 4, !tbaa !5
  %77 = sub nsw i32 0, %76
  %78 = sext i32 %77 to i64
  tail call void @print_intColor(i64 noundef %78, ptr noundef nonnull @.str.1) #2
  br label %81

79:                                               ; preds = %71
  %80 = zext nneg i32 %73 to i64
  tail call void @print_intColor(i64 noundef %80, ptr noundef nonnull @.str.1) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1) #2
  br label %81

81:                                               ; preds = %79, %75
  %82 = getelementptr inbounds i8, ptr %0, i64 32
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = icmp sgt i32 %83, 0
  br i1 %84, label %89, label %85

85:                                               ; preds = %81
  tail call void @print_stringColor(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1) #2
  %86 = load i32, ptr %82, align 4, !tbaa !5
  %87 = sub nsw i32 0, %86
  %88 = sext i32 %87 to i64
  tail call void @print_intColor(i64 noundef %88, ptr noundef nonnull @.str.1) #2
  br label %91

89:                                               ; preds = %81
  %90 = zext nneg i32 %83 to i64
  tail call void @print_intColor(i64 noundef %90, ptr noundef nonnull @.str.1) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1) #2
  br label %91

91:                                               ; preds = %89, %85
  %92 = getelementptr inbounds i8, ptr %0, i64 36
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = icmp sgt i32 %93, 0
  br i1 %94, label %99, label %95

95:                                               ; preds = %91
  tail call void @print_stringColor(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1) #2
  %96 = load i32, ptr %92, align 4, !tbaa !5
  %97 = sub nsw i32 0, %96
  %98 = sext i32 %97 to i64
  tail call void @print_intColor(i64 noundef %98, ptr noundef nonnull @.str.1) #2
  br label %101

99:                                               ; preds = %91
  %100 = zext nneg i32 %93 to i64
  tail call void @print_intColor(i64 noundef %100, ptr noundef nonnull @.str.1) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1) #2
  br label %101

101:                                              ; preds = %99, %95
  tail call void (...) @nextLineAnyway() #2
  ret void
}

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

declare void @print_intColor(i64 noundef, ptr noundef) local_unnamed_addr #1

declare void @nextLineAnyway(...) 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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