; LLVM IR from zeroth-robotics/zeroth-bot :: kos-zbot/firmware/sts3215 (sts3215)

; 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.ServoInfo = type { i8, i8, i16, i16, i16, i16, [6 x i8], i8, i16, i16, i16, i8, i8, i8, i8, i8, [2 x i8], i16 }

; 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
declare dso_local i32 @servo_read(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, ptr noundef) #1

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

12:                                               ; preds = %2
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %134

13:                                               ; preds = %2
  %14 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 0
  %15 = load i8, ptr %14, align 16, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !8
  %17 = getelementptr inbounds %struct.ServoInfo, ptr %16, i32 0, i32 0
  store i8 %15, ptr %17, align 2, !tbaa !10
  %18 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 1
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = load ptr, ptr %5, align 8, !tbaa !8
  %21 = getelementptr inbounds %struct.ServoInfo, ptr %20, i32 0, i32 1
  store i8 %19, ptr %21, align 1, !tbaa !13
  %22 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 3
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = zext i8 %23 to i32
  %25 = shl i32 %24, 8
  %26 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 2
  %27 = load i8, ptr %26, align 2, !tbaa !5
  %28 = zext i8 %27 to i32
  %29 = or i32 %25, %28
  %30 = trunc i32 %29 to i16
  %31 = load ptr, ptr %5, align 8, !tbaa !8
  %32 = getelementptr inbounds %struct.ServoInfo, ptr %31, i32 0, i32 2
  store i16 %30, ptr %32, align 2, !tbaa !14
  %33 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 5
  %34 = load i8, ptr %33, align 1, !tbaa !5
  %35 = zext i8 %34 to i32
  %36 = shl i32 %35, 8
  %37 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 4
  %38 = load i8, ptr %37, align 4, !tbaa !5
  %39 = zext i8 %38 to i32
  %40 = or i32 %36, %39
  %41 = trunc i32 %40 to i16
  %42 = load ptr, ptr %5, align 8, !tbaa !8
  %43 = getelementptr inbounds %struct.ServoInfo, ptr %42, i32 0, i32 3
  store i16 %41, ptr %43, align 2, !tbaa !15
  %44 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 7
  %45 = load i8, ptr %44, align 1, !tbaa !5
  %46 = zext i8 %45 to i32
  %47 = shl i32 %46, 8
  %48 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 6
  %49 = load i8, ptr %48, align 2, !tbaa !5
  %50 = zext i8 %49 to i32
  %51 = or i32 %47, %50
  %52 = trunc i32 %51 to i16
  %53 = load ptr, ptr %5, align 8, !tbaa !8
  %54 = getelementptr inbounds %struct.ServoInfo, ptr %53, i32 0, i32 4
  store i16 %52, ptr %54, align 2, !tbaa !16
  %55 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 9
  %56 = load i8, ptr %55, align 1, !tbaa !5
  %57 = zext i8 %56 to i32
  %58 = shl i32 %57, 8
  %59 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 8
  %60 = load i8, ptr %59, align 8, !tbaa !5
  %61 = zext i8 %60 to i32
  %62 = or i32 %58, %61
  %63 = trunc i32 %62 to i16
  %64 = load ptr, ptr %5, align 8, !tbaa !8
  %65 = getelementptr inbounds %struct.ServoInfo, ptr %64, i32 0, i32 5
  store i16 %63, ptr %65, align 2, !tbaa !17
  %66 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 15
  %67 = load i8, ptr %66, align 1, !tbaa !5
  %68 = load ptr, ptr %5, align 8, !tbaa !8
  %69 = getelementptr inbounds %struct.ServoInfo, ptr %68, i32 0, i32 7
  store i8 %67, ptr %69, align 2, !tbaa !18
  %70 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 17
  %71 = load i8, ptr %70, align 1, !tbaa !5
  %72 = zext i8 %71 to i32
  %73 = shl i32 %72, 8
  %74 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 16
  %75 = load i8, ptr %74, align 16, !tbaa !5
  %76 = zext i8 %75 to i32
  %77 = or i32 %73, %76
  %78 = trunc i32 %77 to i16
  %79 = load ptr, ptr %5, align 8, !tbaa !8
  %80 = getelementptr inbounds %struct.ServoInfo, ptr %79, i32 0, i32 8
  store i16 %78, ptr %80, align 2, !tbaa !19
  %81 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 19
  %82 = load i8, ptr %81, align 1, !tbaa !5
  %83 = zext i8 %82 to i32
  %84 = shl i32 %83, 8
  %85 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 18
  %86 = load i8, ptr %85, align 2, !tbaa !5
  %87 = zext i8 %86 to i32
  %88 = or i32 %84, %87
  %89 = trunc i32 %88 to i16
  %90 = load ptr, ptr %5, align 8, !tbaa !8
  %91 = getelementptr inbounds %struct.ServoInfo, ptr %90, i32 0, i32 9
  store i16 %89, ptr %91, align 2, !tbaa !20
  %92 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 21
  %93 = load i8, ptr %92, align 1, !tbaa !5
  %94 = zext i8 %93 to i32
  %95 = shl i32 %94, 8
  %96 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 20
  %97 = load i8, ptr %96, align 4, !tbaa !5
  %98 = zext i8 %97 to i32
  %99 = or i32 %95, %98
  %100 = trunc i32 %99 to i16
  %101 = load ptr, ptr %5, align 8, !tbaa !8
  %102 = getelementptr inbounds %struct.ServoInfo, ptr %101, i32 0, i32 10
  store i16 %100, ptr %102, align 2, !tbaa !21
  %103 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 22
  %104 = load i8, ptr %103, align 2, !tbaa !5
  %105 = load ptr, ptr %5, align 8, !tbaa !8
  %106 = getelementptr inbounds %struct.ServoInfo, ptr %105, i32 0, i32 11
  store i8 %104, ptr %106, align 2, !tbaa !22
  %107 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 23
  %108 = load i8, ptr %107, align 1, !tbaa !5
  %109 = load ptr, ptr %5, align 8, !tbaa !8
  %110 = getelementptr inbounds %struct.ServoInfo, ptr %109, i32 0, i32 12
  store i8 %108, ptr %110, align 1, !tbaa !23
  %111 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 24
  %112 = load i8, ptr %111, align 8, !tbaa !5
  %113 = load ptr, ptr %5, align 8, !tbaa !8
  %114 = getelementptr inbounds %struct.ServoInfo, ptr %113, i32 0, i32 13
  store i8 %112, ptr %114, align 2, !tbaa !24
  %115 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 25
  %116 = load i8, ptr %115, align 1, !tbaa !5
  %117 = load ptr, ptr %5, align 8, !tbaa !8
  %118 = getelementptr inbounds %struct.ServoInfo, ptr %117, i32 0, i32 14
  store i8 %116, ptr %118, align 1, !tbaa !25
  %119 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 26
  %120 = load i8, ptr %119, align 2, !tbaa !5
  %121 = load ptr, ptr %5, align 8, !tbaa !8
  %122 = getelementptr inbounds %struct.ServoInfo, ptr %121, i32 0, i32 15
  store i8 %120, ptr %122, align 2, !tbaa !26
  %123 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 29
  %124 = load i8, ptr %123, align 1, !tbaa !5
  %125 = zext i8 %124 to i32
  %126 = shl i32 %125, 8
  %127 = getelementptr inbounds [30 x i8], ptr %6, i64 0, i64 28
  %128 = load i8, ptr %127, align 4, !tbaa !5
  %129 = zext i8 %128 to i32
  %130 = or i32 %126, %129
  %131 = trunc i32 %130 to i16
  %132 = load ptr, ptr %5, align 8, !tbaa !8
  %133 = getelementptr inbounds %struct.ServoInfo, ptr %132, i32 0, i32 17
  store i16 %131, ptr %133, align 2, !tbaa !27
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %134

134:                                              ; preds = %13, %12
  call void @llvm.lifetime.end.p0(i64 30, ptr %6) #2
  %135 = load i32, ptr %3, align 4
  ret i32 %135
}

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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !6, i64 0}
!11 = !{!"", !6, i64 0, !6, i64 1, !12, i64 2, !12, i64 4, !12, i64 6, !12, i64 8, !6, i64 10, !6, i64 16, !12, i64 18, !12, i64 20, !12, i64 22, !6, i64 24, !6, i64 25, !6, i64 26, !6, i64 27, !6, i64 28, !6, i64 29, !12, i64 32}
!12 = !{!"short", !6, i64 0}
!13 = !{!11, !6, i64 1}
!14 = !{!11, !12, i64 2}
!15 = !{!11, !12, i64 4}
!16 = !{!11, !12, i64 6}
!17 = !{!11, !12, i64 8}
!18 = !{!11, !6, i64 16}
!19 = !{!11, !12, i64 18}
!20 = !{!11, !12, i64 20}
!21 = !{!11, !12, i64 22}
!22 = !{!11, !6, i64 24}
!23 = !{!11, !6, i64 25}
!24 = !{!11, !6, i64 26}
!25 = !{!11, !6, i64 27}
!26 = !{!11, !6, i64 28}
!27 = !{!11, !12, i64 32}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @servo_read(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @servo_read_info(i8 noundef zeroext %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  %3 = alloca [30 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 30, ptr nonnull %3) #2
  %4 = call i32 @servo_read(i8 noundef zeroext %0, i8 noundef zeroext 40, i8 noundef zeroext 30, ptr noundef nonnull %3)
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %5, label %31

5:                                                ; preds = %2
  %6 = load i8, ptr %3, align 16, !tbaa !5
  store i8 %6, ptr %1, align 2, !tbaa !8
  %7 = getelementptr inbounds i8, ptr %3, i64 1
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 %8, ptr %9, align 1, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %3, i64 2
  %11 = getelementptr inbounds i8, ptr %1, i64 2
  %12 = load <4 x i16>, ptr %10, align 2
  store <4 x i16> %12, ptr %11, align 2, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %3, i64 15
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %1, i64 16
  store i8 %14, ptr %15, align 2, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %3, i64 16
  %17 = getelementptr inbounds i8, ptr %1, i64 18
  %18 = load <2 x i16>, ptr %16, align 16
  store <2 x i16> %18, ptr %17, align 2, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %3, i64 20
  %20 = load i16, ptr %19, align 4
  %21 = getelementptr inbounds i8, ptr %1, i64 22
  store i16 %20, ptr %21, align 2, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %3, i64 22
  %23 = getelementptr inbounds i8, ptr %1, i64 24
  %24 = load <4 x i8>, ptr %22, align 2, !tbaa !5
  store <4 x i8> %24, ptr %23, align 2, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %3, i64 26
  %26 = load i8, ptr %25, align 2, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %1, i64 28
  store i8 %26, ptr %27, align 2, !tbaa !15
  %28 = getelementptr inbounds i8, ptr %3, i64 28
  %29 = load i16, ptr %28, align 4
  %30 = getelementptr inbounds i8, ptr %1, i64 32
  store i16 %29, ptr %30, align 2, !tbaa !16
  br label %31

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

attributes #0 = { mustprogress 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !6, i64 0}
!9 = !{!"", !6, i64 0, !6, i64 1, !10, i64 2, !10, i64 4, !10, i64 6, !10, i64 8, !6, i64 10, !6, i64 16, !10, i64 18, !10, i64 20, !10, i64 22, !6, i64 24, !6, i64 25, !6, i64 26, !6, i64 27, !6, i64 28, !6, i64 29, !10, i64 32}
!10 = !{!"short", !6, i64 0}
!11 = !{!9, !6, i64 1}
!12 = !{!10, !10, i64 0}
!13 = !{!9, !6, i64 16}
!14 = !{!9, !10, i64 22}
!15 = !{!9, !6, i64 28}
!16 = !{!9, !10, i64 32}


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