; LLVM IR from docsteer/sacnview :: libs/WinPcap-413-173-b4/Examples-pcap/sendpack (sendpack)

; 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 [20 x i8], align 1
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [256 x i8], align 16
  %8 = alloca [100 x i8], align 16
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 256, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 100, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = icmp ne i32 %11, 2
  br i1 %12, label %13, label %18

13:                                               ; preds = %2
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds ptr, ptr %14, i64 0
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %16)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %68

18:                                               ; preds = %2
  %19 = load ptr, ptr %5, align 8, !tbaa !9
  %20 = getelementptr inbounds ptr, ptr %19, i64 1
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %23 = call ptr @pcap_open_live(ptr noundef %21, i32 noundef 65536, i32 noundef 1, i32 noundef 1000, ptr noundef %22)
  store ptr %23, ptr %6, align 8, !tbaa !9
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %31

25:                                               ; preds = %18
  %26 = load ptr, ptr @stderr, align 8, !tbaa !9
  %27 = load ptr, ptr %5, align 8, !tbaa !9
  %28 = getelementptr inbounds ptr, ptr %27, i64 1
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.1, ptr noundef %29) #4
  store i32 2, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %68

31:                                               ; preds = %18
  %32 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 0
  store i8 1, ptr %32, align 16, !tbaa !11
  %33 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 1
  store i8 1, ptr %33, align 1, !tbaa !11
  %34 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 2
  store i8 1, ptr %34, align 2, !tbaa !11
  %35 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 3
  store i8 1, ptr %35, align 1, !tbaa !11
  %36 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 4
  store i8 1, ptr %36, align 4, !tbaa !11
  %37 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 5
  store i8 1, ptr %37, align 1, !tbaa !11
  %38 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 6
  store i8 2, ptr %38, align 2, !tbaa !11
  %39 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 7
  store i8 2, ptr %39, align 1, !tbaa !11
  %40 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 8
  store i8 2, ptr %40, align 8, !tbaa !11
  %41 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 9
  store i8 2, ptr %41, align 1, !tbaa !11
  %42 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 10
  store i8 2, ptr %42, align 2, !tbaa !11
  %43 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 11
  store i8 2, ptr %43, align 1, !tbaa !11
  store i32 12, ptr %9, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %53, %31
  %45 = load i32, ptr %9, align 4, !tbaa !5
  %46 = icmp slt i32 %45, 100
  br i1 %46, label %47, label %56

47:                                               ; preds = %44
  %48 = load i32, ptr %9, align 4, !tbaa !5
  %49 = trunc i32 %48 to i8
  %50 = load i32, ptr %9, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 %51
  store i8 %49, ptr %52, align 1, !tbaa !11
  br label %53

53:                                               ; preds = %47
  %54 = load i32, ptr %9, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %9, align 4, !tbaa !5
  br label %44, !llvm.loop !12

56:                                               ; preds = %44
  %57 = load ptr, ptr %6, align 8, !tbaa !9
  %58 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 0
  %59 = call i32 @pcap_sendpacket(ptr noundef %57, ptr noundef %58, i32 noundef 100)
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %66

61:                                               ; preds = %56
  %62 = load ptr, ptr @stderr, align 8, !tbaa !9
  %63 = load ptr, ptr %6, align 8, !tbaa !9
  %64 = call ptr @pcap_geterr(ptr noundef %63)
  %65 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef @.str.2, ptr noundef %64) #4
  store i32 3, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %68

66:                                               ; preds = %56
  %67 = load ptr, ptr %6, align 8, !tbaa !9
  call void @pcap_close(ptr noundef %67)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %68

68:                                               ; preds = %66, %61, %25, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 100, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 256, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %69 = load i32, ptr %3, align 4
  ret i32 %69
}

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

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

declare ptr @pcap_open_live(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

declare i32 @pcap_sendpacket(ptr noundef, ptr noundef, i32 noundef) #2

declare ptr @pcap_geterr(ptr noundef) #2

declare void @pcap_close(ptr noundef) #2

; 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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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 = external hidden unnamed_addr constant [20 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 4) i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [256 x i8], align 16
  %4 = alloca [100 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %4) #5
  %.not = icmp eq i32 %0, 2
  br i1 %.not, label %8, label %5

5:                                                ; preds = %2
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef %6)
  br label %31

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = call ptr @pcap_open_live(ptr noundef %10, i32 noundef 65536, i32 noundef 1, i32 noundef 1000, ptr noundef nonnull %3) #5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %17

13:                                               ; preds = %8
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.1, ptr noundef %15) #6
  br label %31

17:                                               ; preds = %8
  %18 = getelementptr inbounds i8, ptr %4, i64 6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(6) %4, i8 1, i64 6, i1 false)
  %19 = getelementptr inbounds i8, ptr %4, i64 12
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(6) %18, i8 2, i64 6, i1 false)
  store <16 x i8> <i8 12, i8 13, i8 14, i8 15, i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27>, ptr %19, align 4, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %4, i64 28
  store <16 x i8> <i8 28, i8 29, i8 30, i8 31, i8 32, i8 33, i8 34, i8 35, i8 36, i8 37, i8 38, i8 39, i8 40, i8 41, i8 42, i8 43>, ptr %20, align 4, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %4, i64 44
  store <16 x i8> <i8 44, i8 45, i8 46, i8 47, i8 48, i8 49, i8 50, i8 51, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 58, i8 59>, ptr %21, align 4, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %4, i64 60
  store <16 x i8> <i8 60, i8 61, i8 62, i8 63, i8 64, i8 65, i8 66, i8 67, i8 68, i8 69, i8 70, i8 71, i8 72, i8 73, i8 74, i8 75>, ptr %22, align 4, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %4, i64 76
  store <16 x i8> <i8 76, i8 77, i8 78, i8 79, i8 80, i8 81, i8 82, i8 83, i8 84, i8 85, i8 86, i8 87, i8 88, i8 89, i8 90, i8 91>, ptr %23, align 4, !tbaa !9
  %24 = getelementptr inbounds i8, ptr %4, i64 92
  store <8 x i8> <i8 92, i8 93, i8 94, i8 95, i8 96, i8 97, i8 98, i8 99>, ptr %24, align 4, !tbaa !9
  %25 = call i32 @pcap_sendpacket(ptr noundef nonnull %11, ptr noundef nonnull %4, i32 noundef 100) #5
  %.not13 = icmp eq i32 %25, 0
  br i1 %.not13, label %30, label %26

26:                                               ; preds = %17
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call ptr @pcap_geterr(ptr noundef nonnull %11) #5
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.2, ptr noundef %28) #6
  br label %31

30:                                               ; preds = %17
  call void @pcap_close(ptr noundef nonnull %11) #5
  br label %31

31:                                               ; preds = %30, %26, %13, %5
  %.011 = phi i32 [ 1, %5 ], [ 2, %13 ], [ 3, %26 ], [ 0, %30 ]
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %3) #5
  ret i32 %.011
}

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

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

declare ptr @pcap_open_live(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

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

declare i32 @pcap_sendpacket(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare ptr @pcap_geterr(ptr noundef) local_unnamed_addr #3

declare void @pcap_close(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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
attributes #6 = { cold 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}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass