; LLVM IR from microbotsio/CodeCell :: src (shtp)

; 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.shtp_s = type { ptr, ptr, ptr, [8 x i8], i16, i16, [256 x i8], i16, i16, i8, [384 x i8], i16, i32, [384 x i8], i32, [5 x %struct.shtp_App_s], i8, i8, [5 x %struct.shtp_AppListener_s], [8 x %struct.shtp_Channel_s], [8 x %struct.shtp_ChanListener_s], i8, i32, i32, i32, i32, i32 }
%struct.shtp_App_s = type { i32, [32 x i8] }
%struct.shtp_AppListener_s = type { i16, ptr, ptr }
%struct.shtp_Channel_s = type { i8, i8, i32, [32 x i8], i8, ptr, ptr }
%struct.shtp_ChanListener_s = type { i16, [32 x i8], ptr, ptr }

; 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 zeroext i8 @shtp_chanNo(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %13, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 -1, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %38, %3
  %15 = load i32, ptr %11, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 5
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 2, ptr %12, align 4
  br label %41

18:                                               ; preds = %14
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.shtp_s, ptr %19, i32 0, i32 15
  %21 = load i32, ptr %11, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [5 x %struct.shtp_App_s], ptr %20, i64 0, i64 %22
  %24 = getelementptr inbounds %struct.shtp_App_s, ptr %23, i32 0, i32 1
  %25 = getelementptr inbounds [32 x i8], ptr %24, i64 0, i64 0
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call i32 @strcmp(ptr noundef %25, ptr noundef %26) #4
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %37

29:                                               ; preds = %18
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.shtp_s, ptr %30, i32 0, i32 15
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [5 x %struct.shtp_App_s], ptr %31, i64 0, i64 %33
  %35 = getelementptr inbounds %struct.shtp_App_s, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 4, !tbaa !11
  store i32 %36, ptr %10, align 4, !tbaa !9
  store i32 2, ptr %12, align 4
  br label %41

37:                                               ; preds = %18
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %11, align 4, !tbaa !9
  br label %14, !llvm.loop !13

41:                                               ; preds = %29, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = icmp eq i32 %43, -1
  br i1 %44, label %45, label %46

45:                                               ; preds = %42
  store i8 -1, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %79

46:                                               ; preds = %42
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %75, %46
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = icmp slt i32 %48, 8
  br i1 %49, label %50, label %78

50:                                               ; preds = %47
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.shtp_s, ptr %51, i32 0, i32 19
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [8 x %struct.shtp_Channel_s], ptr %52, i64 0, i64 %54
  %56 = getelementptr inbounds %struct.shtp_Channel_s, ptr %55, i32 0, i32 3
  %57 = getelementptr inbounds [32 x i8], ptr %56, i64 0, i64 0
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = call i32 @strcmp(ptr noundef %57, ptr noundef %58) #4
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %74

61:                                               ; preds = %50
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.shtp_s, ptr %62, i32 0, i32 19
  %64 = load i32, ptr %9, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [8 x %struct.shtp_Channel_s], ptr %63, i64 0, i64 %65
  %67 = getelementptr inbounds %struct.shtp_Channel_s, ptr %66, i32 0, i32 2
  %68 = load i32, ptr %67, align 4, !tbaa !15
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = icmp eq i32 %68, %69
  br i1 %70, label %71, label %74

71:                                               ; preds = %61
  %72 = load i32, ptr %9, align 4, !tbaa !9
  %73 = trunc i32 %72 to i8
  store i8 %73, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %79

74:                                               ; preds = %61, %50
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %9, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %9, align 4, !tbaa !9
  br label %47, !llvm.loop !18

78:                                               ; preds = %47
  store i8 -1, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %79

79:                                               ; preds = %78, %71, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %80 = load i8, ptr %4, align 1
  ret i8 %80
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr 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 = { 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 #3 = { nounwind }
attributes #4 = { 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, !10, i64 0}
!12 = !{!"shtp_App_s", !10, i64 0, !7, i64 4}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !10, i64 4}
!16 = !{!"shtp_Channel_s", !7, i64 0, !7, i64 1, !10, i64 4, !7, i64 8, !17, i64 40, !6, i64 48, !6, i64 56}
!17 = !{!"_Bool", !7, i64 0}
!18 = distinct !{!18, !14}


; 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: mustprogress nofree nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i8 @shtp_chanNo(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 1076
  %5 = getelementptr inbounds i8, ptr %0, i64 1080
  %6 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) %1) #2
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %28, label %8

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 1112
  %10 = getelementptr inbounds i8, ptr %0, i64 1116
  %11 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %10, ptr noundef nonnull dereferenceable(1) %1) #2
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %28, label %13

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %0, i64 1148
  %15 = getelementptr inbounds i8, ptr %0, i64 1152
  %16 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %15, ptr noundef nonnull dereferenceable(1) %1) #2
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %28, label %18

18:                                               ; preds = %13
  %19 = getelementptr inbounds i8, ptr %0, i64 1184
  %20 = getelementptr inbounds i8, ptr %0, i64 1188
  %21 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %20, ptr noundef nonnull dereferenceable(1) %1) #2
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %28, label %23

23:                                               ; preds = %18
  %24 = getelementptr inbounds i8, ptr %0, i64 1220
  %25 = getelementptr inbounds i8, ptr %0, i64 1224
  %26 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %25, ptr noundef nonnull dereferenceable(1) %1) #2
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %.thread

28:                                               ; preds = %23, %18, %13, %8, %3
  %.lcssa = phi ptr [ %4, %3 ], [ %9, %8 ], [ %14, %13 ], [ %19, %18 ], [ %24, %23 ]
  %29 = load i32, ptr %.lcssa, align 4, !tbaa !5
  %30 = icmp eq i32 %29, -1
  br i1 %30, label %.thread, label %.preheader

.preheader:                                       ; preds = %28
  %31 = getelementptr inbounds i8, ptr %0, i64 1392
  %32 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %31, ptr noundef nonnull dereferenceable(1) %2) #2
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %38

34:                                               ; preds = %.preheader
  %35 = getelementptr inbounds i8, ptr %0, i64 1388
  %36 = load i32, ptr %35, align 4, !tbaa !10
  %37 = icmp eq i32 %36, %29
  br i1 %37, label %.thread, label %38

38:                                               ; preds = %.preheader, %34
  %39 = getelementptr inbounds i8, ptr %0, i64 1456
  %40 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %39, ptr noundef nonnull dereferenceable(1) %2) #2
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %42, label %46

42:                                               ; preds = %38
  %43 = getelementptr inbounds i8, ptr %0, i64 1452
  %44 = load i32, ptr %43, align 4, !tbaa !10
  %45 = icmp eq i32 %44, %29
  br i1 %45, label %.thread, label %46

46:                                               ; preds = %42, %38
  %47 = getelementptr inbounds i8, ptr %0, i64 1520
  %48 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %47, ptr noundef nonnull dereferenceable(1) %2) #2
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %54

50:                                               ; preds = %46
  %51 = getelementptr inbounds i8, ptr %0, i64 1516
  %52 = load i32, ptr %51, align 4, !tbaa !10
  %53 = icmp eq i32 %52, %29
  br i1 %53, label %.thread, label %54

54:                                               ; preds = %50, %46
  %55 = getelementptr inbounds i8, ptr %0, i64 1584
  %56 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %55, ptr noundef nonnull dereferenceable(1) %2) #2
  %57 = icmp eq i32 %56, 0
  br i1 %57, label %58, label %62

58:                                               ; preds = %54
  %59 = getelementptr inbounds i8, ptr %0, i64 1580
  %60 = load i32, ptr %59, align 4, !tbaa !10
  %61 = icmp eq i32 %60, %29
  br i1 %61, label %.thread, label %62

62:                                               ; preds = %58, %54
  %63 = getelementptr inbounds i8, ptr %0, i64 1648
  %64 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %63, ptr noundef nonnull dereferenceable(1) %2) #2
  %65 = icmp eq i32 %64, 0
  br i1 %65, label %66, label %70

66:                                               ; preds = %62
  %67 = getelementptr inbounds i8, ptr %0, i64 1644
  %68 = load i32, ptr %67, align 4, !tbaa !10
  %69 = icmp eq i32 %68, %29
  br i1 %69, label %.thread, label %70

70:                                               ; preds = %66, %62
  %71 = getelementptr inbounds i8, ptr %0, i64 1712
  %72 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %71, ptr noundef nonnull dereferenceable(1) %2) #2
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %74, label %78

74:                                               ; preds = %70
  %75 = getelementptr inbounds i8, ptr %0, i64 1708
  %76 = load i32, ptr %75, align 4, !tbaa !10
  %77 = icmp eq i32 %76, %29
  br i1 %77, label %.thread, label %78

78:                                               ; preds = %74, %70
  %79 = getelementptr inbounds i8, ptr %0, i64 1776
  %80 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %79, ptr noundef nonnull dereferenceable(1) %2) #2
  %81 = icmp eq i32 %80, 0
  br i1 %81, label %82, label %86

82:                                               ; preds = %78
  %83 = getelementptr inbounds i8, ptr %0, i64 1772
  %84 = load i32, ptr %83, align 4, !tbaa !10
  %85 = icmp eq i32 %84, %29
  br i1 %85, label %.thread, label %86

86:                                               ; preds = %82, %78
  %87 = getelementptr inbounds i8, ptr %0, i64 1840
  %88 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %87, ptr noundef nonnull dereferenceable(1) %2) #2
  %89 = icmp eq i32 %88, 0
  br i1 %89, label %90, label %.thread.loopexit

90:                                               ; preds = %86
  %91 = getelementptr inbounds i8, ptr %0, i64 1836
  %92 = load i32, ptr %91, align 4, !tbaa !10
  %93 = icmp eq i32 %92, %29
  br i1 %93, label %.thread, label %.thread.loopexit

.thread.loopexit:                                 ; preds = %90, %86
  br label %.thread

.thread:                                          ; preds = %34, %42, %50, %58, %66, %74, %82, %90, %23, %.thread.loopexit, %28
  %.020 = phi i8 [ -1, %28 ], [ -1, %.thread.loopexit ], [ -1, %23 ], [ 0, %34 ], [ 1, %42 ], [ 2, %50 ], [ 3, %58 ], [ 4, %66 ], [ 5, %74 ], [ 6, %82 ], [ 7, %90 ]
  ret i8 %.020
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn memory(read, inaccessiblemem: none) 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 nounwind willreturn memory(argmem: 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 #2 = { 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, !7, i64 0}
!6 = !{!"shtp_App_s", !7, i64 0, !8, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 4}
!11 = !{!"shtp_Channel_s", !8, i64 0, !8, i64 1, !7, i64 4, !8, i64 8, !12, i64 40, !13, i64 48, !13, i64 56}
!12 = !{!"_Bool", !8, i64 0}
!13 = !{!"any pointer", !8, i64 0}


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