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

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

2:                                                ; preds = %7, %0
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = icmp slt i32 %3, 100
  br i1 %4, label %5, label %10

5:                                                ; preds = %2
  %6 = call ptr @createMutex()
  br label %7

7:                                                ; preds = %5
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = add nsw i32 %8, 1
  store i32 %9, ptr %1, align 4, !tbaa !5
  br label %2, !llvm.loop !9

10:                                               ; preds = %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  ret void
}

; 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 ptr @createMutex() #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 }

!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 = distinct !{!9, !10}
!10 = !{!"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"

; Function Attrs: nounwind uwtable
define dso_local void @initiliazeMutexes() local_unnamed_addr #0 {
  %1 = tail call ptr @createMutex()
  %2 = tail call ptr @createMutex()
  %3 = tail call ptr @createMutex()
  %4 = tail call ptr @createMutex()
  %5 = tail call ptr @createMutex()
  %6 = tail call ptr @createMutex()
  %7 = tail call ptr @createMutex()
  %8 = tail call ptr @createMutex()
  %9 = tail call ptr @createMutex()
  %10 = tail call ptr @createMutex()
  %11 = tail call ptr @createMutex()
  %12 = tail call ptr @createMutex()
  %13 = tail call ptr @createMutex()
  %14 = tail call ptr @createMutex()
  %15 = tail call ptr @createMutex()
  %16 = tail call ptr @createMutex()
  %17 = tail call ptr @createMutex()
  %18 = tail call ptr @createMutex()
  %19 = tail call ptr @createMutex()
  %20 = tail call ptr @createMutex()
  %21 = tail call ptr @createMutex()
  %22 = tail call ptr @createMutex()
  %23 = tail call ptr @createMutex()
  %24 = tail call ptr @createMutex()
  %25 = tail call ptr @createMutex()
  %26 = tail call ptr @createMutex()
  %27 = tail call ptr @createMutex()
  %28 = tail call ptr @createMutex()
  %29 = tail call ptr @createMutex()
  %30 = tail call ptr @createMutex()
  %31 = tail call ptr @createMutex()
  %32 = tail call ptr @createMutex()
  %33 = tail call ptr @createMutex()
  %34 = tail call ptr @createMutex()
  %35 = tail call ptr @createMutex()
  %36 = tail call ptr @createMutex()
  %37 = tail call ptr @createMutex()
  %38 = tail call ptr @createMutex()
  %39 = tail call ptr @createMutex()
  %40 = tail call ptr @createMutex()
  %41 = tail call ptr @createMutex()
  %42 = tail call ptr @createMutex()
  %43 = tail call ptr @createMutex()
  %44 = tail call ptr @createMutex()
  %45 = tail call ptr @createMutex()
  %46 = tail call ptr @createMutex()
  %47 = tail call ptr @createMutex()
  %48 = tail call ptr @createMutex()
  %49 = tail call ptr @createMutex()
  %50 = tail call ptr @createMutex()
  %51 = tail call ptr @createMutex()
  %52 = tail call ptr @createMutex()
  %53 = tail call ptr @createMutex()
  %54 = tail call ptr @createMutex()
  %55 = tail call ptr @createMutex()
  %56 = tail call ptr @createMutex()
  %57 = tail call ptr @createMutex()
  %58 = tail call ptr @createMutex()
  %59 = tail call ptr @createMutex()
  %60 = tail call ptr @createMutex()
  %61 = tail call ptr @createMutex()
  %62 = tail call ptr @createMutex()
  %63 = tail call ptr @createMutex()
  %64 = tail call ptr @createMutex()
  %65 = tail call ptr @createMutex()
  %66 = tail call ptr @createMutex()
  %67 = tail call ptr @createMutex()
  %68 = tail call ptr @createMutex()
  %69 = tail call ptr @createMutex()
  %70 = tail call ptr @createMutex()
  %71 = tail call ptr @createMutex()
  %72 = tail call ptr @createMutex()
  %73 = tail call ptr @createMutex()
  %74 = tail call ptr @createMutex()
  %75 = tail call ptr @createMutex()
  %76 = tail call ptr @createMutex()
  %77 = tail call ptr @createMutex()
  %78 = tail call ptr @createMutex()
  %79 = tail call ptr @createMutex()
  %80 = tail call ptr @createMutex()
  %81 = tail call ptr @createMutex()
  %82 = tail call ptr @createMutex()
  %83 = tail call ptr @createMutex()
  %84 = tail call ptr @createMutex()
  %85 = tail call ptr @createMutex()
  %86 = tail call ptr @createMutex()
  %87 = tail call ptr @createMutex()
  %88 = tail call ptr @createMutex()
  %89 = tail call ptr @createMutex()
  %90 = tail call ptr @createMutex()
  %91 = tail call ptr @createMutex()
  %92 = tail call ptr @createMutex()
  %93 = tail call ptr @createMutex()
  %94 = tail call ptr @createMutex()
  %95 = tail call ptr @createMutex()
  %96 = tail call ptr @createMutex()
  %97 = tail call ptr @createMutex()
  %98 = tail call ptr @createMutex()
  %99 = tail call ptr @createMutex()
  %100 = tail call ptr @createMutex()
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @createMutex() 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" }

!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)"}


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