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

; 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.libxsmm_generated_code = type { ptr, i32, i32, i32, i32, i32, i32 }
%struct.libxsmm_const_data_tracker = type { [81920 x i8], i32, [128 x i32], i32 }

@.str = external hidden unnamed_addr constant [82 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@libxsmm_verbosity = external global i32, align 4
@stderr = external global ptr, align 8
@__func__.libxsmm_x86_instruction_lea_data = external hidden unnamed_addr constant [33 x i8], align 1
@.str.174 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.175 = external hidden unnamed_addr constant [80 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: 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) #1

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_x86_instruction_lea_data(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #4 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  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 ptr %3, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %12, i32 0, i32 3
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = icmp ugt i32 %14, 1
  br i1 %15, label %16, label %102

16:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  store ptr %19, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %20, i32 0, i32 2
  %22 = load i32, ptr %21, align 4, !tbaa !14
  store i32 %22, ptr %10, align 4, !tbaa !9
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !15
  %26 = add i32 %25, 7
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = icmp ult i32 %26, %27
  br i1 %28, label %29, label %38

29:                                               ; preds = %16
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %32 = icmp ult i32 1, %31
  br i1 %32, label %33, label %35

33:                                               ; preds = %29
  %34 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %36

35:                                               ; preds = %29
  br label %36

36:                                               ; preds = %35, %33
  %37 = phi i32 [ %34, %33 ], [ 1, %35 ]
  call void @libxsmm_handle_error(ptr noundef %30, i32 noundef 90002, ptr noundef @__func__.libxsmm_x86_instruction_lea_data, ptr noundef @.str, i32 noundef 4950, i32 noundef %37)
  store i32 1, ptr %11, align 4
  br label %99

38:                                               ; preds = %16
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.libxsmm_const_data_tracker, ptr %39, i32 0, i32 3
  %41 = load i32, ptr %40, align 4, !tbaa !16
  %42 = icmp eq i32 128, %41
  br i1 %42, label %43, label %54

43:                                               ; preds = %38
  %44 = load ptr, ptr @stderr, align 8, !tbaa !5
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef @.str.174) #5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %48 = icmp ult i32 1, %47
  br i1 %48, label %49, label %51

49:                                               ; preds = %43
  %50 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %52

51:                                               ; preds = %43
  br label %52

52:                                               ; preds = %51, %49
  %53 = phi i32 [ %50, %49 ], [ 1, %51 ]
  call void @libxsmm_handle_error(ptr noundef %46, i32 noundef 90000, ptr noundef @__func__.libxsmm_x86_instruction_lea_data, ptr noundef @.str, i32 noundef 4957, i32 noundef %53)
  store i32 1, ptr %11, align 4
  br label %99

54:                                               ; preds = %38
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = icmp uge i32 %55, 8
  %57 = zext i1 %56 to i64
  %58 = select i1 %56, i32 76, i32 72
  %59 = trunc i32 %58 to i8
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = load i32, ptr %10, align 4, !tbaa !9
  %62 = add i32 %61, 1
  store i32 %62, ptr %10, align 4, !tbaa !9
  %63 = zext i32 %61 to i64
  %64 = getelementptr inbounds i8, ptr %60, i64 %63
  store i8 %59, ptr %64, align 1, !tbaa !18
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = load i32, ptr %10, align 4, !tbaa !9
  %67 = add i32 %66, 1
  store i32 %67, ptr %10, align 4, !tbaa !9
  %68 = zext i32 %66 to i64
  %69 = getelementptr inbounds i8, ptr %65, i64 %68
  store i8 -115, ptr %69, align 1, !tbaa !18
  %70 = load i32, ptr %6, align 4, !tbaa !9
  %71 = urem i32 %70, 8
  %72 = mul i32 %71, 8
  %73 = add i32 5, %72
  %74 = trunc i32 %73 to i8
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = load i32, ptr %10, align 4, !tbaa !9
  %77 = add i32 %76, 1
  store i32 %77, ptr %10, align 4, !tbaa !9
  %78 = zext i32 %76 to i64
  %79 = getelementptr inbounds i8, ptr %75, i64 %78
  store i8 %74, ptr %79, align 1, !tbaa !18
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = load i32, ptr %10, align 4, !tbaa !9
  %82 = zext i32 %81 to i64
  %83 = getelementptr inbounds i8, ptr %80, i64 %82
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %83, ptr align 4 %7, i64 4, i1 false)
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %84, i32 0, i32 2
  %86 = load i32, ptr %85, align 4, !tbaa !14
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.libxsmm_const_data_tracker, ptr %87, i32 0, i32 2
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.libxsmm_const_data_tracker, ptr %89, i32 0, i32 3
  %91 = load i32, ptr %90, align 4, !tbaa !16
  %92 = add i32 %91, 1
  store i32 %92, ptr %90, align 4, !tbaa !16
  %93 = zext i32 %91 to i64
  %94 = getelementptr inbounds [128 x i32], ptr %88, i64 0, i64 %93
  store i32 %86, ptr %94, align 4, !tbaa !9
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %95, i32 0, i32 2
  %97 = load i32, ptr %96, align 4, !tbaa !14
  %98 = add i32 %97, 7
  store i32 %98, ptr %96, align 4, !tbaa !14
  store i32 0, ptr %11, align 4
  br label %99

99:                                               ; preds = %54, %52, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %100 = load i32, ptr %11, align 4
  switch i32 %100, label %114 [
    i32 0, label %101
    i32 1, label %113
  ]

101:                                              ; preds = %99
  br label %113

102:                                              ; preds = %4
  %103 = load ptr, ptr @stderr, align 8, !tbaa !5
  %104 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %103, ptr noundef @.str.175) #5
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %107 = icmp ult i32 1, %106
  br i1 %107, label %108, label %110

108:                                              ; preds = %102
  %109 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %111

110:                                              ; preds = %102
  br label %111

111:                                              ; preds = %110, %108
  %112 = phi i32 [ %109, %108 ], [ 1, %110 ]
  call void @libxsmm_handle_error(ptr noundef %105, i32 noundef 90000, ptr noundef @__func__.libxsmm_x86_instruction_lea_data, ptr noundef @.str, i32 noundef 4973, i32 noundef %112)
  br label %113

113:                                              ; preds = %111, %101, %99
  ret void

114:                                              ; preds = %99
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 "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 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 #5 = { 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 = !{!12, !10, i64 16}
!12 = !{!"libxsmm_generated_code", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!13 = !{!12, !6, i64 0}
!14 = !{!12, !10, i64 12}
!15 = !{!12, !10, i64 8}
!16 = !{!17, !10, i64 82436}
!17 = !{!"libxsmm_const_data_tracker", !7, i64 0, !10, i64 81920, !7, i64 81924, !10, i64 82436}
!18 = !{!7, !7, 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"

@.str = external hidden unnamed_addr constant [82 x i8], align 1
@libxsmm_ninit = external local_unnamed_addr global i32, align 4
@libxsmm_verbosity = external local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@__func__.libxsmm_x86_instruction_lea_data = external hidden unnamed_addr constant [33 x i8], align 1
@.str.174 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.175 = external hidden unnamed_addr constant [80 x i8], align 1

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_x86_instruction_lea_data(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef %3) local_unnamed_addr #2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp ugt i32 %6, 1
  br i1 %7, label %8, label %56

8:                                                ; preds = %4
  %9 = load ptr, ptr %0, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load i32, ptr %10, align 4, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = add i32 %13, 7
  %15 = icmp ult i32 %14, %11
  br i1 %15, label %16, label %21

16:                                               ; preds = %8
  %17 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %18 = icmp ugt i32 %17, 1
  %19 = load i32, ptr @libxsmm_verbosity, align 4
  %20 = select i1 %18, i32 %19, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90002, ptr noundef nonnull @__func__.libxsmm_x86_instruction_lea_data, ptr noundef nonnull @.str, i32 noundef 4950, i32 noundef %20) #3
  br label %63

21:                                               ; preds = %8
  %22 = getelementptr inbounds i8, ptr %3, i64 82436
  %23 = load i32, ptr %22, align 4, !tbaa !15
  %24 = icmp eq i32 %23, 128
  br i1 %24, label %25, label %32

25:                                               ; preds = %21
  %26 = load ptr, ptr @stderr, align 8, !tbaa !17
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.174) #4
  %28 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %29 = icmp ugt i32 %28, 1
  %30 = load i32, ptr @libxsmm_verbosity, align 4
  %31 = select i1 %29, i32 %30, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_x86_instruction_lea_data, ptr noundef nonnull @.str, i32 noundef 4957, i32 noundef %31) #3
  br label %63

32:                                               ; preds = %21
  %33 = icmp ugt i32 %1, 7
  %34 = select i1 %33, i8 76, i8 72
  %35 = add i32 %11, 1
  %36 = zext i32 %11 to i64
  %37 = getelementptr inbounds i8, ptr %9, i64 %36
  store i8 %34, ptr %37, align 1, !tbaa !18
  %38 = add i32 %11, 2
  %39 = zext i32 %35 to i64
  %40 = getelementptr inbounds i8, ptr %9, i64 %39
  store i8 -115, ptr %40, align 1, !tbaa !18
  %.tr = trunc i32 %1 to i8
  %41 = shl i8 %.tr, 3
  %42 = and i8 %41, 56
  %43 = or disjoint i8 %42, 5
  %44 = add i32 %11, 3
  %45 = zext i32 %38 to i64
  %46 = getelementptr inbounds i8, ptr %9, i64 %45
  store i8 %43, ptr %46, align 1, !tbaa !18
  %47 = zext i32 %44 to i64
  %48 = getelementptr inbounds i8, ptr %9, i64 %47
  store i32 %2, ptr %48, align 1
  %49 = load i32, ptr %10, align 4, !tbaa !12
  %50 = getelementptr inbounds i8, ptr %3, i64 81924
  %51 = load i32, ptr %22, align 4, !tbaa !15
  %52 = add i32 %51, 1
  store i32 %52, ptr %22, align 4, !tbaa !15
  %53 = zext i32 %51 to i64
  %54 = getelementptr inbounds [128 x i32], ptr %50, i64 0, i64 %53
  store i32 %49, ptr %54, align 4, !tbaa !14
  %55 = add i32 %49, 7
  store i32 %55, ptr %10, align 4, !tbaa !12
  br label %63

56:                                               ; preds = %4
  %57 = load ptr, ptr @stderr, align 8, !tbaa !17
  %58 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef nonnull @.str.175) #4
  %59 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %60 = icmp ugt i32 %59, 1
  %61 = load i32, ptr @libxsmm_verbosity, align 4
  %62 = select i1 %60, i32 %61, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_x86_instruction_lea_data, ptr noundef nonnull @.str, i32 noundef 4973, i32 noundef %62) #3
  br label %63

63:                                               ; preds = %16, %25, %32, %56
  ret void
}

attributes #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 = { 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, !10, i64 16}
!6 = !{!"libxsmm_generated_code", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !10, i64 12}
!13 = !{!6, !10, i64 8}
!14 = !{!10, !10, i64 0}
!15 = !{!16, !10, i64 82436}
!16 = !{!"libxsmm_const_data_tracker", !8, i64 0, !10, i64 81920, !8, i64 81924, !10, i64 82436}
!17 = !{!7, !7, i64 0}
!18 = !{!8, !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass