; LLVM IR from gem5/gem5 :: ext/nomali/tests (nomali_test0)

; 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.nomali_config_t = type { i32, i32, i32, i32 }

@__const.main.cfg = external hidden unnamed_addr constant %struct.nomali_config_t, align 4
@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %struct.nomali_config_t, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 @__const.main.cfg, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  br label %10

10:                                               ; preds = %2
  %11 = call i32 @nomali_create(ptr noundef %7, ptr noundef %6)
  store i32 %11, ptr %8, align 4, !tbaa !5
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %17

13:                                               ; preds = %10
  %14 = load i32, ptr %8, align 4, !tbaa !5
  %15 = call ptr @nomali_errstr(i32 noundef %14)
  %16 = load i32, ptr %8, align 4, !tbaa !5
  call void (ptr, ...) @test_diag(ptr noundef @.str, ptr noundef %15, i32 noundef %16)
  call void @test_fail(ptr noundef @.str.1)
  br label %18

17:                                               ; preds = %10
  call void @test_ok(ptr noundef @.str.1)
  br label %18

18:                                               ; preds = %17, %13
  br label %19

19:                                               ; preds = %18
  br label %20

20:                                               ; preds = %19
  %21 = load i32, ptr %8, align 4, !tbaa !5
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  call void (ptr, ...) @test_bail(ptr noundef @.str.2) #6
  unreachable

24:                                               ; preds = %20
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr %7, align 8, !tbaa !9
  %27 = call i32 @nomali_reg_read(ptr noundef %26, ptr noundef %9, i64 noundef 0)
  store i32 %27, ptr %8, align 4, !tbaa !5
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %33

29:                                               ; preds = %25
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = call ptr @nomali_errstr(i32 noundef %30)
  %32 = load i32, ptr %8, align 4, !tbaa !5
  call void (ptr, ...) @test_diag(ptr noundef @.str.3, ptr noundef %31, i32 noundef %32)
  call void @test_fail(ptr noundef @.str.4)
  br label %34

33:                                               ; preds = %25
  call void @test_ok(ptr noundef @.str.4)
  br label %34

34:                                               ; preds = %33, %29
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = load i32, ptr %9, align 4, !tbaa !5
  %38 = icmp ne i32 %37, 1767243792
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  call void @test_fail(ptr noundef @.str.5)
  br label %41

40:                                               ; preds = %36
  call void @test_ok(ptr noundef @.str.5)
  br label %41

41:                                               ; preds = %40, %39
  br label %42

42:                                               ; preds = %41
  %43 = load ptr, ptr %7, align 8, !tbaa !9
  %44 = call i32 @nomali_destroy(ptr noundef %43)
  store i32 %44, ptr %8, align 4, !tbaa !5
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %50

46:                                               ; preds = %42
  %47 = load i32, ptr %8, align 4, !tbaa !5
  %48 = call ptr @nomali_errstr(i32 noundef %47)
  %49 = load i32, ptr %8, align 4, !tbaa !5
  call void (ptr, ...) @test_diag(ptr noundef @.str.6, ptr noundef %48, i32 noundef %49)
  call void @test_fail(ptr noundef @.str.7)
  br label %51

50:                                               ; preds = %42
  call void @test_ok(ptr noundef @.str.7)
  br label %51

51:                                               ; preds = %50, %46
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  ret i32 0
}

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

; 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) #2

declare i32 @nomali_create(ptr noundef, ptr noundef) #3

declare void @test_diag(ptr noundef, ...) #3

declare ptr @nomali_errstr(i32 noundef) #3

declare void @test_fail(ptr noundef) #3

declare void @test_ok(ptr noundef) #3

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

declare i32 @nomali_reg_read(ptr noundef, ptr noundef, i64 noundef) #3

declare i32 @nomali_destroy(ptr noundef) #3

; 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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.nomali_config_t = type { i32, i32, i32, i32 }

@__const.main.cfg = external hidden unnamed_addr constant %struct.nomali_config_t, align 4
@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca %struct.nomali_config_t, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %3, ptr noundef nonnull align 4 dereferenceable(16) @__const.main.cfg, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  %6 = call i32 @nomali_create(ptr noundef nonnull %4, ptr noundef nonnull %3) #5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %9, label %7

7:                                                ; preds = %2
  %8 = call ptr @nomali_errstr(i32 noundef %6) #5
  call void (ptr, ...) @test_diag(ptr noundef nonnull @.str, ptr noundef %8, i32 noundef %6) #5
  call void @test_fail(ptr noundef nonnull @.str.1) #5
  call void (ptr, ...) @test_bail(ptr noundef nonnull @.str.2) #6
  unreachable

9:                                                ; preds = %2
  call void @test_ok(ptr noundef nonnull @.str.1) #5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = call i32 @nomali_reg_read(ptr noundef %10, ptr noundef nonnull %5, i64 noundef 0) #5
  %.not9 = icmp eq i32 %11, 0
  br i1 %.not9, label %14, label %12

12:                                               ; preds = %9
  %13 = call ptr @nomali_errstr(i32 noundef %11) #5
  call void (ptr, ...) @test_diag(ptr noundef nonnull @.str.3, ptr noundef %13, i32 noundef %11) #5
  call void @test_fail(ptr noundef nonnull @.str.4) #5
  br label %15

14:                                               ; preds = %9
  call void @test_ok(ptr noundef nonnull @.str.4) #5
  br label %15

15:                                               ; preds = %14, %12
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %.not10 = icmp eq i32 %16, 1767243792
  br i1 %.not10, label %18, label %17

17:                                               ; preds = %15
  call void @test_fail(ptr noundef nonnull @.str.5) #5
  br label %19

18:                                               ; preds = %15
  call void @test_ok(ptr noundef nonnull @.str.5) #5
  br label %19

19:                                               ; preds = %17, %18
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call i32 @nomali_destroy(ptr noundef %20) #5
  %.not11 = icmp eq i32 %21, 0
  br i1 %.not11, label %24, label %22

22:                                               ; preds = %19
  %23 = call ptr @nomali_errstr(i32 noundef %21) #5
  call void (ptr, ...) @test_diag(ptr noundef nonnull @.str.6, ptr noundef %23, i32 noundef %21) #5
  call void @test_fail(ptr noundef nonnull @.str.7) #5
  br label %25

24:                                               ; preds = %19
  call void @test_ok(ptr noundef nonnull @.str.7) #5
  br label %25

25:                                               ; preds = %24, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  ret i32 0
}

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

; Function Attrs: mustprogress 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) #2

declare i32 @nomali_create(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @test_diag(ptr noundef, ...) local_unnamed_addr #3

declare ptr @nomali_errstr(i32 noundef) local_unnamed_addr #3

declare void @test_fail(ptr noundef) local_unnamed_addr #3

declare void @test_ok(ptr noundef) local_unnamed_addr #3

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

declare i32 @nomali_reg_read(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

declare i32 @nomali_destroy(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind }
attributes #6 = { 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}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass