; LLVM IR from aap/librw :: src/skin.ll (ZN2rw4Skin4initEiii)

; 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.rw::Skin" = type { i32, i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32 }

@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1

; 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: mustprogress uwtable
define dso_local void @_ZN2rw4Skin4initEiii(ptr noundef nonnull align 8 dereferenceable(112) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 0
  store i32 %12, ptr %13, align 8, !tbaa !11
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 1
  store i32 %14, ptr %15, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %16 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 1
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %18 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = mul nsw i32 %19, 64
  %21 = add nsw i32 %17, %20
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = mul nsw i32 %22, 20
  %24 = add nsw i32 %21, %23
  %25 = add nsw i32 %24, 15
  store i32 %25, ptr %9, align 4, !tbaa !9
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  %28 = mul i64 %27, 1
  %29 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %28, i32 noundef 196886, ptr noundef @.str.1)
  %30 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 13
  store ptr %29, ptr %30, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %31 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 13
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  store ptr %32, ptr %10, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 3
  store ptr null, ptr %33, align 8, !tbaa !15
  %34 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 1
  %35 = load i32, ptr %34, align 4, !tbaa !13
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %45

37:                                               ; preds = %4
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 3
  store ptr %38, ptr %39, align 8, !tbaa !15
  %40 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 1
  %41 = load i32, ptr %40, align 4, !tbaa !13
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = sext i32 %41 to i64
  %44 = getelementptr inbounds i8, ptr %42, i64 %43
  store ptr %44, ptr %10, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %37, %4
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = ptrtoint ptr %46 to i64
  %48 = add i64 %47, 15
  %49 = and i64 %48, -16
  %50 = inttoptr i64 %49 to ptr
  store ptr %50, ptr %10, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 4
  store ptr null, ptr %51, align 8, !tbaa !16
  %52 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !11
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %64

55:                                               ; preds = %45
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 4
  store ptr %56, ptr %57, align 8, !tbaa !16
  %58 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 0
  %59 = load i32, ptr %58, align 8, !tbaa !11
  %60 = mul nsw i32 64, %59
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = sext i32 %60 to i64
  %63 = getelementptr inbounds i8, ptr %61, i64 %62
  store ptr %63, ptr %10, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %55, %45
  %65 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 5
  store ptr null, ptr %65, align 8, !tbaa !17
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %76

68:                                               ; preds = %64
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  %70 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 5
  store ptr %69, ptr %70, align 8, !tbaa !17
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = mul nsw i32 4, %71
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = sext i32 %72 to i64
  %75 = getelementptr inbounds i8, ptr %73, i64 %74
  store ptr %75, ptr %10, align 8, !tbaa !5
  br label %76

76:                                               ; preds = %68, %64
  %77 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 6
  store ptr null, ptr %77, align 8, !tbaa !18
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %83

80:                                               ; preds = %76
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 6
  store ptr %81, ptr %82, align 8, !tbaa !18
  br label %83

83:                                               ; preds = %80, %76
  %84 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 7
  store i32 0, ptr %84, align 8, !tbaa !19
  %85 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 8
  store i32 0, ptr %85, align 4, !tbaa !20
  %86 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 9
  store i32 0, ptr %86, align 8, !tbaa !21
  %87 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 10
  store ptr null, ptr %87, align 8, !tbaa !22
  %88 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 11
  store ptr null, ptr %88, align 8, !tbaa !23
  %89 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 12
  store ptr null, ptr %89, align 8, !tbaa !24
  %90 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 14
  store ptr null, ptr %90, align 8, !tbaa !25
  %91 = getelementptr inbounds %"struct.rw::Skin", ptr %11, i32 0, i32 15
  store i32 0, ptr %91, align 8, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN2rw4SkinE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !10, i64 104}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !6, i64 88}
!15 = !{!12, !6, i64 16}
!16 = !{!12, !6, i64 24}
!17 = !{!12, !6, i64 32}
!18 = !{!12, !6, i64 40}
!19 = !{!12, !10, i64 48}
!20 = !{!12, !10, i64 52}
!21 = !{!12, !10, i64 56}
!22 = !{!12, !6, i64 64}
!23 = !{!12, !6, i64 72}
!24 = !{!12, !6, i64 80}
!25 = !{!12, !6, i64 96}
!26 = !{!12, !10, i64 104}


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

@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw4Skin4initEiii(ptr nocapture noundef nonnull align 8 dereferenceable(112) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 align 2 {
  store i32 %1, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %2, ptr %5, align 4, !tbaa !11
  %6 = shl nsw i32 %1, 6
  %7 = mul nsw i32 %3, 20
  %8 = add i32 %2, 15
  %9 = add i32 %8, %6
  %10 = add i32 %9, %7
  %11 = zext i32 %10 to i64
  %12 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %11, i32 noundef 196886, ptr noundef nonnull @.str.1)
  %13 = getelementptr inbounds i8, ptr %0, i64 88
  store ptr %12, ptr %13, align 8, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr null, ptr %14, align 8, !tbaa !13
  %15 = load i32, ptr %5, align 4, !tbaa !11
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %19, label %16

16:                                               ; preds = %4
  store ptr %12, ptr %14, align 8, !tbaa !13
  %17 = sext i32 %15 to i64
  %18 = getelementptr inbounds i8, ptr %12, i64 %17
  br label %19

19:                                               ; preds = %16, %4
  %.0 = phi ptr [ %18, %16 ], [ %12, %4 ]
  %20 = ptrtoint ptr %.0 to i64
  %21 = add i64 %20, 15
  %22 = and i64 %21, -16
  %23 = inttoptr i64 %22 to ptr
  %24 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr null, ptr %24, align 8, !tbaa !14
  %25 = load i32, ptr %0, align 8, !tbaa !5
  %.not16 = icmp eq i32 %25, 0
  br i1 %.not16, label %30, label %26

26:                                               ; preds = %19
  store ptr %23, ptr %24, align 8, !tbaa !14
  %27 = shl nsw i32 %25, 6
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %23, i64 %28
  br label %30

30:                                               ; preds = %26, %19
  %.1 = phi ptr [ %29, %26 ], [ %23, %19 ]
  %31 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr null, ptr %31, align 8, !tbaa !15
  %.not17 = icmp eq i32 %3, 0
  br i1 %.not17, label %36, label %32

32:                                               ; preds = %30
  store ptr %.1, ptr %31, align 8, !tbaa !15
  %33 = shl nsw i32 %3, 2
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i8, ptr %.1, i64 %34
  br label %36

36:                                               ; preds = %32, %30
  %spec.select = phi ptr [ %35, %32 ], [ null, %30 ]
  %37 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %spec.select, ptr %37, align 8, !tbaa !16
  %38 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 0, ptr %38, align 8, !tbaa !17
  %39 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 0, ptr %39, align 4, !tbaa !18
  %40 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 0, ptr %40, align 8, !tbaa !19
  %41 = getelementptr inbounds i8, ptr %0, i64 64
  %42 = getelementptr inbounds i8, ptr %0, i64 96
  store ptr null, ptr %42, align 8, !tbaa !20
  %43 = getelementptr inbounds i8, ptr %0, i64 104
  store i32 0, ptr %43, align 8, !tbaa !21
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %41, i8 0, i64 24, i1 false)
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

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 = { inlinehint 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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 = !{!"_ZTSN2rw4SkinE", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !7, i64 48, !7, i64 52, !7, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !7, i64 104}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !10, i64 88}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !10, i64 24}
!15 = !{!6, !10, i64 32}
!16 = !{!6, !10, i64 40}
!17 = !{!6, !7, i64 48}
!18 = !{!6, !7, i64 52}
!19 = !{!6, !7, i64 56}
!20 = !{!6, !10, i64 96}
!21 = !{!6, !7, i64 104}


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