; LLVM IR from hit9/bitproto :: example/C (main)

; 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.Drone = type { i8, %struct.Position, %struct.Flight, [4 x %struct.Propeller], %struct.Power, %struct.Network, %struct.LandingGear, %struct.PressureSensor }
%struct.Position = type { i32, i32, i32 }
%struct.Flight = type { %struct.Pose, [3 x i32], [3 x i32] }
%struct.Pose = type { i32, i32, i32 }
%struct.Propeller = type { i8, i8, i8 }
%struct.Power = type { i8, i8, i8 }
%struct.Network = type { i8, i32 }
%struct.LandingGear = type { i8 }
%struct.PressureSensor = type { [2 x i32] }

@.str = external hidden unnamed_addr constant [33 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [64 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.Drone, align 4
  %3 = alloca [67 x i8], align 16
  %4 = alloca %struct.Drone, align 4
  %5 = alloca [512 x i8], align 16
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 88, ptr %2) #5
  call void @llvm.memset.p0.i64(ptr align 4 %2, i8 0, i64 88, i1 false)
  %6 = getelementptr inbounds %struct.Drone, ptr %2, i32 0, i32 0
  store i8 2, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds %struct.Drone, ptr %2, i32 0, i32 1
  %8 = getelementptr inbounds %struct.Position, ptr %7, i32 0, i32 1
  store i32 2000, ptr %8, align 4, !tbaa !18
  %9 = getelementptr inbounds %struct.Drone, ptr %2, i32 0, i32 1
  %10 = getelementptr inbounds %struct.Position, ptr %9, i32 0, i32 0
  store i32 2000, ptr %10, align 4, !tbaa !19
  %11 = getelementptr inbounds %struct.Drone, ptr %2, i32 0, i32 1
  %12 = getelementptr inbounds %struct.Position, ptr %11, i32 0, i32 2
  store i32 1080, ptr %12, align 4, !tbaa !20
  %13 = getelementptr inbounds %struct.Drone, ptr %2, i32 0, i32 2
  %14 = getelementptr inbounds %struct.Flight, ptr %13, i32 0, i32 2
  %15 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 0
  store i32 -1001, ptr %15, align 4, !tbaa !21
  %16 = getelementptr inbounds %struct.Drone, ptr %2, i32 0, i32 4
  %17 = getelementptr inbounds %struct.Power, ptr %16, i32 0, i32 2
  store i8 0, ptr %17, align 2, !tbaa !22
  %18 = getelementptr inbounds %struct.Drone, ptr %2, i32 0, i32 3
  %19 = getelementptr inbounds [4 x %struct.Propeller], ptr %18, i64 0, i64 0
  %20 = getelementptr inbounds %struct.Propeller, ptr %19, i32 0, i32 2
  store i8 1, ptr %20, align 2, !tbaa !23
  %21 = getelementptr inbounds %struct.Drone, ptr %2, i32 0, i32 7
  %22 = getelementptr inbounds %struct.PressureSensor, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds [2 x i32], ptr %22, i64 0, i64 0
  store i32 -11, ptr %23, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 67, ptr %3) #5
  call void @llvm.memset.p0.i64(ptr align 16 %3, i8 0, i64 67, i1 false)
  %24 = getelementptr inbounds [67 x i8], ptr %3, i64 0, i64 0
  %25 = call i32 @EncodeDrone(ptr noundef %2, ptr noundef %24)
  call void @llvm.lifetime.start.p0(i64 88, ptr %4) #5
  call void @llvm.memset.p0.i64(ptr align 4 %4, i8 0, i64 88, i1 false)
  %26 = getelementptr inbounds [67 x i8], ptr %3, i64 0, i64 0
  %27 = call i32 @DecodeDrone(ptr noundef %4, ptr noundef %26)
  %28 = getelementptr inbounds %struct.Drone, ptr %4, i32 0, i32 0
  %29 = load i8, ptr %28, align 4, !tbaa !5
  %30 = zext i8 %29 to i32
  %31 = getelementptr inbounds %struct.Drone, ptr %2, i32 0, i32 0
  %32 = load i8, ptr %31, align 4, !tbaa !5
  %33 = zext i8 %32 to i32
  %34 = icmp eq i32 %30, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %0
  br label %37

36:                                               ; preds = %0
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 27, ptr noundef @__PRETTY_FUNCTION__.main) #6
  unreachable

37:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 512, ptr %5) #5
  call void @llvm.memset.p0.i64(ptr align 16 %5, i8 0, i64 512, i1 false)
  %38 = getelementptr inbounds [512 x i8], ptr %5, i64 0, i64 0
  %39 = call i32 @JsonDrone(ptr noundef %4, ptr noundef %38)
  %40 = getelementptr inbounds [512 x i8], ptr %5, i64 0, i64 0
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %40)
  call void @llvm.lifetime.end.p0(i64 512, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 88, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 67, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 88, ptr %2) #5
  ret i32 0
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare i32 @EncodeDrone(ptr noundef, ptr noundef) #3

declare i32 @DecodeDrone(ptr noundef, ptr noundef) #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

declare i32 @JsonDrone(ptr noundef, ptr noundef) #3

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

; 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { noreturn 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 #5 = { nounwind }
attributes #6 = { noreturn 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 = !{!"Drone", !7, i64 0, !9, i64 4, !11, i64 16, !7, i64 52, !13, i64 64, !15, i64 68, !16, i64 76, !17, i64 80}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"Position", !10, i64 0, !10, i64 4, !10, i64 8}
!10 = !{!"int", !7, i64 0}
!11 = !{!"Flight", !12, i64 0, !7, i64 12, !7, i64 24}
!12 = !{!"Pose", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!"Power", !7, i64 0, !7, i64 1, !14, i64 2}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!"Network", !7, i64 0, !10, i64 4}
!16 = !{!"LandingGear", !7, i64 0}
!17 = !{!"PressureSensor", !7, i64 0}
!18 = !{!6, !10, i64 8}
!19 = !{!6, !10, i64 4}
!20 = !{!6, !10, i64 12}
!21 = !{!10, !10, i64 0}
!22 = !{!6, !14, i64 66}
!23 = !{!24, !7, i64 2}
!24 = !{!"Propeller", !7, i64 0, !7, i64 1, !7, i64 2}


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

%struct.Drone = type { i8, %struct.Position, %struct.Flight, [4 x %struct.Propeller], %struct.Power, %struct.Network, %struct.LandingGear, %struct.PressureSensor }
%struct.Position = type { i32, i32, i32 }
%struct.Flight = type { %struct.Pose, [3 x i32], [3 x i32] }
%struct.Pose = type { i32, i32, i32 }
%struct.Propeller = type { i8, i8, i8 }
%struct.Power = type { i8, i8, i8 }
%struct.Network = type { i8, i32 }
%struct.LandingGear = type { i8 }
%struct.PressureSensor = type { [2 x i32] }

@.str = external hidden unnamed_addr constant [33 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [64 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.Drone, align 4
  %2 = alloca [67 x i8], align 16
  %3 = alloca %struct.Drone, align 4
  %4 = alloca [512 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %1) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(88) %1, i8 0, i64 88, i1 false)
  store i8 2, ptr %1, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 2000, ptr %6, align 4, !tbaa !18
  store i32 2000, ptr %5, align 4, !tbaa !19
  %7 = getelementptr inbounds i8, ptr %1, i64 12
  store i32 1080, ptr %7, align 4, !tbaa !20
  %8 = getelementptr inbounds i8, ptr %1, i64 40
  store i32 -1001, ptr %8, align 4, !tbaa !21
  %9 = getelementptr inbounds i8, ptr %1, i64 54
  store i8 1, ptr %9, align 2, !tbaa !22
  %10 = getelementptr inbounds i8, ptr %1, i64 80
  store i32 -11, ptr %10, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 67, ptr nonnull %2) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(67) %2, i8 0, i64 67, i1 false)
  %11 = call i32 @EncodeDrone(ptr noundef nonnull %1, ptr noundef nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %3) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(88) %3, i8 0, i64 88, i1 false)
  %12 = call i32 @DecodeDrone(ptr noundef nonnull %3, ptr noundef nonnull %2) #6
  %13 = load i8, ptr %3, align 4, !tbaa !5
  %14 = load i8, ptr %1, align 4, !tbaa !5
  %15 = icmp eq i8 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %0
  call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 27, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #7
  unreachable

17:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %4) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(512) %4, i8 0, i64 512, i1 false)
  %18 = call i32 @JsonDrone(ptr noundef nonnull %3, ptr noundef nonnull %4) #6
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull %4)
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 67, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %1) #6
  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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

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

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

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { noreturn 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn 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 = !{!"Drone", !7, i64 0, !9, i64 4, !11, i64 16, !7, i64 52, !13, i64 64, !15, i64 68, !16, i64 76, !17, i64 80}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"Position", !10, i64 0, !10, i64 4, !10, i64 8}
!10 = !{!"int", !7, i64 0}
!11 = !{!"Flight", !12, i64 0, !7, i64 12, !7, i64 24}
!12 = !{!"Pose", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!"Power", !7, i64 0, !7, i64 1, !14, i64 2}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!"Network", !7, i64 0, !10, i64 4}
!16 = !{!"LandingGear", !7, i64 0}
!17 = !{!"PressureSensor", !7, i64 0}
!18 = !{!6, !10, i64 8}
!19 = !{!6, !10, i64 4}
!20 = !{!6, !10, i64 12}
!21 = !{!10, !10, i64 0}
!22 = !{!23, !7, i64 2}
!23 = !{!"Propeller", !7, i64 0, !7, i64 1, !7, i64 2}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass