; LLVM IR from libxsmm/libxsmm :: src (libxsmm_generator)

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

%union.anon.2 = type { ptr }
%struct.libxsmm_meqn_descriptor = type <{ i32, i32, i32, i8, i32 }>

@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_meqn_descriptor_init = external hidden unnamed_addr constant [164 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @libxsmm_meqn_descriptor_init(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #3 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %union.anon.2, align 8
  %14 = alloca i8, align 1
  %15 = alloca ptr, align 8
  %16 = alloca i8, align 1
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  store i32 %5, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 8, i1 false)
  br label %17

17:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #4
  store i8 96, ptr %14, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %18, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #4
  store i8 0, ptr %16, align 1, !tbaa !11
  br label %19

19:                                               ; preds = %30, %17
  %20 = load i8, ptr %16, align 1, !tbaa !11
  %21 = sext i8 %20 to i32
  %22 = load i8, ptr %14, align 1, !tbaa !11
  %23 = sext i8 %22 to i32
  %24 = icmp slt i32 %21, %23
  br i1 %24, label %25, label %33

25:                                               ; preds = %19
  %26 = load ptr, ptr %15, align 8, !tbaa !5
  %27 = load i8, ptr %16, align 1, !tbaa !11
  %28 = sext i8 %27 to i64
  %29 = getelementptr inbounds i8, ptr %26, i64 %28
  store i8 0, ptr %29, align 1, !tbaa !11
  br label %30

30:                                               ; preds = %25
  %31 = load i8, ptr %16, align 1, !tbaa !11
  %32 = add i8 %31, 1
  store i8 %32, ptr %16, align 1, !tbaa !11
  br label %19, !llvm.loop !12

33:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #4
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %36, ptr %13, align 8, !tbaa !11
  %37 = load ptr, ptr %13, align 8, !tbaa !11
  %38 = icmp ne ptr null, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %35
  br label %41

40:                                               ; preds = %35
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 128, ptr noundef @__PRETTY_FUNCTION__.libxsmm_meqn_descriptor_init) #5
  unreachable

41:                                               ; preds = %39
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = icmp eq i32 %42, %43
  br i1 %44, label %45, label %49

45:                                               ; preds = %41
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = trunc i32 %46 to i8
  %48 = zext i8 %47 to i32
  br label %58

49:                                               ; preds = %41
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = shl i32 %51, 4
  %53 = trunc i32 %52 to i8
  %54 = zext i8 %53 to i32
  %55 = or i32 %50, %54
  %56 = trunc i32 %55 to i8
  %57 = zext i8 %56 to i32
  br label %58

58:                                               ; preds = %49, %45
  %59 = phi i32 [ %48, %45 ], [ %57, %49 ]
  %60 = trunc i32 %59 to i8
  %61 = load ptr, ptr %13, align 8, !tbaa !11
  %62 = getelementptr inbounds %struct.libxsmm_meqn_descriptor, ptr %61, i32 0, i32 3
  store i8 %60, ptr %62, align 1, !tbaa !15
  %63 = load i32, ptr %12, align 4, !tbaa !9
  %64 = load ptr, ptr %13, align 8, !tbaa !11
  %65 = getelementptr inbounds %struct.libxsmm_meqn_descriptor, ptr %64, i32 0, i32 4
  store i32 %63, ptr %65, align 1, !tbaa !17
  %66 = load i32, ptr %11, align 4, !tbaa !9
  %67 = load ptr, ptr %13, align 8, !tbaa !11
  %68 = getelementptr inbounds %struct.libxsmm_meqn_descriptor, ptr %67, i32 0, i32 2
  store i32 %66, ptr %68, align 1, !tbaa !18
  %69 = load i32, ptr %9, align 4, !tbaa !9
  %70 = load ptr, ptr %13, align 8, !tbaa !11
  %71 = getelementptr inbounds %struct.libxsmm_meqn_descriptor, ptr %70, i32 0, i32 0
  store i32 %69, ptr %71, align 1, !tbaa !19
  %72 = load i32, ptr %10, align 4, !tbaa !9
  %73 = load ptr, ptr %13, align 8, !tbaa !11
  %74 = getelementptr inbounds %struct.libxsmm_meqn_descriptor, ptr %73, i32 0, i32 1
  store i32 %72, ptr %74, align 1, !tbaa !20
  %75 = load ptr, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret ptr %75
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #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 = { nounwind }
attributes #5 = { 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, !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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13, !14}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!"llvm.loop.unroll.count", i32 4}
!15 = !{!16, !7, i64 12}
!16 = !{!"libxsmm_meqn_descriptor", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12, !10, i64 13}
!17 = !{!16, !10, i64 13}
!18 = !{!16, !10, i64 8}
!19 = !{!16, !10, i64 0}
!20 = !{!16, !10, i64 4}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local noundef ptr @libxsmm_meqn_descriptor_init(ptr noundef returned writeonly %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = getelementptr inbounds i8, ptr %0, i64 17
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(96) %7, i8 0, i64 79, i1 false), !tbaa !5
  %8 = trunc i32 %1 to i8
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  store i8 %8, ptr %9, align 1, !tbaa !8
  %10 = getelementptr inbounds i8, ptr %0, i64 13
  store i32 %5, ptr %10, align 1, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %4, ptr %11, align 1, !tbaa !12
  store i32 %2, ptr %0, align 1, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %3, ptr %12, align 1, !tbaa !14
  ret ptr %0
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !6, i64 12}
!9 = !{!"libxsmm_meqn_descriptor", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 12, !10, i64 13}
!10 = !{!"int", !6, i64 0}
!11 = !{!9, !10, i64 13}
!12 = !{!9, !10, i64 8}
!13 = !{!9, !10, i64 0}
!14 = !{!9, !10, i64 4}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopIdiomRecognizePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass