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

; 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.libxsmm_meqn_info = type { %struct.libxsmm_meqn_arg }
%struct.libxsmm_meqn_arg = type { i32, i32, i32, i32, i32, i32, i32, %struct.libxsmm_matrix_arg_attributes }
%struct.libxsmm_matrix_arg_attributes = type { i32, i32, i32, i32 }
%struct.libxsmm_meqn_op_metadata = type { i32, i32 }
%struct.libxsmm_matrix_eqn = type { ptr, ptr, i32, i32, i32, i32 }
%struct.libxsmm_meqn_binary_op = type { i32, i32, i32, i32, i32, i32 }

@libxsmm_matrix_eqns = external dso_local global [4096 x ptr], align 64
@stderr = external global ptr, align 8
@.str.32 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [46 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @libxsmm_meqn_add_node(ptr noundef, i32 noundef, ptr noundef byval(%union.libxsmm_meqn_info) align 8) #2

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_meqn_mov_head(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @libxsmm_meqn_push_back_binary_op(i64 %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca %struct.libxsmm_meqn_op_metadata, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %union.libxsmm_meqn_info, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i64 %0, ptr %6, align 4
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 44, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %15 = getelementptr inbounds %struct.libxsmm_meqn_op_metadata, ptr %6, i32 0, i32 0
  %16 = load i32, ptr %15, align 4, !tbaa !9
  store i32 %16, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %17 = load i32, ptr %7, align 4, !tbaa !5
  %18 = icmp eq i32 %17, 11
  br i1 %18, label %40, label %19

19:                                               ; preds = %4
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = icmp eq i32 %20, 12
  br i1 %21, label %40, label %22

22:                                               ; preds = %19
  %23 = load i32, ptr %7, align 4, !tbaa !5
  %24 = icmp eq i32 %23, 13
  br i1 %24, label %40, label %25

25:                                               ; preds = %22
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = icmp eq i32 %26, 14
  br i1 %27, label %40, label %28

28:                                               ; preds = %25
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = icmp eq i32 %29, 15
  br i1 %30, label %40, label %31

31:                                               ; preds = %28
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = icmp eq i32 %32, 16
  br i1 %33, label %40, label %34

34:                                               ; preds = %31
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = icmp eq i32 %35, 17
  br i1 %36, label %40, label %37

37:                                               ; preds = %34
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = icmp eq i32 %38, 18
  br label %40

40:                                               ; preds = %37, %34, %31, %28, %25, %22, %19, %4
  %41 = phi i1 [ true, %34 ], [ true, %31 ], [ true, %28 ], [ true, %25 ], [ true, %22 ], [ true, %19 ], [ true, %4 ], [ %39, %37 ]
  %42 = zext i1 %41 to i64
  %43 = select i1 %41, i32 1, i32 0
  store i32 %43, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = icmp eq i32 %44, 6
  br i1 %45, label %67, label %46

46:                                               ; preds = %40
  %47 = load i32, ptr %7, align 4, !tbaa !5
  %48 = icmp eq i32 %47, 19
  br i1 %48, label %67, label %49

49:                                               ; preds = %46
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = icmp eq i32 %50, 20
  br i1 %51, label %67, label %52

52:                                               ; preds = %49
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = icmp eq i32 %53, 21
  br i1 %54, label %67, label %55

55:                                               ; preds = %52
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = icmp eq i32 %56, 22
  br i1 %57, label %67, label %58

58:                                               ; preds = %55
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = icmp eq i32 %59, 23
  br i1 %60, label %67, label %61

61:                                               ; preds = %58
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = icmp eq i32 %62, 24
  br i1 %63, label %67, label %64

64:                                               ; preds = %61
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = icmp eq i32 %65, 25
  br label %67

67:                                               ; preds = %64, %61, %58, %55, %52, %49, %46, %40
  %68 = phi i1 [ true, %61 ], [ true, %58 ], [ true, %55 ], [ true, %52 ], [ true, %49 ], [ true, %46 ], [ true, %40 ], [ %66, %64 ]
  %69 = zext i1 %68 to i64
  %70 = select i1 %68, i32 1, i32 0
  store i32 %70, ptr %13, align 4, !tbaa !5
  %71 = load i32, ptr %11, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [4096 x ptr], ptr @libxsmm_matrix_eqns, i64 0, i64 %72
  %74 = load ptr, ptr %73, align 8, !tbaa !11
  %75 = icmp eq ptr %74, null
  br i1 %75, label %76, label %79

76:                                               ; preds = %67
  %77 = load ptr, ptr @stderr, align 8, !tbaa !11
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %77, ptr noundef @.str.32) #3
  store i32 1, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %123

79:                                               ; preds = %67
  %80 = load i32, ptr %11, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [4096 x ptr], ptr @libxsmm_matrix_eqns, i64 0, i64 %81
  %83 = load ptr, ptr %82, align 8, !tbaa !11
  %84 = getelementptr inbounds %struct.libxsmm_matrix_eqn, ptr %83, i32 0, i32 2
  %85 = load i32, ptr %84, align 8, !tbaa !13
  %86 = icmp eq i32 %85, 1
  br i1 %86, label %87, label %90

87:                                               ; preds = %79
  %88 = load ptr, ptr @stderr, align 8, !tbaa !11
  %89 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %88, ptr noundef @.str.33) #3
  store i32 2, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %123

90:                                               ; preds = %79
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = getelementptr inbounds %struct.libxsmm_meqn_binary_op, ptr %10, i32 0, i32 0
  store i32 %91, ptr %92, align 4, !tbaa !13
  %93 = load i32, ptr %9, align 4, !tbaa !5
  %94 = getelementptr inbounds %struct.libxsmm_meqn_binary_op, ptr %10, i32 0, i32 1
  store i32 %93, ptr %94, align 4, !tbaa !13
  %95 = load i32, ptr %8, align 4, !tbaa !5
  %96 = icmp eq i32 %95, 14
  br i1 %96, label %97, label %98

97:                                               ; preds = %90
  br label %100

98:                                               ; preds = %90
  %99 = load i32, ptr %8, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %98, %97
  %101 = phi i32 [ 1, %97 ], [ %99, %98 ]
  %102 = getelementptr inbounds %struct.libxsmm_meqn_binary_op, ptr %10, i32 0, i32 2
  store i32 %101, ptr %102, align 4, !tbaa !13
  %103 = getelementptr inbounds %struct.libxsmm_meqn_op_metadata, ptr %6, i32 0, i32 1
  %104 = load i32, ptr %103, align 4, !tbaa !14
  %105 = getelementptr inbounds %struct.libxsmm_meqn_binary_op, ptr %10, i32 0, i32 3
  store i32 %104, ptr %105, align 4, !tbaa !13
  %106 = load i32, ptr %13, align 4, !tbaa !5
  %107 = getelementptr inbounds %struct.libxsmm_meqn_binary_op, ptr %10, i32 0, i32 4
  store i32 %106, ptr %107, align 4, !tbaa !13
  %108 = load i32, ptr %12, align 4, !tbaa !5
  %109 = getelementptr inbounds %struct.libxsmm_meqn_binary_op, ptr %10, i32 0, i32 5
  store i32 %108, ptr %109, align 4, !tbaa !13
  %110 = load i32, ptr %11, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [4096 x ptr], ptr @libxsmm_matrix_eqns, i64 0, i64 %111
  %113 = load ptr, ptr %112, align 8, !tbaa !11
  %114 = getelementptr inbounds %struct.libxsmm_matrix_eqn, ptr %113, i32 0, i32 1
  %115 = load ptr, ptr %114, align 8, !tbaa !13
  %116 = call ptr @libxsmm_meqn_add_node(ptr noundef %115, i32 noundef 2, ptr noundef byval(%union.libxsmm_meqn_info) align 8 %10)
  %117 = load i32, ptr %11, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [4096 x ptr], ptr @libxsmm_matrix_eqns, i64 0, i64 %118
  %120 = load ptr, ptr %119, align 8, !tbaa !11
  %121 = getelementptr inbounds %struct.libxsmm_matrix_eqn, ptr %120, i32 0, i32 1
  store ptr %116, ptr %121, align 8, !tbaa !13
  %122 = load i32, ptr %11, align 4, !tbaa !5
  call void @libxsmm_meqn_mov_head(i32 noundef %122)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %123

123:                                              ; preds = %100, %87, %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 44, ptr %10) #3
  %124 = load i32, ptr %5, align 4
  ret i32 %124
}

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

%union.libxsmm_meqn_info = type { %struct.libxsmm_meqn_arg }
%struct.libxsmm_meqn_arg = type { i32, i32, i32, i32, i32, i32, i32, %struct.libxsmm_matrix_arg_attributes }
%struct.libxsmm_matrix_arg_attributes = type { i32, i32, i32, i32 }

@libxsmm_matrix_eqns = external dso_local local_unnamed_addr global [4096 x ptr], align 64
@stderr = external local_unnamed_addr global ptr, align 8
@.str.32 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [46 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @libxsmm_meqn_add_node(ptr noundef, i32 noundef, ptr noundef byval(%union.libxsmm_meqn_info) align 8) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_meqn_mov_head(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @libxsmm_meqn_push_back_binary_op(i64 %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = alloca %union.libxsmm_meqn_info, align 8
  %.sroa.0.0.extract.trunc = trunc i64 %0 to i32
  %.sroa.2.0.extract.shift = lshr i64 %0, 32
  %.sroa.2.0.extract.trunc = trunc nuw i64 %.sroa.2.0.extract.shift to i32
  call void @llvm.lifetime.start.p0(i64 44, ptr nonnull %5) #3
  %6 = add i32 %1, -11
  %narrow = icmp ult i32 %6, 8
  %7 = zext i1 %narrow to i32
  %8 = add i32 %1, -19
  %9 = icmp ult i32 %8, 3
  %10 = and i32 %1, -17
  %11 = icmp eq i32 %10, 6
  %or.cond19 = or i1 %11, %9
  %12 = add i32 %1, -23
  %13 = icmp ult i32 %12, 3
  %narrow53 = or i1 %13, %or.cond19
  %14 = zext i1 %narrow53 to i32
  %sext = shl i64 %0, 32
  %15 = ashr exact i64 %sext, 32
  %16 = getelementptr inbounds [4096 x ptr], ptr @libxsmm_matrix_eqns, i64 0, i64 %15
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %22

19:                                               ; preds = %4
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str.32) #4
  br label %42

22:                                               ; preds = %4
  %23 = getelementptr inbounds i8, ptr %17, i64 16
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %26, label %29

26:                                               ; preds = %22
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.33) #4
  br label %42

29:                                               ; preds = %22
  store i32 %1, ptr %5, align 8, !tbaa !9
  %30 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %3, ptr %30, align 4, !tbaa !9
  %31 = icmp eq i32 %2, 14
  %32 = select i1 %31, i32 1, i32 %2
  %33 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %32, ptr %33, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %5, i64 12
  store i32 %.sroa.2.0.extract.trunc, ptr %34, align 4, !tbaa !9
  %35 = getelementptr inbounds i8, ptr %5, i64 16
  store i32 %14, ptr %35, align 8, !tbaa !9
  %36 = getelementptr inbounds i8, ptr %5, i64 20
  store i32 %7, ptr %36, align 4, !tbaa !9
  %37 = getelementptr inbounds i8, ptr %17, i64 8
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = tail call ptr @libxsmm_meqn_add_node(ptr noundef %38, i32 noundef 2, ptr noundef nonnull byval(%union.libxsmm_meqn_info) align 8 %5)
  %40 = load ptr, ptr %16, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 8
  store ptr %39, ptr %41, align 8, !tbaa !9
  tail call void @libxsmm_meqn_mov_head(i32 noundef %.sroa.0.0.extract.trunc)
  br label %42

42:                                               ; preds = %29, %26, %19
  %.0 = phi i32 [ 1, %19 ], [ 2, %26 ], [ 0, %29 ]
  call void @llvm.lifetime.end.p0(i64 44, ptr nonnull %5) #3
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { nounwind }
attributes #4 = { cold 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 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass