; LLVM IR from pandax381/microps :: net (net_device_output)

; 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.net_device = type { ptr, ptr, i32, [16 x i8], i16, i16, i16, i16, i16, [16 x i8], %union.anon, ptr, ptr }
%union.anon = type { [16 x i8] }
%struct.net_device_ops = type { ptr, ptr, ptr, ptr }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [57 x i8], align 1
@__func__.net_device_output = external hidden unnamed_addr constant [18 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [41 x i8], align 1

declare i32 @lprintf(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @net_device_output(ptr noundef %0, i16 noundef zeroext %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i16, align 2
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i16 %1, ptr %8, align 2, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i64 %3, ptr %10, align 8, !tbaa !11
  store ptr %4, ptr %11, align 8, !tbaa !5
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.net_device, ptr %12, i32 0, i32 6
  %14 = load i16, ptr %13, align 8, !tbaa !13
  %15 = zext i16 %14 to i32
  %16 = and i32 %15, 1
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %24, label %18

18:                                               ; preds = %5
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.net_device, ptr %20, i32 0, i32 3
  %22 = getelementptr inbounds [16 x i8], ptr %21, i64 0, i64 0
  %23 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %19, i32 noundef 69, ptr noundef @.str, i32 noundef 149, ptr noundef @__func__.net_device_output, ptr noundef @.str.5, ptr noundef %22)
  store i32 -1, ptr %6, align 4
  br label %73

24:                                               ; preds = %5
  %25 = load i64, ptr %10, align 8, !tbaa !11
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.net_device, ptr %26, i32 0, i32 5
  %28 = load i16, ptr %27, align 2, !tbaa !16
  %29 = zext i16 %28 to i64
  %30 = icmp ugt i64 %25, %29
  br i1 %30, label %31, label %42

31:                                               ; preds = %24
  %32 = load ptr, ptr @stderr, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.net_device, ptr %33, i32 0, i32 3
  %35 = getelementptr inbounds [16 x i8], ptr %34, i64 0, i64 0
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.net_device, ptr %36, i32 0, i32 5
  %38 = load i16, ptr %37, align 2, !tbaa !16
  %39 = zext i16 %38 to i32
  %40 = load i64, ptr %10, align 8, !tbaa !11
  %41 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %32, i32 noundef 69, ptr noundef @.str, i32 noundef 153, ptr noundef @__func__.net_device_output, ptr noundef @.str.6, ptr noundef %35, i32 noundef %39, i64 noundef %40)
  store i32 -1, ptr %6, align 4
  br label %73

42:                                               ; preds = %24
  %43 = load ptr, ptr @stderr, align 8, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.net_device, ptr %44, i32 0, i32 3
  %46 = getelementptr inbounds [16 x i8], ptr %45, i64 0, i64 0
  %47 = load i16, ptr %8, align 2, !tbaa !9
  %48 = call ptr @net_protocol_name(i16 noundef zeroext %47)
  %49 = load i16, ptr %8, align 2, !tbaa !9
  %50 = zext i16 %49 to i32
  %51 = load i64, ptr %10, align 8, !tbaa !11
  %52 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %43, i32 noundef 68, ptr noundef @.str, i32 noundef 156, ptr noundef @__func__.net_device_output, ptr noundef @.str.7, ptr noundef %46, ptr noundef %48, i32 noundef %50, i64 noundef %51)
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.net_device, ptr %53, i32 0, i32 11
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = getelementptr inbounds %struct.net_device_ops, ptr %55, i32 0, i32 2
  %57 = load ptr, ptr %56, align 8, !tbaa !18
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load i16, ptr %8, align 2, !tbaa !9
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = load i64, ptr %10, align 8, !tbaa !11
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = call i32 %57(ptr noundef %58, i16 noundef zeroext %59, ptr noundef %60, i64 noundef %61, ptr noundef %62)
  %64 = icmp eq i32 %63, -1
  br i1 %64, label %65, label %72

65:                                               ; preds = %42
  %66 = load ptr, ptr @stderr, align 8, !tbaa !5
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.net_device, ptr %67, i32 0, i32 3
  %69 = getelementptr inbounds [16 x i8], ptr %68, i64 0, i64 0
  %70 = load i64, ptr %10, align 8, !tbaa !11
  %71 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %66, i32 noundef 69, ptr noundef @.str, i32 noundef 159, ptr noundef @__func__.net_device_output, ptr noundef @.str.8, ptr noundef %69, i64 noundef %70)
  store i32 -1, ptr %6, align 4
  br label %73

72:                                               ; preds = %42
  store i32 0, ptr %6, align 4
  br label %73

73:                                               ; preds = %72, %65, %31, %18
  %74 = load i32, ptr %6, align 4
  ret i32 %74
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @net_protocol_name(i16 noundef zeroext) #1

attributes #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 = { 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" }

!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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 40}
!14 = !{!"net_device", !6, i64 0, !6, i64 8, !15, i64 16, !7, i64 20, !10, i64 36, !10, i64 38, !10, i64 40, !10, i64 42, !10, i64 44, !7, i64 46, !7, i64 62, !6, i64 80, !6, i64 88}
!15 = !{!"int", !7, i64 0}
!16 = !{!14, !10, i64 38}
!17 = !{!14, !6, i64 80}
!18 = !{!19, !6, i64 16}
!19 = !{!"net_device_ops", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [57 x i8], align 1
@__func__.net_device_output = external hidden unnamed_addr constant [18 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [41 x i8], align 1

declare i32 @lprintf(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @net_device_output(ptr noundef %0, i16 noundef zeroext %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = load i16, ptr %6, align 8, !tbaa !5
  %8 = and i16 %7, 1
  %.not = icmp eq i16 %8, 0
  br i1 %.not, label %9, label %13

9:                                                ; preds = %5
  %10 = load ptr, ptr @stderr, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %0, i64 20
  %12 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %10, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 149, ptr noundef nonnull @__func__.net_device_output, ptr noundef nonnull @.str.5, ptr noundef nonnull %11) #2
  br label %36

13:                                               ; preds = %5
  %14 = getelementptr inbounds i8, ptr %0, i64 38
  %15 = load i16, ptr %14, align 2, !tbaa !13
  %16 = zext i16 %15 to i64
  %17 = icmp ult i64 %16, %3
  %18 = load ptr, ptr @stderr, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %0, i64 20
  br i1 %17, label %20, label %23

20:                                               ; preds = %13
  %21 = zext i16 %15 to i32
  %22 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %18, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 153, ptr noundef nonnull @__func__.net_device_output, ptr noundef nonnull @.str.6, ptr noundef nonnull %19, i32 noundef %21, i64 noundef %3) #2
  br label %36

23:                                               ; preds = %13
  %24 = tail call ptr @net_protocol_name(i16 noundef zeroext %1)
  %25 = zext i16 %1 to i32
  %26 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %18, i32 noundef 68, ptr noundef nonnull @.str, i32 noundef 156, ptr noundef nonnull @__func__.net_device_output, ptr noundef nonnull @.str.7, ptr noundef nonnull %19, ptr noundef %24, i32 noundef %25, i64 noundef %3) #2
  %27 = getelementptr inbounds i8, ptr %0, i64 80
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %29 = getelementptr inbounds i8, ptr %28, i64 16
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = tail call i32 %30(ptr noundef nonnull %0, i16 noundef zeroext %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) #2
  %32 = icmp eq i32 %31, -1
  br i1 %32, label %33, label %36

33:                                               ; preds = %23
  %34 = load ptr, ptr @stderr, align 8, !tbaa !12
  %35 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %34, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 159, ptr noundef nonnull @__func__.net_device_output, ptr noundef nonnull @.str.8, ptr noundef nonnull %19, i64 noundef %3) #2
  br label %36

36:                                               ; preds = %23, %33, %20, %9
  %.0 = phi i32 [ -1, %20 ], [ -1, %33 ], [ -1, %9 ], [ 0, %23 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @net_protocol_name(i16 noundef zeroext) local_unnamed_addr #1

attributes #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 = { 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 }

!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, !11, i64 40}
!6 = !{!"net_device", !7, i64 0, !7, i64 8, !10, i64 16, !8, i64 20, !11, i64 36, !11, i64 38, !11, i64 40, !11, i64 42, !11, i64 44, !8, i64 46, !8, i64 62, !7, i64 80, !7, i64 88}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !11, i64 38}
!14 = !{!6, !7, i64 80}
!15 = !{!16, !7, i64 16}
!16 = !{!"net_device_ops", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass