; LLVM IR from libxsmm/libxsmm :: samples/external_aux (perf_counter_markers)

; 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.perf_event_attr = type { i32, i32, i64, %union.anon, i64, i64, i64, %union.anon.0, i32, %union.anon.1, %union.anon.2, i64, i64, i32, i32, i64, i32, i16, i16, i32, i32, i64 }
%union.anon = type { i64 }
%union.anon.0 = type { i32 }
%union.anon.1 = type { i64 }
%union.anon.2 = type { i64 }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @evsetup(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca [1024 x i8], align 16
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca %struct.perf_event_attr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1024, ptr %15) #6
  %23 = getelementptr inbounds [1024 x i8], ptr %15, i64 0, i64 0
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %23, ptr noundef @.str, ptr noundef %24) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %26 = getelementptr inbounds [1024 x i8], ptr %15, i64 0, i64 0
  %27 = call noalias ptr @fopen(ptr noundef %26, ptr noundef @.str.1)
  store ptr %27, ptr %16, align 8, !tbaa !5
  %28 = load ptr, ptr %16, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %32

30:                                               ; preds = %7
  %31 = getelementptr inbounds [1024 x i8], ptr %15, i64 0, i64 0
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.2, ptr noundef %31) #7
  unreachable

32:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %33 = load ptr, ptr %16, align 8, !tbaa !5
  %34 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %33, ptr noundef @.str.3, ptr noundef %17)
  %35 = load ptr, ptr %16, align 8, !tbaa !5
  %36 = call i32 @fclose(ptr noundef %35)
  call void @llvm.lifetime.start.p0(i64 128, ptr %22) #6
  call void @llvm.memset.p0.i64(ptr align 8 %22, i8 0, i64 128, i1 false)
  %37 = getelementptr inbounds %struct.perf_event_attr, ptr %22, i32 0, i32 1
  store i32 128, ptr %37, align 4, !tbaa !11
  %38 = load i32, ptr %17, align 4, !tbaa !9
  %39 = getelementptr inbounds %struct.perf_event_attr, ptr %22, i32 0, i32 0
  store i32 %38, ptr %39, align 8, !tbaa !15
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = shl i32 %41, 8
  %43 = or i32 %40, %42
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds %struct.perf_event_attr, ptr %22, i32 0, i32 2
  store i64 %44, ptr %45, align 8, !tbaa !16
  %46 = load i32, ptr %12, align 4, !tbaa !9
  %47 = zext i32 %46 to i64
  store i64 %47, ptr %18, align 8, !tbaa !17
  %48 = load i32, ptr %13, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  store i64 %49, ptr %19, align 8, !tbaa !17
  %50 = load i64, ptr %19, align 8, !tbaa !17
  %51 = shl i64 %50, 32
  %52 = load i64, ptr %18, align 8, !tbaa !17
  %53 = or i64 %52, %51
  store i64 %53, ptr %18, align 8, !tbaa !17
  %54 = load i64, ptr %18, align 8, !tbaa !17
  %55 = getelementptr inbounds %struct.perf_event_attr, ptr %22, i32 0, i32 9
  store i64 %54, ptr %55, align 8, !tbaa !19
  %56 = load i32, ptr %14, align 4, !tbaa !9
  %57 = icmp slt i32 %56, 0
  br i1 %57, label %58, label %59

58:                                               ; preds = %32
  store i32 0, ptr %20, align 4, !tbaa !9
  store i32 -1, ptr %21, align 4, !tbaa !9
  br label %61

59:                                               ; preds = %32
  %60 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %60, ptr %20, align 4, !tbaa !9
  store i32 -1, ptr %21, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %59, %58
  %62 = load i32, ptr %21, align 4, !tbaa !9
  %63 = load i32, ptr %20, align 4, !tbaa !9
  %64 = call i32 @perf_event_open(ptr noundef %22, i32 noundef %62, i32 noundef %63, i32 noundef -1, i64 noundef 0)
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %64, ptr %65, align 4, !tbaa !9
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = load i32, ptr %66, align 4, !tbaa !9
  %68 = icmp eq i32 %67, -1
  br i1 %68, label %69, label %74

69:                                               ; preds = %61
  %70 = load i32, ptr %20, align 4, !tbaa !9
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.perf_event_attr, ptr %22, i32 0, i32 2
  %73 = load i64, ptr %72, align 8, !tbaa !16
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.4, i32 noundef %70, ptr noundef %71, i64 noundef %73) #7
  unreachable

74:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 128, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 1024, ptr %15) #6
  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: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #2

declare noalias ptr @fopen(ptr noundef, ptr noundef) #3

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) #4

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) #3

declare i32 @fclose(ptr noundef) #3

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

; Function Attrs: nounwind uwtable
declare hidden i32 @perf_event_open(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i64 noundef) #0

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { "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 = { noreturn "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { noreturn }

!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 4}
!12 = !{!"perf_event_attr", !10, i64 0, !10, i64 4, !13, i64 8, !7, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 40, !13, i64 40, !13, i64 40, !13, i64 40, !13, i64 40, !13, i64 40, !13, i64 40, !13, i64 41, !13, i64 41, !13, i64 41, !13, i64 41, !13, i64 41, !13, i64 41, !13, i64 41, !13, i64 41, !13, i64 42, !13, i64 42, !13, i64 42, !13, i64 42, !13, i64 42, !13, i64 42, !13, i64 42, !13, i64 43, !13, i64 43, !13, i64 43, !13, i64 43, !13, i64 43, !13, i64 43, !13, i64 43, !13, i64 43, !13, i64 44, !13, i64 44, !13, i64 44, !13, i64 44, !13, i64 44, !13, i64 44, !13, i64 44, !7, i64 48, !10, i64 52, !7, i64 56, !7, i64 64, !13, i64 72, !13, i64 80, !10, i64 88, !10, i64 92, !13, i64 96, !10, i64 104, !14, i64 108, !14, i64 110, !10, i64 112, !10, i64 116, !13, i64 120}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !10, i64 0}
!16 = !{!12, !13, i64 8}
!17 = !{!18, !18, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!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"

%struct.perf_event_attr = type { i32, i32, i64, %union.anon, i64, i64, i64, %union.anon.0, i32, %union.anon.1, %union.anon.2, i64, i64, i32, i32, i64, i32, i16, i16, i32, i32, i64 }
%union.anon = type { i64 }
%union.anon.0 = type { i32 }
%union.anon.1 = type { i64 }
%union.anon.2 = type { i64 }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @evsetup(ptr noundef %0, ptr nocapture noundef writeonly %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = alloca [1024 x i8], align 16
  %9 = alloca i32, align 4
  %10 = alloca %struct.perf_event_attr, align 8
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %8) #7
  %11 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) @.str, ptr noundef %0) #7
  %12 = call noalias ptr @fopen(ptr noundef nonnull %8, ptr noundef nonnull @.str.1)
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %7
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.2, ptr noundef nonnull %8) #8
  unreachable

15:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #7
  %16 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %12, ptr noundef nonnull @.str.3, ptr noundef nonnull %9) #7
  %17 = call i32 @fclose(ptr noundef nonnull %12)
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %10) #7
  %18 = getelementptr inbounds i8, ptr %10, i64 16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(128) %18, i8 0, i64 112, i1 false)
  %19 = getelementptr inbounds i8, ptr %10, i64 4
  store i32 128, ptr %19, align 4, !tbaa !5
  %20 = load i32, ptr %9, align 4, !tbaa !12
  store i32 %20, ptr %10, align 8, !tbaa !13
  %21 = shl i32 %3, 8
  %22 = or i32 %21, %2
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds i8, ptr %10, i64 8
  store i64 %23, ptr %24, align 8, !tbaa !14
  %25 = zext i32 %4 to i64
  %26 = zext i32 %5 to i64
  %27 = shl nuw i64 %26, 32
  %28 = or disjoint i64 %27, %25
  %29 = getelementptr inbounds i8, ptr %10, i64 56
  store i64 %28, ptr %29, align 8, !tbaa !15
  %. = call i32 @llvm.smax.i32(i32 %6, i32 0)
  %30 = call i32 @perf_event_open(ptr noundef nonnull %10, i32 noundef -1, i32 noundef %., i32 noundef -1, i64 noundef 0)
  store i32 %30, ptr %1, align 4, !tbaa !12
  %31 = icmp eq i32 %30, -1
  br i1 %31, label %32, label %34

32:                                               ; preds = %15
  %33 = load i64, ptr %24, align 8, !tbaa !14
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.4, i32 noundef %., ptr noundef %0, i64 noundef %33) #8
  unreachable

34:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #7
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %8) #7
  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: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) local_unnamed_addr #3

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @perf_event_open(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i64 noundef) local_unnamed_addr #0

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #6

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { noreturn "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { 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, !7, i64 4}
!6 = !{!"perf_event_attr", !7, i64 0, !7, i64 4, !10, i64 8, !8, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 40, !10, i64 40, !10, i64 40, !10, i64 40, !10, i64 40, !10, i64 40, !10, i64 40, !10, i64 41, !10, i64 41, !10, i64 41, !10, i64 41, !10, i64 41, !10, i64 41, !10, i64 41, !10, i64 41, !10, i64 42, !10, i64 42, !10, i64 42, !10, i64 42, !10, i64 42, !10, i64 42, !10, i64 42, !10, i64 43, !10, i64 43, !10, i64 43, !10, i64 43, !10, i64 43, !10, i64 43, !10, i64 43, !10, i64 43, !10, i64 44, !10, i64 44, !10, i64 44, !10, i64 44, !10, i64 44, !10, i64 44, !10, i64 44, !8, i64 48, !7, i64 52, !8, i64 56, !8, i64 64, !10, i64 72, !10, i64 80, !7, i64 88, !7, i64 92, !10, i64 96, !7, i64 104, !11, i64 108, !11, i64 110, !7, i64 112, !7, i64 116, !10, i64 120}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !10, i64 8}
!15 = !{!8, !8, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass