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

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

@registers = external hidden global [16 x ptr], align 16
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1

declare void @print_string(ptr noundef) #0

declare void @nextLine(...) #0

; Function Attrs: nounwind uwtable
define dso_local void @showRegistersValues(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
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %4

4:                                                ; preds = %17, %1
  %5 = load i32, ptr %3, align 4, !tbaa !9
  %6 = icmp slt i32 %5, 16
  br i1 %6, label %7, label %20

7:                                                ; preds = %4
  %8 = load i32, ptr %3, align 4, !tbaa !9
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [16 x ptr], ptr @registers, i64 0, i64 %9
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  call void @print_string(ptr noundef %11)
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = load i32, ptr %3, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i64, ptr %12, i64 %14
  %16 = load i64, ptr %15, align 8, !tbaa !11
  call void @printHex(i64 noundef %16)
  call void (...) @nextLine()
  br label %17

17:                                               ; preds = %7
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %3, align 4, !tbaa !9
  br label %4, !llvm.loop !13

20:                                               ; preds = %4
  call void @print_string(ptr noundef @.str.2)
  call void @cycle()
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @cycle() #1

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

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

declare void @printHex(i64 noundef) #0

attributes #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 = { 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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@registers = external hidden local_unnamed_addr global [16 x ptr], align 16
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1

declare void @print_string(ptr noundef) local_unnamed_addr #0

declare void @nextLine(...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @showRegistersValues(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = load ptr, ptr @registers, align 16, !tbaa !5
  tail call void @print_string(ptr noundef %2) #2
  %3 = load i64, ptr %0, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %3) #2
  tail call void (...) @nextLine() #2
  %4 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 8), align 8, !tbaa !5
  tail call void @print_string(ptr noundef %4) #2
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i64, ptr %5, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %6) #2
  tail call void (...) @nextLine() #2
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 16), align 16, !tbaa !5
  tail call void @print_string(ptr noundef %7) #2
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load i64, ptr %8, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %9) #2
  tail call void (...) @nextLine() #2
  %10 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 24), align 8, !tbaa !5
  tail call void @print_string(ptr noundef %10) #2
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load i64, ptr %11, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %12) #2
  tail call void (...) @nextLine() #2
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 32), align 16, !tbaa !5
  tail call void @print_string(ptr noundef %13) #2
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = load i64, ptr %14, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %15) #2
  tail call void (...) @nextLine() #2
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 40), align 8, !tbaa !5
  tail call void @print_string(ptr noundef %16) #2
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  %18 = load i64, ptr %17, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %18) #2
  tail call void (...) @nextLine() #2
  %19 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 48), align 16, !tbaa !5
  tail call void @print_string(ptr noundef %19) #2
  %20 = getelementptr inbounds i8, ptr %0, i64 48
  %21 = load i64, ptr %20, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %21) #2
  tail call void (...) @nextLine() #2
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 56), align 8, !tbaa !5
  tail call void @print_string(ptr noundef %22) #2
  %23 = getelementptr inbounds i8, ptr %0, i64 56
  %24 = load i64, ptr %23, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %24) #2
  tail call void (...) @nextLine() #2
  %25 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 64), align 16, !tbaa !5
  tail call void @print_string(ptr noundef %25) #2
  %26 = getelementptr inbounds i8, ptr %0, i64 64
  %27 = load i64, ptr %26, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %27) #2
  tail call void (...) @nextLine() #2
  %28 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 72), align 8, !tbaa !5
  tail call void @print_string(ptr noundef %28) #2
  %29 = getelementptr inbounds i8, ptr %0, i64 72
  %30 = load i64, ptr %29, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %30) #2
  tail call void (...) @nextLine() #2
  %31 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 80), align 16, !tbaa !5
  tail call void @print_string(ptr noundef %31) #2
  %32 = getelementptr inbounds i8, ptr %0, i64 80
  %33 = load i64, ptr %32, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %33) #2
  tail call void (...) @nextLine() #2
  %34 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 88), align 8, !tbaa !5
  tail call void @print_string(ptr noundef %34) #2
  %35 = getelementptr inbounds i8, ptr %0, i64 88
  %36 = load i64, ptr %35, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %36) #2
  tail call void (...) @nextLine() #2
  %37 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 96), align 16, !tbaa !5
  tail call void @print_string(ptr noundef %37) #2
  %38 = getelementptr inbounds i8, ptr %0, i64 96
  %39 = load i64, ptr %38, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %39) #2
  tail call void (...) @nextLine() #2
  %40 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 104), align 8, !tbaa !5
  tail call void @print_string(ptr noundef %40) #2
  %41 = getelementptr inbounds i8, ptr %0, i64 104
  %42 = load i64, ptr %41, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %42) #2
  tail call void (...) @nextLine() #2
  %43 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 112), align 16, !tbaa !5
  tail call void @print_string(ptr noundef %43) #2
  %44 = getelementptr inbounds i8, ptr %0, i64 112
  %45 = load i64, ptr %44, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %45) #2
  tail call void (...) @nextLine() #2
  %46 = load ptr, ptr getelementptr inbounds (i8, ptr @registers, i64 120), align 8, !tbaa !5
  tail call void @print_string(ptr noundef %46) #2
  %47 = getelementptr inbounds i8, ptr %0, i64 120
  %48 = load i64, ptr %47, align 8, !tbaa !9
  tail call void @printHex(i64 noundef %48) #2
  tail call void (...) @nextLine() #2
  tail call void @print_string(ptr noundef nonnull @.str.2) #2
  tail call void @cycle()
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @cycle() local_unnamed_addr #1

declare void @printHex(i64 noundef) local_unnamed_addr #0

attributes #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 = { 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 = { 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 = !{!"long", !7, i64 0}


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