; LLVM IR from zhechkoz/PwIN :: jitmenot (pmparser)

; 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.procmaps_struct = type { ptr, ptr, i64, [5 x i8], i16, i16, i16, i16, i64, [12 x i8], i32, [600 x i8], ptr }

@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [35 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 @pmparser_print(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %7, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = icmp slt i32 %8, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  store i32 -1, ptr %4, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %10, %2
  br label %12

12:                                               ; preds = %84, %11
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %87

15:                                               ; preds = %12
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = icmp eq i32 %16, %17
  br i1 %18, label %22, label %19

19:                                               ; preds = %15
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = icmp eq i32 %20, -1
  br i1 %21, label %22, label %63

22:                                               ; preds = %19, %15
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.procmaps_struct, ptr %23, i32 0, i32 11
  %25 = getelementptr inbounds [600 x i8], ptr %24, i64 0, i64 0
  %26 = call i64 @strlen(ptr noundef %25) #5
  %27 = icmp eq i64 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %22
  br label %33

29:                                               ; preds = %22
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.procmaps_struct, ptr %30, i32 0, i32 11
  %32 = getelementptr inbounds [600 x i8], ptr %31, i64 0, i64 0
  br label %33

33:                                               ; preds = %29, %28
  %34 = phi ptr [ @.str.6, %28 ], [ %32, %29 ]
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, ptr noundef %34)
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.procmaps_struct, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.procmaps_struct, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, ptr noundef %38, ptr noundef %41)
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.procmaps_struct, ptr %43, i32 0, i32 2
  %45 = load i64, ptr %44, align 8, !tbaa !16
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i64 noundef %45)
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.procmaps_struct, ptr %47, i32 0, i32 8
  %49 = load i64, ptr %48, align 8, !tbaa !17
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i64 noundef %49)
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.procmaps_struct, ptr %51, i32 0, i32 3
  %53 = getelementptr inbounds [5 x i8], ptr %52, i64 0, i64 0
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.10, ptr noundef %53)
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.procmaps_struct, ptr %55, i32 0, i32 10
  %57 = load i32, ptr %56, align 4, !tbaa !18
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, i32 noundef %57)
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.procmaps_struct, ptr %59, i32 0, i32 9
  %61 = getelementptr inbounds [12 x i8], ptr %60, i64 0, i64 0
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, ptr noundef %61)
  br label %63

63:                                               ; preds = %33, %19
  %64 = load i32, ptr %4, align 4, !tbaa !9
  %65 = icmp ne i32 %64, -1
  br i1 %65, label %66, label %71

66:                                               ; preds = %63
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = load i32, ptr %4, align 4, !tbaa !9
  %69 = icmp sgt i32 %67, %68
  br i1 %69, label %70, label %71

70:                                               ; preds = %66
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %84

71:                                               ; preds = %66, %63
  %72 = load i32, ptr %4, align 4, !tbaa !9
  %73 = icmp eq i32 %72, -1
  br i1 %73, label %74, label %79

74:                                               ; preds = %71
  %75 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.procmaps_struct, ptr %76, i32 0, i32 12
  %78 = load ptr, ptr %77, align 8, !tbaa !19
  store ptr %78, ptr %5, align 8, !tbaa !5
  br label %83

79:                                               ; preds = %71
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.procmaps_struct, ptr %80, i32 0, i32 12
  %82 = load ptr, ptr %81, align 8, !tbaa !19
  store ptr %82, ptr %5, align 8, !tbaa !5
  br label %83

83:                                               ; preds = %79, %74
  br label %84

84:                                               ; preds = %83, %70
  %85 = load i32, ptr %6, align 4, !tbaa !9
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %6, align 4, !tbaa !9
  br label %12, !llvm.loop !20

87:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

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 willreturn memory(read) "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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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, !6, i64 0}
!12 = !{!"procmaps_struct", !6, i64 0, !6, i64 8, !13, i64 16, !7, i64 24, !14, i64 30, !14, i64 32, !14, i64 34, !14, i64 36, !13, i64 40, !7, i64 48, !10, i64 60, !7, i64 64, !6, i64 664}
!13 = !{!"long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !6, i64 8}
!16 = !{!12, !13, i64 16}
!17 = !{!12, !13, i64 40}
!18 = !{!12, !10, i64 60}
!19 = !{!12, !6, i64 664}
!20 = distinct !{!20, !21}
!21 = !{!"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.5 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [35 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @pmparser_print(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %1, i32 -1)
  %.not25 = icmp eq ptr %0, null
  br i1 %.not25, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %3 = icmp slt i32 %1, 0
  br i1 %3, label %.lr.ph.split.us.split.us, label %.lr.ph.split.split

.lr.ph.split.us.split.us:                         ; preds = %.lr.ph, %.lr.ph.split.us.split.us
  %.02226.us.us = phi ptr [ %27, %.lr.ph.split.us.split.us ], [ %0, %.lr.ph ]
  %4 = getelementptr inbounds i8, ptr %.02226.us.us, i64 64
  %char0.us.us = load i8, ptr %4, align 1
  %5 = icmp eq i8 %char0.us.us, 0
  %6 = select i1 %5, ptr @.str.6, ptr %4
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef nonnull %6)
  %8 = load ptr, ptr %.02226.us.us, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %.02226.us.us, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef %8, ptr noundef %10)
  %12 = getelementptr inbounds i8, ptr %.02226.us.us, i64 16
  %13 = load i64, ptr %12, align 8, !tbaa !14
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i64 noundef %13)
  %15 = getelementptr inbounds i8, ptr %.02226.us.us, i64 40
  %16 = load i64, ptr %15, align 8, !tbaa !15
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i64 noundef %16)
  %18 = getelementptr inbounds i8, ptr %.02226.us.us, i64 24
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10, ptr noundef nonnull %18)
  %20 = getelementptr inbounds i8, ptr %.02226.us.us, i64 60
  %21 = load i32, ptr %20, align 4, !tbaa !16
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, i32 noundef %21)
  %23 = getelementptr inbounds i8, ptr %.02226.us.us, i64 48
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef nonnull %23)
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  %26 = getelementptr inbounds i8, ptr %.02226.us.us, i64 664
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %.not.us.us = icmp eq ptr %27, null
  br i1 %.not.us.us, label %._crit_edge, label %.lr.ph.split.us.split.us, !llvm.loop !18

.lr.ph.split.split:                               ; preds = %.lr.ph, %53
  %.027 = phi i32 [ %56, %53 ], [ 0, %.lr.ph ]
  %.02226 = phi ptr [ %55, %53 ], [ %0, %.lr.ph ]
  %28 = icmp eq i32 %spec.store.select, %.027
  br i1 %28, label %29, label %51

29:                                               ; preds = %.lr.ph.split.split
  %30 = getelementptr inbounds i8, ptr %.02226, i64 64
  %char0 = load i8, ptr %30, align 1
  %31 = icmp eq i8 %char0, 0
  %32 = select i1 %31, ptr @.str.6, ptr %30
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef nonnull %32)
  %34 = load ptr, ptr %.02226, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %.02226, i64 8
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef %34, ptr noundef %36)
  %38 = getelementptr inbounds i8, ptr %.02226, i64 16
  %39 = load i64, ptr %38, align 8, !tbaa !14
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i64 noundef %39)
  %41 = getelementptr inbounds i8, ptr %.02226, i64 40
  %42 = load i64, ptr %41, align 8, !tbaa !15
  %43 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i64 noundef %42)
  %44 = getelementptr inbounds i8, ptr %.02226, i64 24
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10, ptr noundef nonnull %44)
  %46 = getelementptr inbounds i8, ptr %.02226, i64 60
  %47 = load i32, ptr %46, align 4, !tbaa !16
  %48 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, i32 noundef %47)
  %49 = getelementptr inbounds i8, ptr %.02226, i64 48
  %50 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef nonnull %49)
  br label %51

51:                                               ; preds = %.lr.ph.split.split, %29
  %52 = icmp sgt i32 %.027, %spec.store.select
  br i1 %52, label %._crit_edge, label %53

53:                                               ; preds = %51
  %54 = getelementptr inbounds i8, ptr %.02226, i64 664
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = add nuw nsw i32 %.027, 1
  %.not = icmp eq ptr %55, null
  br i1 %.not, label %._crit_edge, label %.lr.ph.split.split, !llvm.loop !18

._crit_edge:                                      ; preds = %51, %53, %.lr.ph.split.us.split.us, %2
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #2

attributes #0 = { nofree 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"procmaps_struct", !7, i64 0, !7, i64 8, !10, i64 16, !8, i64 24, !11, i64 30, !11, i64 32, !11, i64 34, !11, i64 36, !10, i64 40, !8, i64 48, !12, i64 60, !8, i64 64, !7, i64 664}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !10, i64 40}
!16 = !{!6, !12, i64 60}
!17 = !{!6, !7, i64 664}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass