; LLVM IR from mwarning/KadNode :: src (utils)

; 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 [24 x i8], align 1

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

8:                                                ; preds = %20, %3
  %9 = call ptr @__ctype_b_loc() #5
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = load i8, ptr %11, align 1, !tbaa !11
  %13 = sext i8 %12 to i32
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i16, ptr %10, i64 %14
  %16 = load i16, ptr %15, align 2, !tbaa !12
  %17 = zext i16 %16 to i32
  %18 = and i32 %17, 8192
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %23

20:                                               ; preds = %8
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i32 1
  store ptr %22, ptr %6, align 8, !tbaa !5
  br label %8, !llvm.loop !14

23:                                               ; preds = %8
  br label %24

24:                                               ; preds = %87, %23
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = icmp ne i8 %26, 0
  br i1 %27, label %28, label %90

28:                                               ; preds = %24
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %33, label %39

33:                                               ; preds = %28
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds ptr, ptr %35, i64 %37
  store ptr %34, ptr %38, align 8, !tbaa !5
  br label %40

39:                                               ; preds = %28
  call void (i32, ptr, ...) @log_print(i32 noundef 3, ptr noundef @.str)
  br label %90

40:                                               ; preds = %33
  br label %41

41:                                               ; preds = %61, %40
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load i8, ptr %42, align 1, !tbaa !11
  %44 = sext i8 %43 to i32
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %59

46:                                               ; preds = %41
  %47 = call ptr @__ctype_b_loc() #5
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load i8, ptr %49, align 1, !tbaa !11
  %51 = sext i8 %50 to i32
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i16, ptr %48, i64 %52
  %54 = load i16, ptr %53, align 2, !tbaa !12
  %55 = zext i16 %54 to i32
  %56 = and i32 %55, 8192
  %57 = icmp ne i32 %56, 0
  %58 = xor i1 %57, true
  br label %59

59:                                               ; preds = %46, %41
  %60 = phi i1 [ false, %41 ], [ %58, %46 ]
  br i1 %60, label %61, label %64

61:                                               ; preds = %59
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %62, i32 1
  store ptr %63, ptr %6, align 8, !tbaa !5
  br label %41, !llvm.loop !16

64:                                               ; preds = %59
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = load i8, ptr %65, align 1, !tbaa !11
  %67 = icmp ne i8 %66, 0
  br i1 %67, label %68, label %71

68:                                               ; preds = %64
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %69, i32 1
  store ptr %70, ptr %6, align 8, !tbaa !5
  store i8 0, ptr %69, align 1, !tbaa !11
  br label %71

71:                                               ; preds = %68, %64
  br label %72

72:                                               ; preds = %84, %71
  %73 = call ptr @__ctype_b_loc() #5
  %74 = load ptr, ptr %73, align 8, !tbaa !5
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = load i8, ptr %75, align 1, !tbaa !11
  %77 = sext i8 %76 to i32
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds i16, ptr %74, i64 %78
  %80 = load i16, ptr %79, align 2, !tbaa !12
  %81 = zext i16 %80 to i32
  %82 = and i32 %81, 8192
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %84, label %87

84:                                               ; preds = %72
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds i8, ptr %85, i32 1
  store ptr %86, ptr %6, align 8, !tbaa !5
  br label %72, !llvm.loop !17

87:                                               ; preds = %72
  %88 = load i32, ptr %7, align 4, !tbaa !9
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %7, align 4, !tbaa !9
  br label %24, !llvm.loop !18

90:                                               ; preds = %39, %24
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = load i32, ptr %7, align 4, !tbaa !9
  %93 = load i32, ptr %5, align 4, !tbaa !9
  %94 = sub nsw i32 %93, 1
  %95 = icmp sle i32 %92, %94
  br i1 %95, label %96, label %98

96:                                               ; preds = %90
  %97 = load i32, ptr %7, align 4, !tbaa !9
  br label %101

98:                                               ; preds = %90
  %99 = load i32, ptr %5, align 4, !tbaa !9
  %100 = sub nsw i32 %99, 1
  br label %101

101:                                              ; preds = %98, %96
  %102 = phi i32 [ %97, %96 ], [ %100, %98 ]
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds ptr, ptr %91, i64 %103
  store ptr null, ptr %104, align 8, !tbaa !5
  %105 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %105
}

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

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #2

declare void @log_print(i32 noundef, ptr noundef, ...) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind willreturn memory(none) "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 = { "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(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, !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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}
!18 = distinct !{!18, !15}


; 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 [24 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @setargs(ptr nocapture noundef writeonly %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = tail call ptr @__ctype_b_loc() #4
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  br label %6

6:                                                ; preds = %6, %3
  %.021 = phi ptr [ %2, %3 ], [ %12, %6 ]
  %7 = load i8, ptr %.021, align 1, !tbaa !9
  %8 = sext i8 %7 to i64
  %9 = getelementptr inbounds i16, ptr %5, i64 %8
  %10 = load i16, ptr %9, align 2, !tbaa !10
  %11 = and i16 %10, 8192
  %.not = icmp eq i16 %11, 0
  %12 = getelementptr inbounds i8, ptr %.021, i64 1
  br i1 %.not, label %.preheader, label %6, !llvm.loop !12

.preheader:                                       ; preds = %6
  %.not2436 = icmp eq i8 %7, 0
  br i1 %.not2436, label %.loopexit30, label %.lr.ph39.preheader

.lr.ph39.preheader:                               ; preds = %.preheader
  %smax = tail call i32 @llvm.smax.i32(i32 %1, i32 1)
  %13 = add nsw i32 %smax, -1
  %wide.trip.count = zext nneg i32 %13 to i64
  br label %.lr.ph39

.loopexit:                                        ; preds = %27
  %.not24 = icmp eq i8 %28, 0
  br i1 %.not24, label %.loopexit30.loopexit, label %.lr.ph39, !llvm.loop !14

.lr.ph39:                                         ; preds = %.lr.ph39.preheader, %.loopexit
  %indvars.iv = phi i64 [ 0, %.lr.ph39.preheader ], [ %indvars.iv.next, %.loopexit ]
  %.137 = phi ptr [ %.021, %.lr.ph39.preheader ], [ %.4, %.loopexit ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %wide.trip.count
  br i1 %exitcond.not, label %17, label %14

14:                                               ; preds = %.lr.ph39
  %15 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv
  store ptr %.137, ptr %15, align 8, !tbaa !5
  %16 = load i8, ptr %.137, align 1, !tbaa !9
  %.not2634 = icmp eq i8 %16, 0
  %.pre46 = load ptr, ptr %4, align 8, !tbaa !5
  br i1 %.not2634, label %.critedge.thread, label %.lr.ph

17:                                               ; preds = %.lr.ph39
  tail call void (i32, ptr, ...) @log_print(i32 noundef 3, ptr noundef nonnull @.str) #5
  br label %.loopexit30

.lr.ph:                                           ; preds = %14, %24
  %18 = phi i8 [ %25, %24 ], [ %16, %14 ]
  %.235 = phi ptr [ %23, %24 ], [ %.137, %14 ]
  %19 = sext i8 %18 to i64
  %20 = getelementptr inbounds i16, ptr %.pre46, i64 %19
  %21 = load i16, ptr %20, align 2, !tbaa !10
  %22 = and i16 %21, 8192
  %.not27 = icmp eq i16 %22, 0
  %23 = getelementptr inbounds i8, ptr %.235, i64 1
  br i1 %.not27, label %24, label %.critedge

24:                                               ; preds = %.lr.ph
  %25 = load i8, ptr %23, align 1, !tbaa !9
  %.not26 = icmp eq i8 %25, 0
  br i1 %.not26, label %.critedge.thread, label %.lr.ph, !llvm.loop !15

.critedge:                                        ; preds = %.lr.ph
  store i8 0, ptr %.235, align 1, !tbaa !9
  %.pre = load ptr, ptr %4, align 8, !tbaa !5
  br label %.critedge.thread

.critedge.thread:                                 ; preds = %24, %14, %.critedge
  %26 = phi ptr [ %.pre, %.critedge ], [ %.pre46, %14 ], [ %.pre46, %24 ]
  %.3 = phi ptr [ %23, %.critedge ], [ %.137, %14 ], [ %23, %24 ]
  br label %27

27:                                               ; preds = %27, %.critedge.thread
  %.4 = phi ptr [ %.3, %.critedge.thread ], [ %33, %27 ]
  %28 = load i8, ptr %.4, align 1, !tbaa !9
  %29 = sext i8 %28 to i64
  %30 = getelementptr inbounds i16, ptr %26, i64 %29
  %31 = load i16, ptr %30, align 2, !tbaa !10
  %32 = and i16 %31, 8192
  %.not29 = icmp eq i16 %32, 0
  %33 = getelementptr inbounds i8, ptr %.4, i64 1
  br i1 %.not29, label %.loopexit, label %27, !llvm.loop !16

.loopexit30.loopexit:                             ; preds = %.loopexit
  %34 = trunc nuw nsw i64 %indvars.iv.next to i32
  br label %.loopexit30

.loopexit30:                                      ; preds = %.loopexit30.loopexit, %.preheader, %17
  %.033 = phi i32 [ %13, %17 ], [ 0, %.preheader ], [ %34, %.loopexit30.loopexit ]
  %35 = add nsw i32 %1, -1
  %36 = tail call i32 @llvm.smin.i32(i32 %.033, i32 %35)
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds ptr, ptr %0, i64 %37
  store ptr null, ptr %38, align 8, !tbaa !5
  ret i32 %.033
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #1

declare void @log_print(i32 noundef, ptr noundef, ...) local_unnamed_addr #2

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

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

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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind willreturn memory(none) }
attributes #5 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass