; LLVM IR from mlcommons/tiny :: benchmark/interface/Drivers/BSP/Components/ft6x06 (ft6x06)

; 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.FT6X06_MultiTouch_State_t = type { i32, [2 x i32], [2 x i32], [2 x i32], [2 x i32], [2 x i32] }
%struct.FT6X06_Object_t = type { %struct.FT6X06_IO_t, %struct.ft6x06_ctx_t, i8 }
%struct.FT6X06_IO_t = type { ptr, ptr, i16, ptr, ptr, ptr }
%struct.ft6x06_ctx_t = type { ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @FT6X06_GetMultiTouchState(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca [12 x i8], align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 12, ptr %6) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = call i32 @FT6X06_DetectTouch(ptr noundef %7)
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.FT6X06_MultiTouch_State_t, ptr %9, i32 0, i32 0
  store i32 %8, ptr %10, align 4, !tbaa !11
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.FT6X06_Object_t, ptr %11, i32 0, i32 1
  %13 = getelementptr inbounds [12 x i8], ptr %6, i64 0, i64 0
  %14 = call i32 @ft6x06_read_reg(ptr noundef %12, i8 noundef zeroext 3, ptr noundef %13, i16 noundef zeroext 12)
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %2
  store i32 -1, ptr %5, align 4, !tbaa !9
  br label %116

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

116:                                              ; preds = %17, %16
  %117 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 12, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %117
}

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @FT6X06_DetectTouch(ptr noundef) #0

declare i32 @ft6x06_read_reg(ptr noundef, i8 noundef zeroext, ptr noundef, i16 noundef zeroext) #2

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 }

!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 0}
!12 = !{!"", !10, i64 0, !7, i64 4, !7, i64 12, !7, i64 20, !7, i64 28, !7, i64 36}
!13 = !{!7, !7, i64 0}


; 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 range(i32 -1, 1) i32 @FT6X06_GetMultiTouchState(ptr noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %3 = alloca [12 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #3
  %4 = tail call i32 @FT6X06_DetectTouch(ptr noundef %0)
  store i32 %4, ptr %1, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = call i32 @ft6x06_read_reg(ptr noundef nonnull %5, i8 noundef zeroext 3, ptr noundef nonnull %3, i16 noundef zeroext 12) #3
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %69

7:                                                ; preds = %2
  %8 = load i8, ptr %3, align 1, !tbaa !10
  %9 = and i8 %8, 15
  %10 = zext nneg i8 %9 to i32
  %11 = shl nuw nsw i32 %10, 8
  %12 = getelementptr inbounds i8, ptr %3, i64 1
  %13 = load i8, ptr %12, align 1, !tbaa !10
  %14 = zext i8 %13 to i32
  %15 = or disjoint i32 %11, %14
  %16 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 %15, ptr %16, align 4, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %3, i64 2
  %18 = load i8, ptr %17, align 1, !tbaa !10
  %19 = and i8 %18, 15
  %20 = zext nneg i8 %19 to i32
  %21 = shl nuw nsw i32 %20, 8
  %22 = getelementptr inbounds i8, ptr %3, i64 3
  %23 = load i8, ptr %22, align 1, !tbaa !10
  %24 = zext i8 %23 to i32
  %25 = or disjoint i32 %21, %24
  %26 = getelementptr inbounds i8, ptr %1, i64 12
  store i32 %25, ptr %26, align 4, !tbaa !11
  %27 = getelementptr inbounds i8, ptr %1, i64 28
  %28 = getelementptr inbounds i8, ptr %3, i64 4
  %29 = load i8, ptr %28, align 1, !tbaa !10
  %30 = zext i8 %29 to i32
  %31 = getelementptr inbounds i8, ptr %1, i64 20
  store i32 %30, ptr %31, align 4, !tbaa !11
  %32 = getelementptr inbounds i8, ptr %3, i64 5
  %33 = load i8, ptr %32, align 1, !tbaa !10
  %34 = getelementptr inbounds i8, ptr %1, i64 36
  %35 = getelementptr inbounds i8, ptr %3, i64 6
  %36 = load i8, ptr %35, align 1, !tbaa !10
  %37 = and i8 %36, 15
  %38 = zext nneg i8 %37 to i32
  %39 = shl nuw nsw i32 %38, 8
  %40 = getelementptr inbounds i8, ptr %3, i64 7
  %41 = load i8, ptr %40, align 1, !tbaa !10
  %42 = zext i8 %41 to i32
  %43 = or disjoint i32 %39, %42
  %44 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 %43, ptr %44, align 4, !tbaa !11
  %45 = getelementptr inbounds i8, ptr %3, i64 8
  %46 = load i8, ptr %45, align 1, !tbaa !10
  %47 = and i8 %46, 15
  %48 = zext nneg i8 %47 to i32
  %49 = shl nuw nsw i32 %48, 8
  %50 = getelementptr inbounds i8, ptr %3, i64 9
  %51 = load i8, ptr %50, align 1, !tbaa !10
  %52 = zext i8 %51 to i32
  %53 = or disjoint i32 %49, %52
  %54 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 %53, ptr %54, align 4, !tbaa !11
  %55 = insertelement <2 x i8> poison, i8 %8, i64 0
  %56 = insertelement <2 x i8> %55, i8 %36, i64 1
  %57 = lshr <2 x i8> %56, <i8 6, i8 6>
  %58 = zext nneg <2 x i8> %57 to <2 x i32>
  store <2 x i32> %58, ptr %27, align 4, !tbaa !11
  %59 = getelementptr inbounds i8, ptr %3, i64 10
  %60 = load i8, ptr %59, align 1, !tbaa !10
  %61 = zext i8 %60 to i32
  %62 = getelementptr inbounds i8, ptr %1, i64 24
  store i32 %61, ptr %62, align 4, !tbaa !11
  %63 = getelementptr inbounds i8, ptr %3, i64 11
  %64 = load i8, ptr %63, align 1, !tbaa !10
  %65 = insertelement <2 x i8> poison, i8 %33, i64 0
  %66 = insertelement <2 x i8> %65, i8 %64, i64 1
  %67 = lshr <2 x i8> %66, <i8 4, i8 4>
  %68 = zext nneg <2 x i8> %67 to <2 x i32>
  store <2 x i32> %68, ptr %34, align 4, !tbaa !11
  br label %69

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @FT6X06_DetectTouch(ptr noundef) local_unnamed_addr #0

declare i32 @ft6x06_read_reg(ptr noundef, i8 noundef zeroext, ptr noundef, i16 noundef zeroext) local_unnamed_addr #2

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

!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 = !{!"", !7, i64 0, !8, i64 4, !8, i64 12, !8, i64 20, !8, i64 28, !8, i64 36}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!7, !7, i64 0}


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