; LLVM IR from stivalaa/EstimNetDirected :: src/Random123-1.09/examples (kat_c)

; 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.kat_instance = type { i32, i32, %union.anon }
%union.anon = type { %struct.threefry4x64_kat }
%struct.threefry4x64_kat = type { %struct.r123array4x64, %struct.r123array4x64, %struct.r123array4x64, %struct.r123array4x64 }
%struct.r123array4x64 = type { [4 x i64] }
%struct.philox2x32_kat = type { %struct.r123array2x32, %struct.r123array1x32, %struct.r123array2x32, %struct.r123array2x32 }
%struct.r123array1x32 = type { [1 x i32] }
%struct.r123array2x32 = type { [2 x i32] }

@stderr = external global ptr, align 8
@nfailed = external dso_local global i64, align 8
@.str.10 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [18 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 uwtable
declare dso_local void @prtu32(i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @report_philox2x32error(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 1, ptr %4, align 8, !tbaa !9
  %5 = load ptr, ptr @stderr, align 8, !tbaa !5
  %6 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef @.str.10) #3
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.kat_instance, ptr %8, i32 0, i32 1
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef @.str.11, i32 noundef %10) #3
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %25, %1
  %13 = load i64, ptr %3, align 8, !tbaa !9
  %14 = icmp ult i64 %13, 2
  br i1 %14, label %15, label %28

15:                                               ; preds = %12
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str.12) #3
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.kat_instance, ptr %18, i32 0, i32 2
  %20 = getelementptr inbounds %struct.philox2x32_kat, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds %struct.r123array2x32, ptr %20, i32 0, i32 0
  %22 = load i64, ptr %3, align 8, !tbaa !9
  %23 = getelementptr inbounds [2 x i32], ptr %21, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !14
  call void @prtu32(i32 noundef %24)
  br label %25

25:                                               ; preds = %15
  %26 = load i64, ptr %3, align 8, !tbaa !9
  %27 = add i64 %26, 1
  store i64 %27, ptr %3, align 8, !tbaa !9
  br label %12, !llvm.loop !15

28:                                               ; preds = %12
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %43, %28
  %30 = load i64, ptr %3, align 8, !tbaa !9
  %31 = load i64, ptr %4, align 8, !tbaa !9
  %32 = icmp ult i64 %30, %31
  br i1 %32, label %33, label %46

33:                                               ; preds = %29
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef @.str.12) #3
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.kat_instance, ptr %36, i32 0, i32 2
  %38 = getelementptr inbounds %struct.philox2x32_kat, ptr %37, i32 0, i32 1
  %39 = getelementptr inbounds %struct.r123array1x32, ptr %38, i32 0, i32 0
  %40 = load i64, ptr %3, align 8, !tbaa !9
  %41 = getelementptr inbounds [1 x i32], ptr %39, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !14
  call void @prtu32(i32 noundef %42)
  br label %43

43:                                               ; preds = %33
  %44 = load i64, ptr %3, align 8, !tbaa !9
  %45 = add i64 %44, 1
  store i64 %45, ptr %3, align 8, !tbaa !9
  br label %29, !llvm.loop !17

46:                                               ; preds = %29
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %47

47:                                               ; preds = %60, %46
  %48 = load i64, ptr %3, align 8, !tbaa !9
  %49 = icmp ult i64 %48, 2
  br i1 %49, label %50, label %63

50:                                               ; preds = %47
  %51 = load ptr, ptr @stderr, align 8, !tbaa !5
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef @.str.12) #3
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.kat_instance, ptr %53, i32 0, i32 2
  %55 = getelementptr inbounds %struct.philox2x32_kat, ptr %54, i32 0, i32 2
  %56 = getelementptr inbounds %struct.r123array2x32, ptr %55, i32 0, i32 0
  %57 = load i64, ptr %3, align 8, !tbaa !9
  %58 = getelementptr inbounds [2 x i32], ptr %56, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !14
  call void @prtu32(i32 noundef %59)
  br label %60

60:                                               ; preds = %50
  %61 = load i64, ptr %3, align 8, !tbaa !9
  %62 = add i64 %61, 1
  store i64 %62, ptr %3, align 8, !tbaa !9
  br label %47, !llvm.loop !18

63:                                               ; preds = %47
  %64 = load ptr, ptr @stderr, align 8, !tbaa !5
  %65 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %64, ptr noundef @.str.13) #3
  %66 = load ptr, ptr @stderr, align 8, !tbaa !5
  %67 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef @.str.14) #3
  %68 = load ptr, ptr @stderr, align 8, !tbaa !5
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.kat_instance, ptr %69, i32 0, i32 1
  %71 = load i32, ptr %70, align 4, !tbaa !11
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %68, ptr noundef @.str.11, i32 noundef %71) #3
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %73

73:                                               ; preds = %86, %63
  %74 = load i64, ptr %3, align 8, !tbaa !9
  %75 = icmp ult i64 %74, 2
  br i1 %75, label %76, label %89

76:                                               ; preds = %73
  %77 = load ptr, ptr @stderr, align 8, !tbaa !5
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %77, ptr noundef @.str.12) #3
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.kat_instance, ptr %79, i32 0, i32 2
  %81 = getelementptr inbounds %struct.philox2x32_kat, ptr %80, i32 0, i32 0
  %82 = getelementptr inbounds %struct.r123array2x32, ptr %81, i32 0, i32 0
  %83 = load i64, ptr %3, align 8, !tbaa !9
  %84 = getelementptr inbounds [2 x i32], ptr %82, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !14
  call void @prtu32(i32 noundef %85)
  br label %86

86:                                               ; preds = %76
  %87 = load i64, ptr %3, align 8, !tbaa !9
  %88 = add i64 %87, 1
  store i64 %88, ptr %3, align 8, !tbaa !9
  br label %73, !llvm.loop !19

89:                                               ; preds = %73
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %90

90:                                               ; preds = %104, %89
  %91 = load i64, ptr %3, align 8, !tbaa !9
  %92 = load i64, ptr %4, align 8, !tbaa !9
  %93 = icmp ult i64 %91, %92
  br i1 %93, label %94, label %107

94:                                               ; preds = %90
  %95 = load ptr, ptr @stderr, align 8, !tbaa !5
  %96 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %95, ptr noundef @.str.12) #3
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.kat_instance, ptr %97, i32 0, i32 2
  %99 = getelementptr inbounds %struct.philox2x32_kat, ptr %98, i32 0, i32 1
  %100 = getelementptr inbounds %struct.r123array1x32, ptr %99, i32 0, i32 0
  %101 = load i64, ptr %3, align 8, !tbaa !9
  %102 = getelementptr inbounds [1 x i32], ptr %100, i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !14
  call void @prtu32(i32 noundef %103)
  br label %104

104:                                              ; preds = %94
  %105 = load i64, ptr %3, align 8, !tbaa !9
  %106 = add i64 %105, 1
  store i64 %106, ptr %3, align 8, !tbaa !9
  br label %90, !llvm.loop !20

107:                                              ; preds = %90
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %108

108:                                              ; preds = %121, %107
  %109 = load i64, ptr %3, align 8, !tbaa !9
  %110 = icmp ult i64 %109, 2
  br i1 %110, label %111, label %124

111:                                              ; preds = %108
  %112 = load ptr, ptr @stderr, align 8, !tbaa !5
  %113 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %112, ptr noundef @.str.12) #3
  %114 = load ptr, ptr %2, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.kat_instance, ptr %114, i32 0, i32 2
  %116 = getelementptr inbounds %struct.philox2x32_kat, ptr %115, i32 0, i32 3
  %117 = getelementptr inbounds %struct.r123array2x32, ptr %116, i32 0, i32 0
  %118 = load i64, ptr %3, align 8, !tbaa !9
  %119 = getelementptr inbounds [2 x i32], ptr %117, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !14
  call void @prtu32(i32 noundef %120)
  br label %121

121:                                              ; preds = %111
  %122 = load i64, ptr %3, align 8, !tbaa !9
  %123 = add i64 %122, 1
  store i64 %123, ptr %3, align 8, !tbaa !9
  br label %108, !llvm.loop !21

124:                                              ; preds = %108
  %125 = load ptr, ptr @stderr, align 8, !tbaa !5
  %126 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %125, ptr noundef @.str.13) #3
  %127 = load i64, ptr @nfailed, align 8, !tbaa !9
  %128 = add i64 %127, 1
  store i64 %128, ptr @nfailed, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 4}
!12 = !{!"", !13, i64 0, !13, i64 4, !7, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}
!19 = distinct !{!19, !16}
!20 = distinct !{!20, !16}
!21 = distinct !{!21, !16}


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

@stderr = external local_unnamed_addr global ptr, align 8
@nfailed = external dso_local local_unnamed_addr global i64, align 8
@.str.10 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @prtu32(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 @report_philox2x32error(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
.critedge:
  %1 = load ptr, ptr @stderr, align 8, !tbaa !5
  %2 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.10) #2
  %3 = load ptr, ptr @stderr, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !9
  %6 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %3, ptr noundef nonnull @.str.11, i32 noundef %5) #2
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr @stderr, align 8, !tbaa !5
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef nonnull @.str.12) #2
  %10 = load i32, ptr %7, align 4, !tbaa !12
  tail call void @prtu32(i32 noundef %10)
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.12) #2
  %13 = getelementptr inbounds i8, ptr %0, i64 12
  %14 = load i32, ptr %13, align 4, !tbaa !12
  tail call void @prtu32(i32 noundef %14)
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.12) #2
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = load i32, ptr %17, align 4, !tbaa !12
  tail call void @prtu32(i32 noundef %18)
  %19 = getelementptr inbounds i8, ptr %0, i64 20
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str.12) #2
  %22 = load i32, ptr %19, align 4, !tbaa !12
  tail call void @prtu32(i32 noundef %22)
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef nonnull @.str.12) #2
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  %26 = load i32, ptr %25, align 4, !tbaa !12
  tail call void @prtu32(i32 noundef %26)
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.13) #2
  %29 = load ptr, ptr @stderr, align 8, !tbaa !5
  %30 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.14) #2
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = load i32, ptr %4, align 4, !tbaa !9
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef nonnull @.str.11, i32 noundef %32) #2
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str.12) #2
  %36 = load i32, ptr %7, align 4, !tbaa !12
  tail call void @prtu32(i32 noundef %36)
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef nonnull @.str.12) #2
  %39 = load i32, ptr %13, align 4, !tbaa !12
  tail call void @prtu32(i32 noundef %39)
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef nonnull @.str.12) #2
  %42 = load i32, ptr %17, align 4, !tbaa !12
  tail call void @prtu32(i32 noundef %42)
  %43 = getelementptr inbounds i8, ptr %0, i64 28
  %44 = load ptr, ptr @stderr, align 8, !tbaa !5
  %45 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef nonnull @.str.12) #2
  %46 = load i32, ptr %43, align 4, !tbaa !12
  tail call void @prtu32(i32 noundef %46)
  %47 = load ptr, ptr @stderr, align 8, !tbaa !5
  %48 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef nonnull @.str.12) #2
  %49 = getelementptr inbounds i8, ptr %0, i64 32
  %50 = load i32, ptr %49, align 4, !tbaa !12
  tail call void @prtu32(i32 noundef %50)
  %51 = load ptr, ptr @stderr, align 8, !tbaa !5
  %52 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef nonnull @.str.13) #2
  %53 = load i64, ptr @nfailed, align 8, !tbaa !13
  %54 = add i64 %53, 1
  store i64 %54, ptr @nfailed, align 8, !tbaa !13
  ret void
}

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 = { 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 = { 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 = !{!10, !11, i64 4}
!10 = !{!"", !11, i64 0, !11, i64 4, !7, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}


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