; 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] }

@.str.9 = external hidden unnamed_addr constant [5 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 i32 @strtou32(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @read_philox2x32(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %10, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 1, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.kat_instance, ptr %11, i32 0, i32 0
  store i32 0, ptr %12, align 8, !tbaa !11
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.kat_instance, ptr %14, i32 0, i32 1
  %16 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %13, ptr noundef @.str.9, ptr noundef %15, ptr noundef %6) #4
  %17 = load i32, ptr %6, align 4, !tbaa !14
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = sext i32 %17 to i64
  %20 = getelementptr inbounds i8, ptr %18, i64 %19
  store ptr %20, ptr %7, align 8, !tbaa !5
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %21

21:                                               ; preds = %34, %2
  %22 = load i64, ptr %5, align 8, !tbaa !9
  %23 = icmp ult i64 %22, 2
  br i1 %23, label %24, label %37

24:                                               ; preds = %21
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call i32 @strtou32(ptr noundef %25, ptr noundef %8, i32 noundef 16)
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.kat_instance, ptr %27, i32 0, i32 2
  %29 = getelementptr inbounds %struct.philox2x32_kat, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds %struct.r123array2x32, ptr %29, i32 0, i32 0
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = getelementptr inbounds [2 x i32], ptr %30, i64 0, i64 %31
  store i32 %26, ptr %32, align 4, !tbaa !15
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %33, ptr %7, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %24
  %35 = load i64, ptr %5, align 8, !tbaa !9
  %36 = add i64 %35, 1
  store i64 %36, ptr %5, align 8, !tbaa !9
  br label %21, !llvm.loop !16

37:                                               ; preds = %21
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %38

38:                                               ; preds = %52, %37
  %39 = load i64, ptr %5, align 8, !tbaa !9
  %40 = load i64, ptr %9, align 8, !tbaa !9
  %41 = icmp ult i64 %39, %40
  br i1 %41, label %42, label %55

42:                                               ; preds = %38
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = call i32 @strtou32(ptr noundef %43, ptr noundef %8, i32 noundef 16)
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.kat_instance, ptr %45, i32 0, i32 2
  %47 = getelementptr inbounds %struct.philox2x32_kat, ptr %46, i32 0, i32 1
  %48 = getelementptr inbounds %struct.r123array1x32, ptr %47, i32 0, i32 0
  %49 = load i64, ptr %5, align 8, !tbaa !9
  %50 = getelementptr inbounds [1 x i32], ptr %48, i64 0, i64 %49
  store i32 %44, ptr %50, align 4, !tbaa !15
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %51, ptr %7, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %42
  %53 = load i64, ptr %5, align 8, !tbaa !9
  %54 = add i64 %53, 1
  store i64 %54, ptr %5, align 8, !tbaa !9
  br label %38, !llvm.loop !18

55:                                               ; preds = %38
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %69, %55
  %57 = load i64, ptr %5, align 8, !tbaa !9
  %58 = icmp ult i64 %57, 2
  br i1 %58, label %59, label %72

59:                                               ; preds = %56
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = call i32 @strtou32(ptr noundef %60, ptr noundef %8, i32 noundef 16)
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.kat_instance, ptr %62, i32 0, i32 2
  %64 = getelementptr inbounds %struct.philox2x32_kat, ptr %63, i32 0, i32 2
  %65 = getelementptr inbounds %struct.r123array2x32, ptr %64, i32 0, i32 0
  %66 = load i64, ptr %5, align 8, !tbaa !9
  %67 = getelementptr inbounds [2 x i32], ptr %65, i64 0, i64 %66
  store i32 %61, ptr %67, align 4, !tbaa !15
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %68, ptr %7, align 8, !tbaa !5
  br label %69

69:                                               ; preds = %59
  %70 = load i64, ptr %5, align 8, !tbaa !9
  %71 = add i64 %70, 1
  store i64 %71, ptr %5, align 8, !tbaa !9
  br label %56, !llvm.loop !19

72:                                               ; preds = %56
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.kat_instance, ptr %73, i32 0, i32 2
  %75 = getelementptr inbounds %struct.philox2x32_kat, ptr %74, i32 0, i32 3
  %76 = getelementptr inbounds %struct.r123array2x32, ptr %75, i32 0, i32 0
  %77 = getelementptr inbounds [2 x i32], ptr %76, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 4 %77, i8 0, i64 8, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret i32 1
}

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

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

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


; 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.9 = external hidden unnamed_addr constant [5 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: nounwind uwtable
declare dso_local i32 @strtou32(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @read_philox2x32(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
.preheader24:
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  store i32 0, ptr %1, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 4
  %5 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %0, ptr noundef nonnull @.str.9, ptr noundef nonnull %4, ptr noundef nonnull %2) #3
  %6 = load i32, ptr %2, align 4, !tbaa !10
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds i8, ptr %0, i64 %7
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = call i32 @strtou32(ptr noundef %8, ptr noundef nonnull %3, i32 noundef 16)
  store i32 %10, ptr %9, align 4, !tbaa !11
  %11 = load ptr, ptr %3, align 8, !tbaa !12
  %12 = call i32 @strtou32(ptr noundef %11, ptr noundef nonnull %3, i32 noundef 16)
  %13 = getelementptr inbounds i8, ptr %1, i64 12
  store i32 %12, ptr %13, align 4, !tbaa !11
  %14 = load ptr, ptr %3, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %1, i64 16
  %16 = call i32 @strtou32(ptr noundef %14, ptr noundef nonnull %3, i32 noundef 16)
  store i32 %16, ptr %15, align 4, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %1, i64 20
  %.22328 = load ptr, ptr %3, align 8, !tbaa !12
  %18 = call i32 @strtou32(ptr noundef %.22328, ptr noundef nonnull %3, i32 noundef 16)
  store i32 %18, ptr %17, align 4, !tbaa !11
  %.22328.1 = load ptr, ptr %3, align 8, !tbaa !12
  %19 = call i32 @strtou32(ptr noundef %.22328.1, ptr noundef nonnull %3, i32 noundef 16)
  %20 = getelementptr inbounds i8, ptr %1, i64 24
  store i32 %19, ptr %20, align 4, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %1, i64 28
  store i64 0, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  ret i32 1
}

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

attributes #0 = { mustprogress 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 = { 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 = { 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 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !8, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!8, !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}


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