; LLVM IR from kalininalab/rinminer :: rinminer (rinminer)

; 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.output_t = type { ptr, i32, i64, i64, i64, ptr, i32, %union.pthread_mutex_t, i32, i32, i32, i32 }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

@stderr = external global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [32 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #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: nounwind uwtable
define dso_local void @init_output(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #4 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.output_t, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !11
  store i32 %4, ptr %11, align 4, !tbaa !11
  store i32 %5, ptr %12, align 4, !tbaa !11
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 112, i1 false)
  %15 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 0
  %16 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 1
  %17 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 2
  %18 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 3
  %19 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 4
  %20 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 5
  %21 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 6
  %22 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 7
  %23 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 8
  %24 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 9
  %25 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 10
  %26 = getelementptr inbounds %struct.output_t, ptr %13, i32 0, i32 11
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %13, i64 112, i1 false), !tbaa.struct !13
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %32, label %29

29:                                               ; preds = %6
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.output_t, ptr %30, i32 0, i32 1
  store i32 -1, ptr %31, align 8, !tbaa !15
  br label %86

32:                                               ; preds = %6
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = call i32 (ptr, i32, ...) @open(ptr noundef %33, i32 noundef 578, i32 noundef 420)
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.output_t, ptr %35, i32 0, i32 1
  store i32 %34, ptr %36, align 8, !tbaa !15
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.output_t, ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 8, !tbaa !15
  %40 = icmp eq i32 %39, -1
  br i1 %40, label %41, label %47

41:                                               ; preds = %32
  %42 = load ptr, ptr @stderr, align 8, !tbaa !5
  %43 = call ptr @__errno_location() #7
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = call ptr @strerror(i32 noundef %44) #8
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef @.str.12, ptr noundef %45) #8
  call void @exit(i32 noundef 1) #9
  unreachable

47:                                               ; preds = %32
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.output_t, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 8, !tbaa !15
  %51 = load i64, ptr %9, align 8, !tbaa !9
  %52 = call i32 @ftruncate(i32 noundef %50, i64 noundef %51) #8
  %53 = load i64, ptr %9, align 8, !tbaa !9
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.output_t, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 8, !tbaa !15
  %57 = call ptr @mmap(ptr noundef null, i64 noundef %53, i32 noundef 3, i32 noundef 1, i32 noundef %56, i64 noundef 0) #8
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.output_t, ptr %58, i32 0, i32 0
  store ptr %57, ptr %59, align 8, !tbaa !17
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.output_t, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !17
  %63 = icmp eq ptr %62, inttoptr (i64 -1 to ptr)
  br i1 %63, label %64, label %70

64:                                               ; preds = %47
  %65 = load ptr, ptr @stderr, align 8, !tbaa !5
  %66 = call ptr @__errno_location() #7
  %67 = load i32, ptr %66, align 4, !tbaa !11
  %68 = call ptr @strerror(i32 noundef %67) #8
  %69 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str.13, ptr noundef %68) #8
  call void @exit(i32 noundef 1) #9
  unreachable

70:                                               ; preds = %47
  %71 = load i64, ptr %9, align 8, !tbaa !9
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.output_t, ptr %72, i32 0, i32 2
  store i64 %71, ptr %73, align 8, !tbaa !18
  %74 = load i32, ptr %10, align 4, !tbaa !11
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.output_t, ptr %75, i32 0, i32 8
  store i32 %74, ptr %76, align 8, !tbaa !19
  %77 = load i32, ptr %11, align 4, !tbaa !11
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.output_t, ptr %78, i32 0, i32 10
  store i32 %77, ptr %79, align 8, !tbaa !20
  %80 = load i32, ptr %12, align 4, !tbaa !11
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.output_t, ptr %81, i32 0, i32 11
  store i32 %80, ptr %82, align 4, !tbaa !21
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.output_t, ptr %83, i32 0, i32 7
  %85 = call i32 @pthread_mutex_init(ptr noundef %84, ptr noundef null) #8
  br label %86

86:                                               ; preds = %70, %29
  ret void
}

declare i32 @open(ptr noundef, i32 noundef, ...) #5

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #1

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #6

; Function Attrs: nounwind
declare i32 @ftruncate(i32 noundef, i64 noundef) #1

; Function Attrs: nounwind
declare ptr @mmap(ptr noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef, i64 noundef) #1

; Function Attrs: nounwind
declare i32 @pthread_mutex_init(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { 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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { "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 #6 = { nounwind willreturn memory(none) "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 #7 = { nounwind willreturn memory(none) }
attributes #8 = { nounwind }
attributes #9 = { 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 = !{!"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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i64 0, i64 8, !5, i64 8, i64 4, !11, i64 16, i64 8, !9, i64 24, i64 8, !9, i64 32, i64 8, !9, i64 40, i64 8, !5, i64 48, i64 4, !11, i64 56, i64 40, !14, i64 96, i64 4, !11, i64 100, i64 4, !11, i64 104, i64 4, !11, i64 108, i64 4, !11}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !12, i64 8}
!16 = !{!"output_t", !6, i64 0, !12, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !6, i64 40, !12, i64 48, !7, i64 56, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108}
!17 = !{!16, !6, i64 0}
!18 = !{!16, !10, i64 16}
!19 = !{!16, !12, i64 96}
!20 = !{!16, !12, i64 104}
!21 = !{!16, !12, i64 108}


; 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
@.str.12 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [32 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @init_output(ptr noundef %0, ptr noundef readonly %1, i64 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #3 {
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(112) %0, i8 0, i64 112, i1 false)
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %7, label %9

7:                                                ; preds = %6
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 -1, ptr %8, align 8, !tbaa !5
  br label %37

9:                                                ; preds = %6
  %10 = tail call i32 (ptr, i32, ...) @open(ptr noundef nonnull %1, i32 noundef 578, i32 noundef 420) #7
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %10, ptr %11, align 8, !tbaa !5
  %12 = icmp eq i32 %10, -1
  br i1 %12, label %13, label %19

13:                                               ; preds = %9
  %14 = load ptr, ptr @stderr, align 8, !tbaa !12
  %15 = tail call ptr @__errno_location() #8
  %16 = load i32, ptr %15, align 4, !tbaa !13
  %17 = tail call ptr @strerror(i32 noundef %16) #7
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.12, ptr noundef %17) #9
  tail call void @exit(i32 noundef 1) #10
  unreachable

19:                                               ; preds = %9
  %20 = tail call i32 @ftruncate(i32 noundef %10, i64 noundef %2) #7
  %21 = load i32, ptr %11, align 8, !tbaa !5
  %22 = tail call ptr @mmap(ptr noundef null, i64 noundef %2, i32 noundef 3, i32 noundef 1, i32 noundef %21, i64 noundef 0) #7
  store ptr %22, ptr %0, align 8, !tbaa !14
  %23 = icmp eq ptr %22, inttoptr (i64 -1 to ptr)
  br i1 %23, label %24, label %30

24:                                               ; preds = %19
  %25 = load ptr, ptr @stderr, align 8, !tbaa !12
  %26 = tail call ptr @__errno_location() #8
  %27 = load i32, ptr %26, align 4, !tbaa !13
  %28 = tail call ptr @strerror(i32 noundef %27) #7
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.13, ptr noundef %28) #9
  tail call void @exit(i32 noundef 1) #10
  unreachable

30:                                               ; preds = %19
  %31 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %2, ptr %31, align 8, !tbaa !15
  %32 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 %3, ptr %32, align 8, !tbaa !16
  %33 = getelementptr inbounds i8, ptr %0, i64 104
  store i32 %4, ptr %33, align 8, !tbaa !17
  %34 = getelementptr inbounds i8, ptr %0, i64 108
  store i32 %5, ptr %34, align 4, !tbaa !18
  %35 = getelementptr inbounds i8, ptr %0, i64 56
  %36 = tail call i32 @pthread_mutex_init(ptr noundef nonnull %35, ptr noundef null) #7
  br label %37

37:                                               ; preds = %30, %7
  ret void
}

; Function Attrs: nofree
declare noundef i32 @open(ptr nocapture noundef readonly, i32 noundef, ...) local_unnamed_addr #4

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #6

; Function Attrs: nounwind
declare i32 @ftruncate(i32 noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: nounwind
declare ptr @mmap(ptr noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: nounwind
declare i32 @pthread_mutex_init(ptr noundef, ptr noundef) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 #3 = { 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 #4 = { nofree "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 "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 #6 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }
attributes #9 = { cold nounwind }
attributes #10 = { 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, !10, i64 8}
!6 = !{!"output_t", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !7, i64 40, !10, i64 48, !8, i64 56, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !7, i64 0}
!15 = !{!6, !11, i64 16}
!16 = !{!6, !10, i64 96}
!17 = !{!6, !10, i64 104}
!18 = !{!6, !10, i64 108}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass