; LLVM IR from unitreerobotics/kinect_teleoperate :: src/mujoco-3.1.5/sample/record.ll (Z10initMuJoCoPKc)

; 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.mjvScene_ = type { i32, i32, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, i32, ptr, ptr, ptr, ptr, ptr, i32, [100 x %struct.mjvLight_], [2 x %struct.mjvGLCamera_], i8, [3 x float], [4 x float], float, i32, [10 x i8], i32, [3 x float] }
%struct.mjvLight_ = type { [3 x float], [3 x float], [3 x float], float, float, [3 x float], [3 x float], [3 x float], i8, i8, i8, float }
%struct.mjvGLCamera_ = type { [3 x float], [3 x float], [3 x float], float, float, float, float, float, float }
%struct.mjvCamera_ = type { i32, i32, i32, [3 x double], double, double, double }
%struct.mjvOption_ = type { i32, i32, [6 x i8], [6 x i8], [6 x i8], [6 x i8], [6 x i8], [6 x i8], [6 x i8], [32 x i8], i32, i32 }
%struct.mjrContext_ = type { float, float, float, float, float, [4 x float], i32, i32, i32, i32, i32, [10 x i32], [10 x i32], [10 x i32], i32, i32, i32, i32, i32, i32, i32, i32, [10 x i32], [10 x i32], [10 x i32], [10 x i32], i32, [100 x i32], [100 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, [127 x i32], [127 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@m = external dso_local global ptr, align 8
@d = external dso_local global ptr, align 8
@scn = external dso_local global %struct.mjvScene_, align 8
@cam = external dso_local global %struct.mjvCamera_, align 8
@opt = external dso_local global %struct.mjvOption_, align 4
@con = external dso_local global %struct.mjrContext_, align 8
@__const._Z10initMuJoCoPKc.error = external hidden unnamed_addr constant [1000 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10initMuJoCoPKc(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca [1000 x i8], align 16
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1000, ptr %3) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %3, ptr align 16 @__const._Z10initMuJoCoPKc.error, i64 1000, i1 false)
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = call i64 @strlen(ptr noundef %4) #6
  %6 = icmp ugt i64 %5, 4
  br i1 %6, label %7, label %18

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = call i64 @strlen(ptr noundef %9) #6
  %11 = getelementptr inbounds i8, ptr %8, i64 %10
  %12 = getelementptr inbounds i8, ptr %11, i64 -4
  %13 = call i32 @strcmp(ptr noundef %12, ptr noundef @.str) #6
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %18, label %15

15:                                               ; preds = %7
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = call ptr @mj_loadModel(ptr noundef %16, ptr noundef null)
  store ptr %17, ptr @m, align 8, !tbaa !5
  br label %22

18:                                               ; preds = %7, %1
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds [1000 x i8], ptr %3, i64 0, i64 0
  %21 = call ptr @mj_loadXML(ptr noundef %19, ptr noundef null, ptr noundef %20, i32 noundef 1000)
  store ptr %21, ptr @m, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %18, %15
  %23 = load ptr, ptr @m, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %27, label %25

25:                                               ; preds = %22
  %26 = getelementptr inbounds [1000 x i8], ptr %3, i64 0, i64 0
  call void (ptr, ...) @mju_error(ptr noundef @.str.1, ptr noundef %26)
  br label %27

27:                                               ; preds = %25, %22
  %28 = load ptr, ptr @m, align 8, !tbaa !5
  %29 = call ptr @mj_makeData(ptr noundef %28)
  store ptr %29, ptr @d, align 8, !tbaa !5
  %30 = load ptr, ptr @m, align 8, !tbaa !5
  %31 = load ptr, ptr @d, align 8, !tbaa !5
  call void @mj_forward(ptr noundef %30, ptr noundef %31)
  call void @mjv_defaultCamera(ptr noundef @cam)
  call void @mjv_defaultOption(ptr noundef @opt)
  call void @mjv_defaultScene(ptr noundef @scn)
  call void @mjr_defaultContext(ptr noundef @con)
  %32 = load ptr, ptr @m, align 8, !tbaa !5
  call void @mjv_makeScene(ptr noundef %32, ptr noundef @scn, i32 noundef 2000)
  %33 = load ptr, ptr @m, align 8, !tbaa !5
  call void @mjr_makeContext(ptr noundef %33, ptr noundef @con, i32 noundef 200)
  %34 = load ptr, ptr @m, align 8, !tbaa !5
  call void @mjv_defaultFreeCamera(ptr noundef %34, ptr noundef @cam)
  call void @llvm.lifetime.end.p0(i64 1000, ptr %3) #5
  ret void
}

; 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

declare ptr @mj_loadModel(ptr noundef, ptr noundef) #4

declare ptr @mj_loadXML(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #4

declare void @mju_error(ptr noundef, ...) #4

declare ptr @mj_makeData(ptr noundef) #4

declare void @mj_forward(ptr noundef, ptr noundef) #4

declare void @mjv_defaultCamera(ptr noundef) #4

declare void @mjv_defaultOption(ptr noundef) #4

declare void @mjv_defaultScene(ptr noundef) #4

declare void @mjr_defaultContext(ptr noundef) #4

declare void @mjv_makeScene(ptr noundef, ptr noundef, i32 noundef) #4

declare void @mjr_makeContext(ptr noundef, ptr noundef, i32 noundef) #4

declare void @mjv_defaultFreeCamera(ptr noundef, ptr noundef) #4

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

attributes #0 = { mustprogress 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: readwrite) }
attributes #3 = { nounwind willreturn memory(read) "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 = { "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 = { nounwind willreturn memory(read) }

!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++ TBAA"}


; 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.mjvScene_ = type { i32, i32, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, i32, ptr, ptr, ptr, ptr, ptr, i32, [100 x %struct.mjvLight_], [2 x %struct.mjvGLCamera_], i8, [3 x float], [4 x float], float, i32, [10 x i8], i32, [3 x float] }
%struct.mjvLight_ = type { [3 x float], [3 x float], [3 x float], float, float, [3 x float], [3 x float], [3 x float], i8, i8, i8, float }
%struct.mjvGLCamera_ = type { [3 x float], [3 x float], [3 x float], float, float, float, float, float, float }
%struct.mjvCamera_ = type { i32, i32, i32, [3 x double], double, double, double }
%struct.mjvOption_ = type { i32, i32, [6 x i8], [6 x i8], [6 x i8], [6 x i8], [6 x i8], [6 x i8], [6 x i8], [32 x i8], i32, i32 }
%struct.mjrContext_ = type { float, float, float, float, float, [4 x float], i32, i32, i32, i32, i32, [10 x i32], [10 x i32], [10 x i32], i32, i32, i32, i32, i32, i32, i32, i32, [10 x i32], [10 x i32], [10 x i32], [10 x i32], i32, [100 x i32], [100 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, [127 x i32], [127 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@m = external dso_local local_unnamed_addr global ptr, align 8
@d = external dso_local local_unnamed_addr global ptr, align 8
@scn = external dso_local global %struct.mjvScene_, align 8
@cam = external dso_local global %struct.mjvCamera_, align 8
@opt = external dso_local global %struct.mjvOption_, align 4
@con = external dso_local global %struct.mjrContext_, align 8
@__const._Z10initMuJoCoPKc.error = external hidden unnamed_addr constant [1000 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10initMuJoCoPKc(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca [1000 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 1000, ptr nonnull %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(1000) %2, ptr noundef nonnull align 16 dereferenceable(1000) @__const._Z10initMuJoCoPKc.error, i64 1000, i1 false)
  %3 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #6
  %4 = icmp ugt i64 %3, 4
  br i1 %4, label %5, label %11

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 %3
  %7 = getelementptr inbounds i8, ptr %6, i64 -4
  %8 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) @.str) #6
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %11

9:                                                ; preds = %5
  %10 = tail call ptr @mj_loadModel(ptr noundef %0, ptr noundef null)
  br label %13

11:                                               ; preds = %5, %1
  %12 = call ptr @mj_loadXML(ptr noundef %0, ptr noundef null, ptr noundef nonnull %2, i32 noundef 1000)
  br label %13

13:                                               ; preds = %11, %9
  %storemerge = phi ptr [ %10, %9 ], [ %12, %11 ]
  store ptr %storemerge, ptr @m, align 8, !tbaa !5
  %.not5 = icmp eq ptr %storemerge, null
  br i1 %.not5, label %14, label %15

14:                                               ; preds = %13
  call void (ptr, ...) @mju_error(ptr noundef nonnull @.str.1, ptr noundef nonnull %2)
  %.pre = load ptr, ptr @m, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %14, %13
  %16 = phi ptr [ %.pre, %14 ], [ %storemerge, %13 ]
  %17 = call ptr @mj_makeData(ptr noundef %16)
  store ptr %17, ptr @d, align 8, !tbaa !5
  %18 = load ptr, ptr @m, align 8, !tbaa !5
  call void @mj_forward(ptr noundef %18, ptr noundef %17)
  call void @mjv_defaultCamera(ptr noundef nonnull @cam)
  call void @mjv_defaultOption(ptr noundef nonnull @opt)
  call void @mjv_defaultScene(ptr noundef nonnull @scn)
  call void @mjr_defaultContext(ptr noundef nonnull @con)
  %19 = load ptr, ptr @m, align 8, !tbaa !5
  call void @mjv_makeScene(ptr noundef %19, ptr noundef nonnull @scn, i32 noundef 2000)
  %20 = load ptr, ptr @m, align 8, !tbaa !5
  call void @mjr_makeContext(ptr noundef %20, ptr noundef nonnull @con, i32 noundef 200)
  %21 = load ptr, ptr @m, align 8, !tbaa !5
  call void @mjv_defaultFreeCamera(ptr noundef %21, ptr noundef nonnull @cam)
  call void @llvm.lifetime.end.p0(i64 1000, ptr nonnull %2) #5
  ret void
}

; 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3

declare ptr @mj_loadModel(ptr noundef, ptr noundef) local_unnamed_addr #4

declare ptr @mj_loadXML(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

declare void @mju_error(ptr noundef, ...) local_unnamed_addr #4

declare ptr @mj_makeData(ptr noundef) local_unnamed_addr #4

declare void @mj_forward(ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @mjv_defaultCamera(ptr noundef) local_unnamed_addr #4

declare void @mjv_defaultOption(ptr noundef) local_unnamed_addr #4

declare void @mjv_defaultScene(ptr noundef) local_unnamed_addr #4

declare void @mjr_defaultContext(ptr noundef) local_unnamed_addr #4

declare void @mjv_makeScene(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

declare void @mjr_makeContext(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

declare void @mjv_defaultFreeCamera(ptr noundef, ptr noundef) local_unnamed_addr #4

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

attributes #0 = { mustprogress 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: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { "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 = { nounwind willreturn memory(read) }

!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++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass