; LLVM IR from microsoft/ntttcp-for-linux :: src (util)

; 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.rlimit = type { i64, i64 }
%struct.ntttcp_test = type { i8, i8, i8, i8, i8, i8, i8, ptr, i32, i32, ptr, i32, i32, i8, i32, i32, i32, i32, i64, i64, i64, i64, i32, i32, i32, i8, ptr, ptr, i8, ptr, i8, ptr, i8, ptr, i8, i8 }

@.str.1 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.239 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.240 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.241 = external hidden unnamed_addr constant [94 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: nounwind
declare i32 @asprintf(ptr noundef, ptr noundef, ...) #1

declare void @PRINT_ERR(ptr noundef) #2

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

declare void @PRINT_ERR_FREE(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @check_resource_limit(ptr noundef %0) #3 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.rlimit, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  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 !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  %12 = call i32 @getrlimit(i32 noundef 7, ptr noundef %8) #4
  %13 = icmp eq i32 -1, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %1
  call void @PRINT_ERR(ptr noundef @.str.239)
  br label %15

15:                                               ; preds = %14, %1
  %16 = getelementptr inbounds %struct.rlimit, ptr %8, i32 0, i32 0
  %17 = load i64, ptr %16, align 8, !tbaa !13
  store i64 %17, ptr %5, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.rlimit, ptr %8, i32 0, i32 1
  %19 = load i64, ptr %18, align 8, !tbaa !15
  store i64 %19, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %20 = load i64, ptr %5, align 8, !tbaa !9
  %21 = load i64, ptr %6, align 8, !tbaa !9
  %22 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %4, ptr noundef @.str.240, i64 noundef %20, i64 noundef %21) #4
  store i32 %22, ptr %9, align 4, !tbaa !11
  %23 = load i32, ptr %9, align 4, !tbaa !11
  %24 = icmp slt i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %15
  call void @PRINT_ERR(ptr noundef @.str.1)
  br label %26

26:                                               ; preds = %25, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  call void @PRINT_DBG_FREE(ptr noundef %27)
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ntttcp_test, ptr %28, i32 0, i32 1
  %30 = load i8, ptr %29, align 1, !tbaa !16, !range !19, !noundef !20
  %31 = trunc i8 %30 to i1
  %32 = zext i1 %31 to i32
  %33 = icmp eq i32 %32, 1
  br i1 %33, label %34, label %46

34:                                               ; preds = %26
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ntttcp_test, ptr %35, i32 0, i32 8
  %37 = load i32, ptr %36, align 8, !tbaa !21
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ntttcp_test, ptr %38, i32 0, i32 11
  %40 = load i32, ptr %39, align 8, !tbaa !22
  %41 = mul i32 %37, %40
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ntttcp_test, ptr %42, i32 0, i32 12
  %44 = load i32, ptr %43, align 4, !tbaa !23
  %45 = mul i32 %41, %44
  store i32 %45, ptr %7, align 4, !tbaa !11
  br label %51

46:                                               ; preds = %26
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ntttcp_test, ptr %47, i32 0, i32 8
  %49 = load i32, ptr %48, align 8, !tbaa !21
  %50 = mul i32 %49, 1
  store i32 %50, ptr %7, align 4, !tbaa !11
  br label %51

51:                                               ; preds = %46, %34
  %52 = load i32, ptr %7, align 4, !tbaa !11
  %53 = zext i32 %52 to i64
  %54 = load i64, ptr %5, align 8, !tbaa !9
  %55 = icmp ugt i64 %53, %54
  br i1 %55, label %56, label %65

56:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %57 = load i64, ptr %5, align 8, !tbaa !9
  %58 = load i32, ptr %7, align 4, !tbaa !11
  %59 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %4, ptr noundef @.str.241, i64 noundef %57, i32 noundef %58) #4
  store i32 %59, ptr %10, align 4, !tbaa !11
  %60 = load i32, ptr %10, align 4, !tbaa !11
  %61 = icmp slt i32 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %56
  call void @PRINT_ERR(ptr noundef @.str.1)
  br label %63

63:                                               ; preds = %62, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  call void @PRINT_ERR_FREE(ptr noundef %64)
  store i1 false, ptr %2, align 1
  store i32 1, ptr %11, align 4
  br label %66

65:                                               ; preds = %51
  store i1 true, ptr %2, align 1
  store i32 1, ptr %11, align 4
  br label %66

66:                                               ; preds = %65, %63
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, 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
  %67 = load i1, ptr %2, align 1
  ret i1 %67
}

; Function Attrs: nounwind
declare i32 @getrlimit(i32 noundef, ptr noundef) #1

declare void @PRINT_DBG_FREE(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"rlimit", !10, i64 0, !10, i64 8}
!15 = !{!14, !10, i64 8}
!16 = !{!17, !18, i64 1}
!17 = !{!"ntttcp_test", !18, i64 0, !18, i64 1, !18, i64 2, !18, i64 3, !18, i64 4, !18, i64 5, !18, i64 6, !6, i64 8, !12, i64 16, !12, i64 20, !6, i64 24, !12, i64 32, !12, i64 36, !18, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !12, i64 96, !12, i64 100, !12, i64 104, !18, i64 108, !6, i64 112, !6, i64 120, !18, i64 128, !6, i64 136, !18, i64 144, !6, i64 152, !18, i64 160, !6, i64 168, !18, i64 176, !18, i64 177}
!18 = !{!"_Bool", !7, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!17, !12, i64 16}
!22 = !{!17, !12, i64 32}
!23 = !{!17, !12, i64 36}


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

%struct.rlimit = type { i64, i64 }

@.str.1 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.239 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.240 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.241 = external hidden unnamed_addr constant [94 x i8], align 1

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

; Function Attrs: nounwind
declare i32 @asprintf(ptr noundef, ptr noundef, ...) local_unnamed_addr #1

declare void @PRINT_ERR(ptr noundef) local_unnamed_addr #2

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

declare void @PRINT_ERR_FREE(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @check_resource_limit(ptr nocapture noundef readonly %0) local_unnamed_addr #3 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.rlimit, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  %4 = call i32 @getrlimit(i32 noundef 7, ptr noundef nonnull %3) #4
  %5 = icmp eq i32 %4, -1
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  call void @PRINT_ERR(ptr noundef nonnull @.str.239) #4
  br label %7

7:                                                ; preds = %6, %1
  %8 = load i64, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %3, i64 8
  %10 = load i64, ptr %9, align 8, !tbaa !10
  %11 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %2, ptr noundef nonnull @.str.240, i64 noundef %8, i64 noundef %10) #4
  %12 = icmp slt i32 %11, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %7
  call void @PRINT_ERR(ptr noundef nonnull @.str.1) #4
  br label %14

14:                                               ; preds = %13, %7
  %15 = load ptr, ptr %2, align 8, !tbaa !11
  call void @PRINT_DBG_FREE(ptr noundef %15) #4
  %16 = getelementptr inbounds i8, ptr %0, i64 1
  %17 = load i8, ptr %16, align 1, !tbaa !13, !range !17, !noundef !18
  %18 = trunc nuw i8 %17 to i1
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  %20 = load i32, ptr %19, align 8, !tbaa !19
  br i1 %18, label %21, label %28

21:                                               ; preds = %14
  %22 = getelementptr inbounds i8, ptr %0, i64 32
  %23 = load i32, ptr %22, align 8, !tbaa !20
  %24 = mul i32 %23, %20
  %25 = getelementptr inbounds i8, ptr %0, i64 36
  %26 = load i32, ptr %25, align 4, !tbaa !21
  %27 = mul i32 %24, %26
  br label %28

28:                                               ; preds = %14, %21
  %.013 = phi i32 [ %27, %21 ], [ %20, %14 ]
  %29 = zext i32 %.013 to i64
  %30 = icmp uge i64 %8, %29
  br i1 %30, label %37, label %31

31:                                               ; preds = %28
  %32 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %2, ptr noundef nonnull @.str.241, i64 noundef %8, i32 noundef %.013) #4
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  call void @PRINT_ERR(ptr noundef nonnull @.str.1) #4
  br label %35

35:                                               ; preds = %34, %31
  %36 = load ptr, ptr %2, align 8, !tbaa !11
  call void @PRINT_ERR_FREE(ptr noundef %36) #4
  br label %37

37:                                               ; preds = %28, %35
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret i1 %30
}

; Function Attrs: nounwind
declare i32 @getrlimit(i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @PRINT_DBG_FREE(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 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 = !{!"rlimit", !7, i64 0, !7, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !15, i64 1}
!14 = !{!"ntttcp_test", !15, i64 0, !15, i64 1, !15, i64 2, !15, i64 3, !15, i64 4, !15, i64 5, !15, i64 6, !12, i64 8, !16, i64 16, !16, i64 20, !12, i64 24, !16, i64 32, !16, i64 36, !15, i64 40, !16, i64 44, !16, i64 48, !16, i64 52, !16, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !16, i64 96, !16, i64 100, !16, i64 104, !15, i64 108, !12, i64 112, !12, i64 120, !15, i64 128, !12, i64 136, !15, i64 144, !12, i64 152, !15, i64 160, !12, i64 168, !15, i64 176, !15, i64 177}
!15 = !{!"_Bool", !8, i64 0}
!16 = !{!"int", !8, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!14, !16, i64 16}
!20 = !{!14, !16, i64 32}
!21 = !{!14, !16, i64 36}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass