; LLVM IR from ANL-CESAR/XSBench :: opencl (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.Inputs = type { i32, i64, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.SimulationData = type { ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i64, i32, i32, ptr, i32, ptr, i32 }

@.str = external hidden unnamed_addr constant [31 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [128 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [22 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 i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca %struct.Inputs, align 8
  %13 = alloca %struct.SimulationData, align 8
  %14 = alloca %struct.SimulationData, align 8
  %15 = alloca %struct.SimulationData, align 8
  %16 = alloca double, align 8
  %17 = 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 4, ptr %6) #5
  store i32 20, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 1, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr %12) #5
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = load ptr, ptr %5, align 8, !tbaa !9
  call void @read_CLI(ptr dead_on_unwind writable sret(%struct.Inputs) align 8 %12, i32 noundef %18, ptr noundef %19)
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %25

22:                                               ; preds = %2
  %23 = load i32, ptr %10, align 4, !tbaa !5
  %24 = load i32, ptr %6, align 4, !tbaa !5
  call void @print_inputs(ptr noundef byval(%struct.Inputs) align 8 %12, i32 noundef %23, i32 noundef %24)
  br label %25

25:                                               ; preds = %22, %2
  call void @llvm.lifetime.start.p0(i64 112, ptr %13) #5
  %26 = getelementptr inbounds %struct.Inputs, ptr %12, i32 0, i32 9
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %30

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 112, ptr %14) #5
  call void @binary_read(ptr dead_on_unwind writable sret(%struct.SimulationData) align 8 %14, ptr noundef byval(%struct.Inputs) align 8 %12)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %14, i64 112, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 112, ptr %14) #5
  br label %32

30:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 112, ptr %15) #5
  %31 = load i32, ptr %7, align 4, !tbaa !5
  call void @grid_init_do_not_profile(ptr dead_on_unwind writable sret(%struct.SimulationData) align 8 %15, ptr noundef byval(%struct.Inputs) align 8 %12, i32 noundef %31)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %15, i64 112, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 112, ptr %15) #5
  br label %32

32:                                               ; preds = %30, %29
  %33 = getelementptr inbounds %struct.Inputs, ptr %12, i32 0, i32 9
  %34 = load i32, ptr %33, align 8, !tbaa !11
  %35 = icmp eq i32 %34, 2
  br i1 %35, label %36, label %40

36:                                               ; preds = %32
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  call void @binary_write(ptr noundef byval(%struct.Inputs) align 8 %12, ptr noundef byval(%struct.SimulationData) align 8 %13)
  br label %40

40:                                               ; preds = %39, %36, %32
  %41 = call double @get_time()
  store double %41, ptr %8, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %42 = getelementptr inbounds %struct.Inputs, ptr %12, i32 0, i32 8
  %43 = load i32, ptr %42, align 4, !tbaa !18
  %44 = icmp eq i32 %43, 2
  br i1 %44, label %45, label %57

45:                                               ; preds = %40
  %46 = getelementptr inbounds %struct.Inputs, ptr %12, i32 0, i32 10
  %47 = load i32, ptr %46, align 4, !tbaa !19
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %52

49:                                               ; preds = %45
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = call i64 @run_event_based_simulation(ptr noundef byval(%struct.Inputs) align 8 %12, ptr noundef byval(%struct.SimulationData) align 8 %13, i32 noundef %50, ptr noundef %16)
  store i64 %51, ptr %11, align 8, !tbaa !20
  br label %56

52:                                               ; preds = %45
  %53 = getelementptr inbounds %struct.Inputs, ptr %12, i32 0, i32 10
  %54 = load i32, ptr %53, align 4, !tbaa !19
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %54)
  call void @exit(i32 noundef 1) #6
  unreachable

56:                                               ; preds = %49
  br label %59

57:                                               ; preds = %40
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @exit(i32 noundef 1) #6
  unreachable

59:                                               ; preds = %56
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %65

62:                                               ; preds = %59
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %65

65:                                               ; preds = %62, %59
  %66 = call double @get_time()
  store double %66, ptr %9, align 8, !tbaa !16
  %67 = load i64, ptr %11, align 8, !tbaa !20
  %68 = urem i64 %67, 999983
  store i64 %68, ptr %11, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = load double, ptr %9, align 8, !tbaa !16
  %71 = load double, ptr %8, align 8, !tbaa !16
  %72 = fsub double %70, %71
  %73 = load i32, ptr %10, align 4, !tbaa !5
  %74 = load i64, ptr %11, align 8, !tbaa !20
  %75 = load double, ptr %16, align 8, !tbaa !16
  %76 = call i32 @print_results(ptr noundef byval(%struct.Inputs) align 8 %12, i32 noundef %69, double noundef %72, i32 noundef %73, i64 noundef %74, double noundef %75)
  store i32 %76, ptr %17, align 4, !tbaa !5
  %77 = load i32, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 112, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  ret i32 %77
}

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

declare void @read_CLI(ptr dead_on_unwind writable sret(%struct.Inputs) align 8, i32 noundef, ptr noundef) #2

declare void @print_inputs(ptr noundef byval(%struct.Inputs) align 8, i32 noundef, i32 noundef) #2

declare void @binary_read(ptr dead_on_unwind writable sret(%struct.SimulationData) align 8, ptr noundef byval(%struct.Inputs) align 8) #2

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

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

declare void @grid_init_do_not_profile(ptr dead_on_unwind writable sret(%struct.SimulationData) align 8, ptr noundef byval(%struct.Inputs) align 8, i32 noundef) #2

declare void @binary_write(ptr noundef byval(%struct.Inputs) align 8, ptr noundef byval(%struct.SimulationData) align 8) #2

declare double @get_time() #2

declare i64 @run_event_based_simulation(ptr noundef byval(%struct.Inputs) align 8, ptr noundef byval(%struct.SimulationData) align 8, i32 noundef, ptr noundef) #2

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

declare i32 @print_results(ptr noundef byval(%struct.Inputs) align 8, i32 noundef, double noundef, i32 noundef, i64 noundef, double noundef) #2

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 = { "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: readwrite) }
attributes #4 = { noreturn 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 #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 = !{!"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}
!11 = !{!12, !6, i64 48}
!12 = !{!"", !6, i64 0, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, i64 52, !6, i64 56, !6, i64 60}
!13 = !{!"long", !7, i64 0}
!14 = !{i64 0, i64 8, !9, i64 8, i64 8, !9, i64 16, i64 8, !9, i64 24, i64 8, !9, i64 32, i64 8, !9, i64 40, i64 8, !9, i64 48, i64 4, !5, i64 52, i64 4, !5, i64 56, i64 4, !5, i64 60, i64 4, !5, i64 64, i64 8, !15, i64 72, i64 4, !5, i64 76, i64 4, !5, i64 80, i64 8, !9, i64 88, i64 4, !5, i64 96, i64 8, !9, i64 104, i64 4, !5}
!15 = !{!13, !13, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!12, !6, i64 44}
!19 = !{!12, !6, i64 52}
!20 = !{!21, !21, i64 0}
!21 = !{!"long long", !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.Inputs = type { i32, i64, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.SimulationData = type { ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i64, i32, i32, ptr, i32, ptr, i32 }

@.str = external hidden unnamed_addr constant [31 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [128 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.Inputs, align 8
  %4 = alloca %struct.SimulationData, align 8
  %5 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %3) #5
  call void @read_CLI(ptr dead_on_unwind nonnull writable sret(%struct.Inputs) align 8 %3, i32 noundef %0, ptr noundef %1) #5
  call void @print_inputs(ptr noundef nonnull byval(%struct.Inputs) align 8 %3, i32 noundef 1, i32 noundef 20) #5
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %4) #5
  %6 = getelementptr inbounds i8, ptr %3, i64 48
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %9, label %10

9:                                                ; preds = %2
  call void @binary_read(ptr dead_on_unwind nonnull writable sret(%struct.SimulationData) align 8 %4, ptr noundef nonnull byval(%struct.Inputs) align 8 %3) #5
  br label %11

10:                                               ; preds = %2
  call void @grid_init_do_not_profile(ptr dead_on_unwind nonnull writable sret(%struct.SimulationData) align 8 %4, ptr noundef nonnull byval(%struct.Inputs) align 8 %3, i32 noundef 0) #5
  br label %11

11:                                               ; preds = %10, %9
  %12 = load i32, ptr %6, align 8, !tbaa !5
  %13 = icmp eq i32 %12, 2
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  call void @binary_write(ptr noundef nonnull byval(%struct.Inputs) align 8 %3, ptr noundef nonnull byval(%struct.SimulationData) align 8 %4) #5
  br label %15

15:                                               ; preds = %14, %11
  %16 = call double @get_time() #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %17 = getelementptr inbounds i8, ptr %3, i64 44
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %19 = icmp eq i32 %18, 2
  br i1 %19, label %20, label %35

20:                                               ; preds = %15
  %21 = getelementptr inbounds i8, ptr %3, i64 52
  %22 = load i32, ptr %21, align 4, !tbaa !12
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %33

24:                                               ; preds = %20
  %25 = call i64 @run_event_based_simulation(ptr noundef nonnull byval(%struct.Inputs) align 8 %3, ptr noundef nonnull byval(%struct.SimulationData) align 8 %4, i32 noundef 0, ptr noundef nonnull %5) #5
  %26 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %28 = call double @get_time() #5
  %29 = urem i64 %25, 999983
  %30 = fsub double %28, %16
  %31 = load double, ptr %5, align 8, !tbaa !13
  %32 = call i32 @print_results(ptr noundef nonnull byval(%struct.Inputs) align 8 %3, i32 noundef 0, double noundef %30, i32 noundef 1, i64 noundef %29, double noundef %31) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #5
  ret i32 %32

33:                                               ; preds = %20
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %22)
  call void @exit(i32 noundef 1) #6
  unreachable

35:                                               ; preds = %15
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  call void @exit(i32 noundef 1) #6
  unreachable
}

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

declare void @read_CLI(ptr dead_on_unwind writable sret(%struct.Inputs) align 8, i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @print_inputs(ptr noundef byval(%struct.Inputs) align 8, i32 noundef, i32 noundef) local_unnamed_addr #2

declare void @binary_read(ptr dead_on_unwind writable sret(%struct.SimulationData) align 8, ptr noundef byval(%struct.Inputs) align 8) local_unnamed_addr #2

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

declare void @grid_init_do_not_profile(ptr dead_on_unwind writable sret(%struct.SimulationData) align 8, ptr noundef byval(%struct.Inputs) align 8, i32 noundef) local_unnamed_addr #2

declare void @binary_write(ptr noundef byval(%struct.Inputs) align 8, ptr noundef byval(%struct.SimulationData) align 8) local_unnamed_addr #2

declare double @get_time() local_unnamed_addr #2

declare i64 @run_event_based_simulation(ptr noundef byval(%struct.Inputs) align 8, ptr noundef byval(%struct.SimulationData) align 8, i32 noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #4

declare i32 @print_results(ptr noundef byval(%struct.Inputs) align 8, i32 noundef, double noundef, i32 noundef, i64 noundef, double noundef) local_unnamed_addr #2

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 = { "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 = { noreturn 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 #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, !7, i64 48}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !7, i64 44}
!12 = !{!6, !7, i64 52}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass