; LLVM IR from bhaskar0120/simple-render :: main (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.Shape = type { %struct.Vector, %struct.Vector, float, float, float, [3 x i8], ptr, ptr }
%struct.Vector = type { float, float, float }
%struct.Scene = type { [256 x %struct.Shape], i64, %struct.Vector, %struct.Vector, [3 x i8] }

@__const.main.sphere = external hidden unnamed_addr constant %struct.Shape, align 8
@__const.main.plane = external hidden unnamed_addr constant %struct.Shape, align 8
@__const.main.capsule = external hidden unnamed_addr constant %struct.Shape, align 8
@__const.main.torus = external hidden unnamed_addr constant %struct.Shape, align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local void @render(ptr noundef, i32 noundef, i32 noundef, ptr noundef byval(%struct.Scene) align 8) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @convert_to_big_endian(i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.Shape, align 8
  %3 = alloca %struct.Shape, align 8
  %4 = alloca %struct.Shape, align 8
  %5 = alloca %struct.Shape, align 8
  %6 = alloca %struct.Scene, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 56, ptr %2) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %2, ptr align 8 @__const.main.sphere, i64 56, i1 false)
  call void @llvm.lifetime.start.p0(i64 56, ptr %3) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %3, ptr align 8 @__const.main.plane, i64 56, i1 false)
  call void @llvm.lifetime.start.p0(i64 56, ptr %4) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 @__const.main.capsule, i64 56, i1 false)
  call void @llvm.lifetime.start.p0(i64 56, ptr %5) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 @__const.main.torus, i64 56, i1 false)
  call void @llvm.lifetime.start.p0(i64 14376, ptr %6) #7
  call void @llvm.memset.p0.i64(ptr align 8 %6, i8 0, i64 14376, i1 false)
  %13 = getelementptr inbounds %struct.Scene, ptr %6, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %2, i64 56, i1 false), !tbaa.struct !5
  %14 = getelementptr inbounds %struct.Shape, ptr %13, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %3, i64 56, i1 false), !tbaa.struct !5
  %15 = getelementptr inbounds %struct.Shape, ptr %13, i64 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %4, i64 56, i1 false), !tbaa.struct !5
  %16 = getelementptr inbounds %struct.Shape, ptr %13, i64 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %5, i64 56, i1 false), !tbaa.struct !5
  %17 = getelementptr inbounds %struct.Scene, ptr %6, i32 0, i32 1
  store i64 4, ptr %17, align 8, !tbaa !13
  %18 = getelementptr inbounds %struct.Scene, ptr %6, i32 0, i32 2
  %19 = getelementptr inbounds %struct.Vector, ptr %18, i32 0, i32 0
  store float -5.000000e+00, ptr %19, align 8, !tbaa !17
  %20 = getelementptr inbounds %struct.Vector, ptr %18, i32 0, i32 1
  store float 5.000000e+00, ptr %20, align 4, !tbaa !18
  %21 = getelementptr inbounds %struct.Vector, ptr %18, i32 0, i32 2
  store float -1.000000e+00, ptr %21, align 8, !tbaa !19
  %22 = getelementptr inbounds %struct.Scene, ptr %6, i32 0, i32 3
  %23 = getelementptr inbounds %struct.Vector, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.Vector, ptr %22, i32 0, i32 1
  %25 = getelementptr inbounds %struct.Vector, ptr %22, i32 0, i32 2
  %26 = getelementptr inbounds %struct.Scene, ptr %6, i32 0, i32 4
  %27 = getelementptr inbounds i8, ptr %26, i64 1
  %28 = getelementptr inbounds i8, ptr %26, i64 2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 800, ptr %7, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 600, ptr %8, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %29 = load i32, ptr %8, align 4, !tbaa !20
  %30 = load i32, ptr %7, align 4, !tbaa !20
  %31 = mul nsw i32 %29, %30
  %32 = mul nsw i32 %31, 3
  %33 = sext i32 %32 to i64
  %34 = call noalias ptr @malloc(i64 noundef %33) #8
  store ptr %34, ptr %9, align 8, !tbaa !11
  %35 = load ptr, ptr %9, align 8, !tbaa !11
  %36 = load i32, ptr %8, align 4, !tbaa !20
  %37 = load i32, ptr %7, align 4, !tbaa !20
  call void @render(ptr noundef %35, i32 noundef %36, i32 noundef %37, ptr noundef byval(%struct.Scene) align 8 %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %38 = load i32, ptr %7, align 4, !tbaa !20
  %39 = call i32 @convert_to_big_endian(i32 noundef %38)
  store i32 %39, ptr %10, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %40 = load i32, ptr %8, align 4, !tbaa !20
  %41 = call i32 @convert_to_big_endian(i32 noundef %40)
  store i32 %41, ptr %11, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %42 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.1)
  store ptr %42, ptr %12, align 8, !tbaa !11
  %43 = load ptr, ptr %12, align 8, !tbaa !11
  %44 = call i64 @fwrite(ptr noundef %11, i64 noundef 4, i64 noundef 1, ptr noundef %43)
  %45 = load ptr, ptr %12, align 8, !tbaa !11
  %46 = call i64 @fwrite(ptr noundef %10, i64 noundef 4, i64 noundef 1, ptr noundef %45)
  %47 = load ptr, ptr %9, align 8, !tbaa !11
  %48 = load i32, ptr %7, align 4, !tbaa !20
  %49 = load i32, ptr %8, align 4, !tbaa !20
  %50 = mul nsw i32 %48, %49
  %51 = mul nsw i32 %50, 3
  %52 = sext i32 %51 to i64
  %53 = load ptr, ptr %12, align 8, !tbaa !11
  %54 = call i64 @fwrite(ptr noundef %47, i64 noundef 1, i64 noundef %52, ptr noundef %53)
  %55 = load ptr, ptr %12, align 8, !tbaa !11
  %56 = call i32 @fclose(ptr noundef %55)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 14376, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 56, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 56, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 56, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 56, ptr %2) #7
  ret i32 0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #5

declare noalias ptr @fopen(ptr noundef, ptr noundef) #6

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #6

declare i32 @fclose(ptr noundef) #6

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="64" "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 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind allocsize(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 #6 = { "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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6, i64 12, i64 4, !6, i64 16, i64 4, !6, i64 20, i64 4, !6, i64 24, i64 4, !6, i64 28, i64 4, !6, i64 32, i64 4, !6, i64 36, i64 3, !10, i64 40, i64 8, !11, i64 48, i64 8, !11}
!6 = !{!7, !7, i64 0}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !15, i64 14336}
!14 = !{!"Scene", !8, i64 0, !15, i64 14336, !16, i64 14344, !16, i64 14356, !8, i64 14368}
!15 = !{!"long", !8, i64 0}
!16 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!17 = !{!16, !7, i64 0}
!18 = !{!16, !7, i64 4}
!19 = !{!16, !7, i64 8}
!20 = !{!21, !21, i64 0}
!21 = !{!"int", !8, 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"

%struct.Shape = type { %struct.Vector, %struct.Vector, float, float, float, [3 x i8], ptr, ptr }
%struct.Vector = type { float, float, float }
%struct.Scene = type { [256 x %struct.Shape], i64, %struct.Vector, %struct.Vector, [3 x i8] }

@__const.main.sphere = external hidden unnamed_addr constant %struct.Shape, align 8
@__const.main.plane = external hidden unnamed_addr constant %struct.Shape, align 8
@__const.main.capsule = external hidden unnamed_addr constant %struct.Shape, align 8
@__const.main.torus = external hidden unnamed_addr constant %struct.Shape, align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress 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) #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 dso_local void @render(ptr noundef, i32 noundef, i32 noundef, ptr noundef byval(%struct.Scene) align 8) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @convert_to_big_endian(i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca %struct.Scene, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 14376, ptr nonnull %1) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %1, ptr noundef nonnull align 8 dereferenceable(56) @__const.main.sphere, i64 56, i1 false), !tbaa.struct !5
  %4 = getelementptr inbounds i8, ptr %1, i64 56
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %4, ptr noundef nonnull align 8 dereferenceable(56) @__const.main.plane, i64 56, i1 false), !tbaa.struct !5
  %5 = getelementptr inbounds i8, ptr %1, i64 112
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %5, ptr noundef nonnull align 8 dereferenceable(56) @__const.main.capsule, i64 56, i1 false), !tbaa.struct !5
  %6 = getelementptr inbounds i8, ptr %1, i64 168
  %7 = getelementptr inbounds i8, ptr %1, i64 224
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(14152) %7, i8 0, i64 14152, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %6, ptr noundef nonnull align 8 dereferenceable(56) @__const.main.torus, i64 56, i1 false), !tbaa.struct !5
  %8 = getelementptr inbounds i8, ptr %1, i64 14336
  store i64 4, ptr %8, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %1, i64 14344
  store <2 x float> <float -5.000000e+00, float 5.000000e+00>, ptr %9, align 8, !tbaa !6
  %10 = getelementptr inbounds i8, ptr %1, i64 14352
  store float -1.000000e+00, ptr %10, align 8, !tbaa !17
  %11 = tail call noalias dereferenceable_or_null(1440000) ptr @malloc(i64 noundef 1440000) #8
  tail call void @render(ptr noundef %11, i32 noundef 600, i32 noundef 800, ptr noundef nonnull byval(%struct.Scene) align 8 %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %12 = tail call i32 @convert_to_big_endian(i32 noundef 800)
  store i32 %12, ptr %2, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %13 = tail call i32 @convert_to_big_endian(i32 noundef 600)
  store i32 %13, ptr %3, align 4, !tbaa !18
  %14 = tail call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1)
  %15 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 4, i64 noundef 1, ptr noundef %14)
  %16 = call i64 @fwrite(ptr noundef nonnull %2, i64 noundef 4, i64 noundef 1, ptr noundef %14)
  %17 = tail call i64 @fwrite(ptr noundef %11, i64 noundef 1, i64 noundef 1440000, ptr noundef %14)
  %18 = tail call i32 @fclose(ptr noundef %14)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 14376, ptr nonnull %1) #7
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #6

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #6

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #6

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="64" "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 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6, i64 12, i64 4, !6, i64 16, i64 4, !6, i64 20, i64 4, !6, i64 24, i64 4, !6, i64 28, i64 4, !6, i64 32, i64 4, !6, i64 36, i64 3, !10, i64 40, i64 8, !11, i64 48, i64 8, !11}
!6 = !{!7, !7, i64 0}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !15, i64 14336}
!14 = !{!"Scene", !8, i64 0, !15, i64 14336, !16, i64 14344, !16, i64 14356, !8, i64 14368}
!15 = !{!"long", !8, i64 0}
!16 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!17 = !{!16, !7, i64 8}
!18 = !{!19, !19, i64 0}
!19 = !{!"int", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass