; LLVM IR from Softmotions/iowow :: src/utils (iwuuid)

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

%union._uuid = type { [4 x i32] }

@.str = external hidden unnamed_addr constant [69 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
define dso_local void @iwu_uuid4_fill(ptr noundef align 1 dereferenceable(36) %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca [37 x i8], align 16
  %4 = alloca %union._uuid, align 4
  %5 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 37, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %6

6:                                                ; preds = %14, %1
  %7 = load i64, ptr %5, align 8, !tbaa !9
  %8 = icmp ult i64 %7, 4
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %17

10:                                               ; preds = %6
  %11 = call i32 @iwu_rand_u32()
  %12 = load i64, ptr %5, align 8, !tbaa !9
  %13 = getelementptr inbounds [4 x i32], ptr %4, i64 0, i64 %12
  store i32 %11, ptr %13, align 4, !tbaa !11
  br label %14

14:                                               ; preds = %10
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = add i64 %15, 1
  store i64 %16, ptr %5, align 8, !tbaa !9
  br label %6, !llvm.loop !12

17:                                               ; preds = %9
  %18 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 6
  %19 = load i8, ptr %18, align 2, !tbaa !11
  %20 = zext i8 %19 to i32
  %21 = and i32 %20, 15
  %22 = or i32 %21, 64
  %23 = trunc i32 %22 to i8
  %24 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 6
  store i8 %23, ptr %24, align 2, !tbaa !11
  %25 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 8
  %26 = load i8, ptr %25, align 4, !tbaa !11
  %27 = zext i8 %26 to i32
  %28 = and i32 %27, 63
  %29 = or i32 %28, 128
  %30 = trunc i32 %29 to i8
  %31 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 8
  store i8 %30, ptr %31, align 4, !tbaa !11
  %32 = getelementptr inbounds [37 x i8], ptr %3, i64 0, i64 0
  %33 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 0
  %34 = load i8, ptr %33, align 4, !tbaa !11
  %35 = zext i8 %34 to i32
  %36 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 1
  %37 = load i8, ptr %36, align 1, !tbaa !11
  %38 = zext i8 %37 to i32
  %39 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 2
  %40 = load i8, ptr %39, align 2, !tbaa !11
  %41 = zext i8 %40 to i32
  %42 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 3
  %43 = load i8, ptr %42, align 1, !tbaa !11
  %44 = zext i8 %43 to i32
  %45 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 4
  %46 = load i8, ptr %45, align 4, !tbaa !11
  %47 = zext i8 %46 to i32
  %48 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 5
  %49 = load i8, ptr %48, align 1, !tbaa !11
  %50 = zext i8 %49 to i32
  %51 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 6
  %52 = load i8, ptr %51, align 2, !tbaa !11
  %53 = zext i8 %52 to i32
  %54 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 7
  %55 = load i8, ptr %54, align 1, !tbaa !11
  %56 = zext i8 %55 to i32
  %57 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 8
  %58 = load i8, ptr %57, align 4, !tbaa !11
  %59 = zext i8 %58 to i32
  %60 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 9
  %61 = load i8, ptr %60, align 1, !tbaa !11
  %62 = zext i8 %61 to i32
  %63 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 10
  %64 = load i8, ptr %63, align 2, !tbaa !11
  %65 = zext i8 %64 to i32
  %66 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 11
  %67 = load i8, ptr %66, align 1, !tbaa !11
  %68 = zext i8 %67 to i32
  %69 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 12
  %70 = load i8, ptr %69, align 4, !tbaa !11
  %71 = zext i8 %70 to i32
  %72 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 13
  %73 = load i8, ptr %72, align 1, !tbaa !11
  %74 = zext i8 %73 to i32
  %75 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 14
  %76 = load i8, ptr %75, align 2, !tbaa !11
  %77 = zext i8 %76 to i32
  %78 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 15
  %79 = load i8, ptr %78, align 1, !tbaa !11
  %80 = zext i8 %79 to i32
  %81 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %32, i64 noundef 37, ptr noundef @.str, i32 noundef %35, i32 noundef %38, i32 noundef %41, i32 noundef %44, i32 noundef %47, i32 noundef %50, i32 noundef %53, i32 noundef %56, i32 noundef %59, i32 noundef %62, i32 noundef %65, i32 noundef %68, i32 noundef %71, i32 noundef %74, i32 noundef %77, i32 noundef %80) #5
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds [37 x i8], ptr %3, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %82, ptr align 16 %83, i64 36, i1 false)
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 37, ptr %3) #5
  ret void
}

declare i32 @iwu_rand_u32() #2

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

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

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; 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 [69 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
define dso_local void @iwu_uuid4_fill(ptr nocapture noundef writeonly align 1 dereferenceable(36) %0) local_unnamed_addr #1 {
  %2 = alloca [37 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 37, ptr nonnull %2) #5
  %3 = tail call i32 @iwu_rand_u32() #5
  %4 = tail call i32 @iwu_rand_u32() #5
  %5 = tail call i32 @iwu_rand_u32() #5
  %6 = tail call i32 @iwu_rand_u32() #5
  %.sroa.7.6.extract.shift = lshr i32 %4, 16
  %7 = and i32 %.sroa.7.6.extract.shift, 15
  %.sroa.7.6.insert.ext = or disjoint i32 %7, 64
  %8 = and i32 %5, 63
  %.sroa.13.8.insert.ext = or disjoint i32 %8, 128
  %9 = and i32 %3, 255
  %.sroa.0.1.extract.shift = lshr i32 %3, 8
  %10 = and i32 %.sroa.0.1.extract.shift, 255
  %.sroa.0.2.extract.shift = lshr i32 %3, 16
  %11 = and i32 %.sroa.0.2.extract.shift, 255
  %.sroa.0.3.extract.shift = lshr i32 %3, 24
  %12 = and i32 %4, 255
  %.sroa.7.5.extract.shift = lshr i32 %4, 8
  %13 = and i32 %.sroa.7.5.extract.shift, 255
  %.sroa.7.7.extract.shift = lshr i32 %4, 24
  %.sroa.13.9.extract.shift = lshr i32 %5, 8
  %14 = and i32 %.sroa.13.9.extract.shift, 255
  %.sroa.13.10.extract.shift = lshr i32 %5, 16
  %15 = and i32 %.sroa.13.10.extract.shift, 255
  %.sroa.13.11.extract.shift = lshr i32 %5, 24
  %16 = and i32 %6, 255
  %.sroa.19.13.extract.shift = lshr i32 %6, 8
  %17 = and i32 %.sroa.19.13.extract.shift, 255
  %.sroa.19.14.extract.shift = lshr i32 %6, 16
  %18 = and i32 %.sroa.19.14.extract.shift, 255
  %.sroa.19.15.extract.shift = lshr i32 %6, 24
  %19 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %2, i64 noundef 37, ptr noundef nonnull @.str, i32 noundef %9, i32 noundef %10, i32 noundef %11, i32 noundef %.sroa.0.3.extract.shift, i32 noundef %12, i32 noundef %13, i32 noundef %.sroa.7.6.insert.ext, i32 noundef %.sroa.7.7.extract.shift, i32 noundef %.sroa.13.8.insert.ext, i32 noundef %14, i32 noundef %15, i32 noundef %.sroa.13.11.extract.shift, i32 noundef %16, i32 noundef %17, i32 noundef %18, i32 noundef %.sroa.19.15.extract.shift) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(36) %0, ptr noundef nonnull align 16 dereferenceable(36) %2, i64 36, i1 false)
  call void @llvm.lifetime.end.p0(i64 37, ptr nonnull %2) #5
  ret void
}

declare i32 @iwu_rand_u32() local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

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 = { "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 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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)"}


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