; LLVM IR from clunietp/libgmsd :: test (main)

; 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.timeb = type { i64, i16, i16, i16 }

@main.REF_FILE = external hidden global ptr, align 8
@main.TEST_FILES = external hidden global [5 x ptr], align 16
@main.TEST_FILES_RESULTS = external hidden constant [5 x double], align 16
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [44 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 zeroext i1 @compare(ptr noundef, ptr noundef, double noundef, i64 noundef) #1

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

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

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

9:                                                ; preds = %28, %0
  %10 = load i32, ptr %7, align 4, !tbaa !5
  %11 = icmp ult i32 %10, 5
  br i1 %11, label %12, label %31

12:                                               ; preds = %9
  %13 = load ptr, ptr @main.REF_FILE, align 8, !tbaa !11
  %14 = load i32, ptr %7, align 4, !tbaa !5
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds [5 x ptr], ptr @main.TEST_FILES, i64 0, i64 %15
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds [5 x double], ptr @main.TEST_FILES_RESULTS, i64 0, i64 %19
  %21 = load double, ptr %20, align 8, !tbaa !13
  %22 = call zeroext i1 @compare(ptr noundef %13, ptr noundef %17, double noundef %21, i64 noundef 1)
  br i1 %22, label %23, label %25

23:                                               ; preds = %12
  %24 = load i32, ptr %3, align 4, !tbaa !5
  br label %26

25:                                               ; preds = %12
  br label %26

26:                                               ; preds = %25, %23
  %27 = phi i32 [ %24, %23 ], [ -1, %25 ]
  store i32 %27, ptr %3, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %26
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = add i32 %29, 1
  store i32 %30, ptr %7, align 4, !tbaa !5
  br label %9, !llvm.loop !15

31:                                               ; preds = %9
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %36

34:                                               ; preds = %31
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  br label %38

36:                                               ; preds = %31
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  br label %38

38:                                               ; preds = %36, %34
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef 100)
  %40 = call i32 @ftime(ptr noundef %4)
  %41 = load ptr, ptr @main.REF_FILE, align 8, !tbaa !11
  %42 = load ptr, ptr @main.TEST_FILES, align 16, !tbaa !11
  %43 = load double, ptr @main.TEST_FILES_RESULTS, align 16, !tbaa !13
  %44 = call zeroext i1 @compare(ptr noundef %41, ptr noundef %42, double noundef %43, i64 noundef 100)
  %45 = call i32 @ftime(ptr noundef %5)
  %46 = getelementptr inbounds %struct.timeb, ptr %5, i32 0, i32 0
  %47 = load i64, ptr %46, align 8, !tbaa !17
  %48 = getelementptr inbounds %struct.timeb, ptr %4, i32 0, i32 0
  %49 = load i64, ptr %48, align 8, !tbaa !17
  %50 = sub nsw i64 %47, %49
  %51 = mul nsw i64 %50, 1000
  %52 = getelementptr inbounds %struct.timeb, ptr %5, i32 0, i32 1
  %53 = load i16, ptr %52, align 8, !tbaa !20
  %54 = zext i16 %53 to i64
  %55 = add nsw i64 %51, %54
  %56 = getelementptr inbounds %struct.timeb, ptr %4, i32 0, i32 1
  %57 = load i16, ptr %56, align 8, !tbaa !20
  %58 = zext i16 %57 to i64
  %59 = sub nsw i64 %55, %58
  store i64 %59, ptr %6, align 8, !tbaa !9
  %60 = load i64, ptr %6, align 8, !tbaa !9
  %61 = load i64, ptr %6, align 8, !tbaa !9
  %62 = sitofp i64 %61 to double
  %63 = fdiv double %62, 1.000000e+02
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, i64 noundef %60, double noundef %63)
  %65 = load i32, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 %65
}

declare i32 @ftime(ptr noundef) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 = !{!"int", !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, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !10, i64 0}
!18 = !{!"timeb", !10, i64 0, !19, i64 8, !19, i64 10, !19, i64 12}
!19 = !{!"short", !7, i64 0}
!20 = !{!18, !19, i64 8}


; 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.timeb = type { i64, i16, i16, i16 }

@main.REF_FILE = external hidden local_unnamed_addr global ptr, align 8
@main.TEST_FILES = external hidden local_unnamed_addr global [5 x ptr], align 16
@main.TEST_FILES_RESULTS = external hidden local_unnamed_addr constant [5 x double], align 16
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [44 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 zeroext i1 @compare(ptr noundef, ptr noundef, double noundef, i64 noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @main() local_unnamed_addr #1 {
  %1 = alloca %struct.timeb, align 8
  %2 = alloca %struct.timeb, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %1, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %2, i8 0, i64 16, i1 false)
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %4 = load ptr, ptr @main.REF_FILE, align 8, !tbaa !5
  %5 = load ptr, ptr @main.TEST_FILES, align 16, !tbaa !5
  %6 = load double, ptr @main.TEST_FILES_RESULTS, align 16, !tbaa !9
  %7 = tail call zeroext i1 @compare(ptr noundef %4, ptr noundef %5, double noundef %6, i64 noundef 1)
  %8 = load ptr, ptr @main.REF_FILE, align 8, !tbaa !5
  %9 = load ptr, ptr getelementptr inbounds (i8, ptr @main.TEST_FILES, i64 8), align 8, !tbaa !5
  %10 = load double, ptr getelementptr inbounds (i8, ptr @main.TEST_FILES_RESULTS, i64 8), align 8, !tbaa !9
  %11 = tail call zeroext i1 @compare(ptr noundef %8, ptr noundef %9, double noundef %10, i64 noundef 1)
  %12 = load ptr, ptr @main.REF_FILE, align 8, !tbaa !5
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @main.TEST_FILES, i64 16), align 16, !tbaa !5
  %14 = load double, ptr getelementptr inbounds (i8, ptr @main.TEST_FILES_RESULTS, i64 16), align 16, !tbaa !9
  %15 = tail call zeroext i1 @compare(ptr noundef %12, ptr noundef %13, double noundef %14, i64 noundef 1)
  %16 = load ptr, ptr @main.REF_FILE, align 8, !tbaa !5
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @main.TEST_FILES, i64 24), align 8, !tbaa !5
  %18 = load double, ptr getelementptr inbounds (i8, ptr @main.TEST_FILES_RESULTS, i64 24), align 8, !tbaa !9
  %19 = tail call zeroext i1 @compare(ptr noundef %16, ptr noundef %17, double noundef %18, i64 noundef 1)
  %20 = load ptr, ptr @main.REF_FILE, align 8, !tbaa !5
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @main.TEST_FILES, i64 32), align 16, !tbaa !5
  %22 = load double, ptr getelementptr inbounds (i8, ptr @main.TEST_FILES_RESULTS, i64 32), align 16, !tbaa !9
  %23 = tail call zeroext i1 @compare(ptr noundef %20, ptr noundef %21, double noundef %22, i64 noundef 1)
  %24 = select i1 %23, i1 %19, i1 false
  %25 = select i1 %24, i1 %15, i1 false
  %26 = select i1 %25, i1 %11, i1 false
  %27 = select i1 %26, i1 %7, i1 false
  %.str.10..str.11 = select i1 %27, ptr @.str.10, ptr @.str.11
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.10..str.11)
  %narrow15 = xor i1 %27, true
  %29 = sext i1 %narrow15 to i32
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef 100)
  %31 = call i32 @ftime(ptr noundef nonnull %1) #5
  %32 = load ptr, ptr @main.REF_FILE, align 8, !tbaa !5
  %33 = load ptr, ptr @main.TEST_FILES, align 16, !tbaa !5
  %34 = call zeroext i1 @compare(ptr noundef %32, ptr noundef %33, double noundef %6, i64 noundef 100)
  %35 = call i32 @ftime(ptr noundef nonnull %2) #5
  %36 = load i64, ptr %2, align 8, !tbaa !11
  %37 = load i64, ptr %1, align 8, !tbaa !11
  %38 = sub nsw i64 %36, %37
  %39 = mul nsw i64 %38, 1000
  %40 = getelementptr inbounds i8, ptr %2, i64 8
  %41 = load i16, ptr %40, align 8, !tbaa !15
  %42 = zext i16 %41 to i64
  %43 = add nsw i64 %39, %42
  %44 = getelementptr inbounds i8, ptr %1, i64 8
  %45 = load i16, ptr %44, align 8, !tbaa !15
  %46 = zext i16 %45 to i64
  %47 = sub i64 %43, %46
  %48 = sitofp i64 %47 to double
  %49 = fdiv double %48, 1.000000e+02
  %50 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13, i64 noundef %47, double noundef %49)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #5
  ret i32 %29
}

declare i32 @ftime(ptr noundef) local_unnamed_addr #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 }

!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 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"timeb", !13, i64 0, !14, i64 8, !14, i64 10, !14, i64 12}
!13 = !{!"long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !14, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass