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

; 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.s_pipe = type { i32, i32, i32, i8, i8, i8, i8, i8, [40 x i8], i32, i32 }

@.str = external hidden unnamed_addr constant [53 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [53 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 @printPipeInfo(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.s_pipe, ptr %4, i32 0, i32 2
  %6 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %6, ptr %3, align 4, !tbaa !12
  call void (...) @nextLineAnyway()
  call void @print_stringColor(ptr noundef @.str, ptr noundef @.str.1)
  call void (...) @nextLineAnyway()
  call void (...) @nextLineAnyway()
  call void @print_stringColor(ptr noundef @.str.2, ptr noundef @.str.3)
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.s_pipe, ptr %7, i32 0, i32 0
  %9 = load i32, ptr %8, align 4, !tbaa !13
  %10 = sext i32 %9 to i64
  call void @print_intColor(i64 noundef %10, ptr noundef @.str.3)
  call void (...) @nextLineAnyway()
  call void @print_stringColor(ptr noundef @.str.4, ptr noundef @.str.3)
  call void @print_stringColor(ptr noundef @.str.5, ptr noundef @.str.3)
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.s_pipe, ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 4, !tbaa !14
  %14 = sext i32 %13 to i64
  call void @print_intColor(i64 noundef %14, ptr noundef @.str.3)
  call void @print_stringColor(ptr noundef @.str.6, ptr noundef @.str.3)
  call void @print_stringColor(ptr noundef @.str.7, ptr noundef @.str.3)
  %15 = load i32, ptr %3, align 4, !tbaa !12
  %16 = icmp slt i32 %15, 0
  br i1 %16, label %17, label %21

17:                                               ; preds = %1
  call void @print_stringColor(ptr noundef @.str.8, ptr noundef @.str.3)
  %18 = load i32, ptr %3, align 4, !tbaa !12
  %19 = mul nsw i32 %18, -1
  %20 = sext i32 %19 to i64
  call void @print_intColor(i64 noundef %20, ptr noundef @.str.3)
  call void (...) @nextLineAnyway()
  br label %24

21:                                               ; preds = %1
  %22 = load i32, ptr %3, align 4, !tbaa !12
  %23 = sext i32 %22 to i64
  call void @print_intColor(i64 noundef %23, ptr noundef @.str.3)
  call void (...) @nextLineAnyway()
  br label %24

24:                                               ; preds = %21, %17
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.s_pipe, ptr %25, i32 0, i32 3
  %27 = load i8, ptr %26, align 4, !tbaa !15
  %28 = zext i8 %27 to i32
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %24
  call void @print_stringColor(ptr noundef @.str.9, ptr noundef @.str.10)
  br label %32

31:                                               ; preds = %24
  call void @print_stringColor(ptr noundef @.str.11, ptr noundef @.str.12)
  br label %32

32:                                               ; preds = %31, %30
  call void (...) @nextLineAnyway()
  call void (...) @nextLineAnyway()
  call void @print_stringColor(ptr noundef @.str.13, ptr noundef @.str.1)
  call void (...) @nextLineAnyway()
  call void (...) @nextLineAnyway()
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

declare void @nextLineAnyway(...) #2

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

declare void @print_intColor(i64 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, !11, i64 8}
!10 = !{!"s_pipe", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 12, !7, i64 13, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 17, !11, i64 60, !11, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !11, i64 4}
!15 = !{!10, !7, i64 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 [53 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @printPipeInfo(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 4, !tbaa !5
  tail call void (...) @nextLineAnyway() #2
  tail call void @print_stringColor(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1) #2
  tail call void (...) @nextLineAnyway() #2
  tail call void (...) @nextLineAnyway() #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3) #2
  %4 = load i32, ptr %0, align 4, !tbaa !10
  %5 = sext i32 %4 to i64
  tail call void @print_intColor(i64 noundef %5, ptr noundef nonnull @.str.3) #2
  tail call void (...) @nextLineAnyway() #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.3) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.3) #2
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !11
  %8 = sext i32 %7 to i64
  tail call void @print_intColor(i64 noundef %8, ptr noundef nonnull @.str.3) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.3) #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.3) #2
  %9 = icmp slt i32 %3, 0
  br i1 %9, label %10, label %12

10:                                               ; preds = %1
  tail call void @print_stringColor(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.3) #2
  %11 = sub nsw i32 0, %3
  br label %12

12:                                               ; preds = %1, %10
  %.sink6 = phi i32 [ %11, %10 ], [ %3, %1 ]
  %13 = zext nneg i32 %.sink6 to i64
  tail call void @print_intColor(i64 noundef %13, ptr noundef nonnull @.str.3) #2
  tail call void (...) @nextLineAnyway() #2
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  %15 = load i8, ptr %14, align 4, !tbaa !12
  %16 = icmp eq i8 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %12
  tail call void @print_stringColor(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.10) #2
  br label %19

18:                                               ; preds = %12
  tail call void @print_stringColor(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.12) #2
  br label %19

19:                                               ; preds = %18, %17
  tail call void (...) @nextLineAnyway() #2
  tail call void (...) @nextLineAnyway() #2
  tail call void @print_stringColor(ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.1) #2
  tail call void (...) @nextLineAnyway() #2
  tail call void (...) @nextLineAnyway() #2
  ret void
}

declare void @nextLineAnyway(...) local_unnamed_addr #1

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

declare void @print_intColor(i64 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 = !{!"s_pipe", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12, !8, i64 13, !8, i64 14, !8, i64 15, !8, i64 16, !8, i64 17, !7, i64 60, !7, i64 64}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !8, i64 12}


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