; LLVM IR from Montimage/mmt-security :: test (tcp_server)

; 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.user_data_struct = type { i32 }

@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @processing(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca [2000 x i8], align 16
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.user_data_struct, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %10, ptr %3, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 2000, ptr %7) #4
  br label %11

11:                                               ; preds = %51, %1
  %12 = load i32, ptr %3, align 4, !tbaa !12
  %13 = call i64 @recv(i32 noundef %12, ptr noundef %6, i64 noundef 4, i32 noundef 256)
  store i64 %13, ptr %4, align 8, !tbaa !13
  %14 = load i64, ptr %4, align 8, !tbaa !13
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %11
  br label %52

17:                                               ; preds = %11
  %18 = load i32, ptr %6, align 4, !tbaa !12
  %19 = icmp ugt i32 %18, 2000
  br i1 %19, label %20, label %22

20:                                               ; preds = %17
  %21 = load i32, ptr %6, align 4, !tbaa !12
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 2, ptr noundef @.str, i32 noundef %21)
  store i32 2000, ptr %6, align 4, !tbaa !12
  br label %33

22:                                               ; preds = %17
  %23 = load i32, ptr %6, align 4, !tbaa !12
  %24 = icmp ult i32 %23, 30
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  br label %51

26:                                               ; preds = %22
  %27 = load i32, ptr %6, align 4, !tbaa !12
  %28 = icmp ult i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %26
  %30 = load i32, ptr %6, align 4, !tbaa !12
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 0, ptr noundef @.str.1, i32 noundef %30)
  br label %31

31:                                               ; preds = %29, %26
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32, %20
  %34 = load i32, ptr %3, align 4, !tbaa !12
  %35 = getelementptr inbounds [2000 x i8], ptr %7, i64 0, i64 0
  %36 = load i32, ptr %6, align 4, !tbaa !12
  %37 = sub i32 %36, 4
  %38 = zext i32 %37 to i64
  %39 = call i64 @recv(i32 noundef %34, ptr noundef %35, i64 noundef %38, i32 noundef 256)
  store i64 %39, ptr %4, align 8, !tbaa !13
  %40 = load i64, ptr %4, align 8, !tbaa !13
  %41 = icmp eq i64 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %33
  br label %52

43:                                               ; preds = %33
  %44 = load i64, ptr %4, align 8, !tbaa !13
  %45 = icmp ugt i64 %44, 10
  br i1 %45, label %46, label %49

46:                                               ; preds = %43
  %47 = load i64, ptr %5, align 8, !tbaa !13
  %48 = add i64 %47, 1
  store i64 %48, ptr %5, align 8, !tbaa !13
  br label %50

49:                                               ; preds = %43
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 3, ptr noundef @.str.2)
  br label %50

50:                                               ; preds = %49, %46
  br label %51

51:                                               ; preds = %50, %25
  br i1 true, label %11, label %52

52:                                               ; preds = %51, %42, %16
  %53 = call i32 (...) @gettid()
  %54 = load i64, ptr %5, align 8, !tbaa !13
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 0, ptr noundef @.str.3, i32 noundef %53, i64 noundef %54)
  %55 = load i32, ptr %3, align 4, !tbaa !12
  %56 = call i32 @close(i32 noundef %55)
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = call i64 @mmt_mem_free(ptr noundef %57)
  call void @llvm.lifetime.end.p0(i64 2000, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret ptr null
}

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

declare i64 @recv(i32 noundef, ptr noundef, i64 noundef, i32 noundef) #2

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

declare i32 @gettid(...) #2

declare i32 @close(i32 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @mmt_mem_free(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 = { "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 = { inlinehint 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 #4 = { 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 0}
!10 = !{!"user_data_struct", !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}


; 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 [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @processing(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca i32, align 4
  %3 = alloca [2000 x i8], align 16
  %4 = load i32, ptr %0, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 2000, ptr nonnull %3) #4
  %5 = call i64 @recv(i32 noundef %4, ptr noundef nonnull %2, i64 noundef 4, i32 noundef 256) #4
  %6 = icmp eq i64 %5, 0
  br i1 %6, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %23
  %.012 = phi i64 [ %.1, %23 ], [ 0, %1 ]
  %7 = load i32, ptr %2, align 4, !tbaa !10
  %8 = icmp ugt i32 %7, 2000
  br i1 %8, label %9, label %10

9:                                                ; preds = %.lr.ph
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 2, ptr noundef nonnull @.str, i32 noundef %7) #4
  store i32 2000, ptr %2, align 4, !tbaa !10
  br label %12

10:                                               ; preds = %.lr.ph
  %11 = icmp ult i32 %7, 30
  br i1 %11, label %23, label %12

12:                                               ; preds = %10, %9
  %13 = phi i32 [ %7, %10 ], [ 2000, %9 ]
  %14 = add nsw i32 %13, -4
  %15 = zext nneg i32 %14 to i64
  %16 = call i64 @recv(i32 noundef %4, ptr noundef nonnull %3, i64 noundef %15, i32 noundef 256) #4
  %17 = icmp eq i64 %16, 0
  br i1 %17, label %._crit_edge, label %18

18:                                               ; preds = %12
  %19 = icmp ugt i64 %16, 10
  br i1 %19, label %20, label %22

20:                                               ; preds = %18
  %21 = add i64 %.012, 1
  br label %23

22:                                               ; preds = %18
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 3, ptr noundef nonnull @.str.2) #4
  br label %23

23:                                               ; preds = %20, %22, %10
  %.1 = phi i64 [ %21, %20 ], [ %.012, %22 ], [ %.012, %10 ]
  %24 = call i64 @recv(i32 noundef %4, ptr noundef nonnull %2, i64 noundef 4, i32 noundef 256) #4
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %23, %12, %1
  %.0.lcssa = phi i64 [ 0, %1 ], [ %.012, %12 ], [ %.1, %23 ]
  %26 = call i32 (...) @gettid() #4
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 0, ptr noundef nonnull @.str.3, i32 noundef %26, i64 noundef %.0.lcssa) #4
  %27 = call i32 @close(i32 noundef %4) #4
  %28 = call i64 @mmt_mem_free(ptr noundef nonnull %0)
  call void @llvm.lifetime.end.p0(i64 2000, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  ret ptr null
}

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

declare i64 @recv(i32 noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #2

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

declare i32 @gettid(...) local_unnamed_addr #2

declare i32 @close(i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @mmt_mem_free(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #4 = { 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 0}
!6 = !{!"user_data_struct", !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass