; LLVM IR from introlab/odas :: src/sink (snk_hops)

; 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.snk_hops_obj = type { i64, i32, i32, i32, ptr, ptr, ptr, i32, ptr, %struct.sockaddr_in, i32, [4 x i8], ptr }
%struct.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.msg_hops_obj = type { i64, i32, ptr }
%struct.hops_obj = type { i32, i32, 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 void @snk_hops_process_format_binary_int08(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 1, ptr %6, align 4, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %64, %1
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.snk_hops_obj, ptr %10, i32 0, i32 1
  %12 = load i32, ptr %11, align 8, !tbaa !11
  %13 = icmp ult i32 %9, %12
  br i1 %13, label %14, label %67

14:                                               ; preds = %8
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %60, %14
  %16 = load i32, ptr %3, align 4, !tbaa !9
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.snk_hops_obj, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 4, !tbaa !17
  %20 = icmp ult i32 %16, %19
  br i1 %20, label %21, label %63

21:                                               ; preds = %15
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.snk_hops_obj, ptr %22, i32 0, i32 12
  %24 = load ptr, ptr %23, align 8, !tbaa !18
  %25 = getelementptr inbounds %struct.msg_hops_obj, ptr %24, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !19
  %27 = getelementptr inbounds %struct.hops_obj, ptr %26, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !21
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds ptr, ptr %28, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = load i32, ptr %4, align 4, !tbaa !9
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds float, ptr %32, i64 %34
  %36 = load float, ptr %35, align 4, !tbaa !23
  store float %36, ptr %5, align 4, !tbaa !23
  %37 = load float, ptr %5, align 4, !tbaa !23
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.snk_hops_obj, ptr %39, i32 0, i32 11
  %41 = getelementptr inbounds [4 x i8], ptr %40, i64 0, i64 0
  call void @pcm_normalized2signedXXbits(float noundef %37, i32 noundef %38, ptr noundef %41)
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.snk_hops_obj, ptr %42, i32 0, i32 6
  %44 = load ptr, ptr %43, align 8, !tbaa !25
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds i8, ptr %44, i64 %46
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.snk_hops_obj, ptr %48, i32 0, i32 11
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = sub i32 4, %50
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds [4 x i8], ptr %49, i64 0, i64 %52
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = zext i32 %54 to i64
  %56 = mul i64 1, %55
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %47, ptr align 1 %53, i64 %56, i1 false)
  %57 = load i32, ptr %6, align 4, !tbaa !9
  %58 = load i32, ptr %7, align 4, !tbaa !9
  %59 = add i32 %58, %57
  store i32 %59, ptr %7, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %21
  %61 = load i32, ptr %3, align 4, !tbaa !9
  %62 = add i32 %61, 1
  store i32 %62, ptr %3, align 4, !tbaa !9
  br label %15, !llvm.loop !26

63:                                               ; preds = %15
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %4, align 4, !tbaa !9
  %66 = add i32 %65, 1
  store i32 %66, ptr %4, align 4, !tbaa !9
  br label %8, !llvm.loop !28

67:                                               ; preds = %8
  %68 = load i32, ptr %7, align 4, !tbaa !9
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.snk_hops_obj, ptr %69, i32 0, i32 7
  store i32 %68, ptr %70, align 8, !tbaa !29
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

declare void @pcm_normalized2signedXXbits(float noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"snk_hops_obj", !13, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !6, i64 56, !14, i64 64, !10, i64 80, !7, i64 84, !6, i64 88}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"sockaddr_in", !15, i64 0, !15, i64 2, !16, i64 4, !7, i64 8}
!15 = !{!"short", !7, i64 0}
!16 = !{!"in_addr", !10, i64 0}
!17 = !{!12, !10, i64 12}
!18 = !{!12, !6, i64 88}
!19 = !{!20, !6, i64 16}
!20 = !{!"msg_hops_obj", !13, i64 0, !10, i64 8, !6, i64 16}
!21 = !{!22, !6, i64 8}
!22 = !{!"hops_obj", !10, i64 0, !10, i64 4, !6, i64 8}
!23 = !{!24, !24, i64 0}
!24 = !{!"float", !7, i64 0}
!25 = !{!12, !6, i64 40}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}
!29 = !{!12, !10, i64 48}


; 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: nounwind uwtable
define dso_local void @snk_hops_process_format_binary_int08(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge26, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = getelementptr inbounds i8, ptr %0, i64 88
  %6 = getelementptr inbounds i8, ptr %0, i64 84
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = getelementptr inbounds i8, ptr %0, i64 87
  %9 = load i32, ptr %4, align 4, !tbaa !15
  %.not28 = icmp eq i32 %9, 0
  br i1 %.not28, label %._crit_edge26, label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %10 = phi i32 [ %29, %._crit_edge ], [ %3, %.preheader.lr.ph ]
  %11 = phi i32 [ %30, %._crit_edge ], [ 1, %.preheader.lr.ph ]
  %indvars.iv32 = phi i64 [ %indvars.iv.next33, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.025 = phi i32 [ %.1.lcssa, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.not29 = icmp eq i32 %11, 0
  br i1 %.not29, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %.123 = phi i32 [ %25, %.lr.ph ], [ %.025, %.preheader ]
  %12 = load ptr, ptr %5, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !19
  %17 = getelementptr inbounds ptr, ptr %16, i64 %indvars.iv
  %18 = load ptr, ptr %17, align 8, !tbaa !21
  %19 = getelementptr inbounds float, ptr %18, i64 %indvars.iv32
  %20 = load float, ptr %19, align 4, !tbaa !22
  tail call void @pcm_normalized2signedXXbits(float noundef %20, i32 noundef 1, ptr noundef nonnull %6) #2
  %21 = load ptr, ptr %7, align 8, !tbaa !24
  %22 = zext i32 %.123 to i64
  %23 = getelementptr inbounds i8, ptr %21, i64 %22
  %24 = load i8, ptr %8, align 1
  store i8 %24, ptr %23, align 1
  %25 = add i32 %.123, 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr %4, align 4, !tbaa !15
  %27 = zext i32 %26 to i64
  %28 = icmp ult i64 %indvars.iv.next, %27
  br i1 %28, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !25

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr %2, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %29 = phi i32 [ %10, %.preheader ], [ %.pre, %._crit_edge.loopexit ]
  %30 = phi i32 [ 0, %.preheader ], [ %26, %._crit_edge.loopexit ]
  %.1.lcssa = phi i32 [ %.025, %.preheader ], [ %25, %._crit_edge.loopexit ]
  %indvars.iv.next33 = add nuw nsw i64 %indvars.iv32, 1
  %31 = zext i32 %29 to i64
  %32 = icmp ult i64 %indvars.iv.next33, %31
  br i1 %32, label %.preheader, label %._crit_edge26, !llvm.loop !27

._crit_edge26:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %1
  %.0.lcssa = phi i32 [ 0, %1 ], [ 0, %.preheader.lr.ph ], [ %.1.lcssa, %._crit_edge ]
  %33 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 %.0.lcssa, ptr %33, align 8, !tbaa !29
  ret void
}

declare void @pcm_normalized2signedXXbits(float noundef, i32 noundef, ptr noundef) local_unnamed_addr #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 = { "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, !10, i64 8}
!6 = !{!"snk_hops_obj", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !10, i64 48, !11, i64 56, !12, i64 64, !10, i64 80, !8, i64 84, !11, i64 88}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"sockaddr_in", !13, i64 0, !13, i64 2, !14, i64 4, !8, i64 8}
!13 = !{!"short", !8, i64 0}
!14 = !{!"in_addr", !10, i64 0}
!15 = !{!6, !10, i64 12}
!16 = !{!6, !11, i64 88}
!17 = !{!18, !11, i64 16}
!18 = !{!"msg_hops_obj", !7, i64 0, !10, i64 8, !11, i64 16}
!19 = !{!20, !11, i64 8}
!20 = !{!"hops_obj", !10, i64 0, !10, i64 4, !11, i64 8}
!21 = !{!11, !11, i64 0}
!22 = !{!23, !23, i64 0}
!23 = !{!"float", !8, i64 0}
!24 = !{!6, !11, i64 40}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26, !28}
!28 = !{!"llvm.loop.unswitch.partial.disable"}
!29 = !{!6, !10, i64 48}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass