; LLVM IR from kacperks/Fractal_Engine :: Engine/Thirdparty/cmake/Engine/Thirdparty/cmake/openal-soft/examples/common_ (InitAL)

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

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @InitAL(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store ptr null, ptr %7, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %48

12:                                               ; preds = %2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %48

15:                                               ; preds = %12
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = icmp sgt i32 %17, 1
  br i1 %18, label %19, label %48

19:                                               ; preds = %15
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds ptr, ptr %21, i64 0
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %24 = call i32 @strcmp(ptr noundef %23, ptr noundef @.str) #6
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %48

26:                                               ; preds = %19
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = getelementptr inbounds ptr, ptr %28, i64 1
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = call ptr @alcOpenDevice(ptr noundef %30)
  store ptr %31, ptr %7, align 8, !tbaa !5
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %41, label %34

34:                                               ; preds = %26
  %35 = load ptr, ptr @stderr, align 8, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = getelementptr inbounds ptr, ptr %37, i64 1
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef @.str.1, ptr noundef %39) #5
  br label %41

41:                                               ; preds = %34, %26
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %44 = getelementptr inbounds ptr, ptr %43, i64 2
  store ptr %44, ptr %42, align 8, !tbaa !5
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load i32, ptr %45, align 4, !tbaa !9
  %47 = sub nsw i32 %46, 2
  store i32 %47, ptr %45, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %41, %19, %15, %12, %2
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %53, label %51

51:                                               ; preds = %48
  %52 = call ptr @alcOpenDevice(ptr noundef null)
  store ptr %52, ptr %7, align 8, !tbaa !5
  br label %53

53:                                               ; preds = %51, %48
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  br i1 %55, label %59, label %56

56:                                               ; preds = %53
  %57 = load ptr, ptr @stderr, align 8, !tbaa !5
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef @.str.2) #5
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %99

59:                                               ; preds = %53
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = call ptr @alcCreateContext(ptr noundef %60, ptr noundef null)
  store ptr %61, ptr %8, align 8, !tbaa !5
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = icmp eq ptr %62, null
  br i1 %63, label %69, label %64

64:                                               ; preds = %59
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = call signext i8 @alcMakeContextCurrent(ptr noundef %65)
  %67 = sext i8 %66 to i32
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %79

69:                                               ; preds = %64, %59
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %74

72:                                               ; preds = %69
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  call void @alcDestroyContext(ptr noundef %73)
  br label %74

74:                                               ; preds = %72, %69
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = call signext i8 @alcCloseDevice(ptr noundef %75)
  %77 = load ptr, ptr @stderr, align 8, !tbaa !5
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %77, ptr noundef @.str.3) #5
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %99

79:                                               ; preds = %64
  store ptr null, ptr %6, align 8, !tbaa !5
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = call signext i8 @alcIsExtensionPresent(ptr noundef %80, ptr noundef @.str.4)
  %82 = icmp ne i8 %81, 0
  br i1 %82, label %83, label %86

83:                                               ; preds = %79
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = call ptr @alcGetString(ptr noundef %84, i32 noundef 4115)
  store ptr %85, ptr %6, align 8, !tbaa !5
  br label %86

86:                                               ; preds = %83, %79
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = icmp ne ptr %87, null
  br i1 %88, label %89, label %93

89:                                               ; preds = %86
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = call i32 @alcGetError(ptr noundef %90)
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %96

93:                                               ; preds = %89, %86
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = call ptr @alcGetString(ptr noundef %94, i32 noundef 4101)
  store ptr %95, ptr %6, align 8, !tbaa !5
  br label %96

96:                                               ; preds = %93, %89
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, ptr noundef %97)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %99

99:                                               ; preds = %96, %74, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %100 = load i32, ptr %3, align 4
  ret i32 %100
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

declare ptr @alcOpenDevice(ptr noundef) #3

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

declare ptr @alcCreateContext(ptr noundef, ptr noundef) #3

declare signext i8 @alcMakeContextCurrent(ptr noundef) #3

declare void @alcDestroyContext(ptr noundef) #3

declare signext i8 @alcCloseDevice(ptr noundef) #3

declare signext i8 @alcIsExtensionPresent(ptr noundef, ptr noundef) #3

declare ptr @alcGetString(ptr noundef, i32 noundef) #3

declare i32 @alcGetError(ptr noundef) #3

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

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

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 = { nounwind willreturn memory(read) "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 = { "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 "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 = { nounwind willreturn memory(read) }

!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 = !{!"int", !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"

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @InitAL(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = icmp ne ptr %1, null
  %4 = icmp ne ptr %0, null
  %or.cond = and i1 %4, %3
  br i1 %or.cond, label %5, label %.thread

5:                                                ; preds = %2
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 1
  br i1 %7, label %8, label %.thread

8:                                                ; preds = %5
  %9 = load ptr, ptr %0, align 8, !tbaa !9
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %10, ptr noundef nonnull dereferenceable(1) @.str) #4
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %.thread

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %9, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = tail call ptr @alcOpenDevice(ptr noundef %15) #5
  %.not = icmp eq ptr %16, null
  br i1 %.not, label %.thread39, label %.thread41

.thread39:                                        ; preds = %13
  %17 = load ptr, ptr @stderr, align 8, !tbaa !9
  %18 = load ptr, ptr %0, align 8, !tbaa !9
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.1, ptr noundef %20) #6
  %22 = load ptr, ptr %0, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  store ptr %23, ptr %0, align 8, !tbaa !9
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = add nsw i32 %24, -2
  store i32 %25, ptr %1, align 4, !tbaa !5
  br label %.thread

.thread41:                                        ; preds = %13
  %26 = load ptr, ptr %0, align 8, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %26, i64 16
  store ptr %27, ptr %0, align 8, !tbaa !9
  %28 = load i32, ptr %1, align 4, !tbaa !5
  %29 = add nsw i32 %28, -2
  store i32 %29, ptr %1, align 4, !tbaa !5
  br label %34

.thread:                                          ; preds = %2, %5, %8, %.thread39
  %30 = tail call ptr @alcOpenDevice(ptr noundef null) #5
  %.not32 = icmp eq ptr %30, null
  br i1 %.not32, label %31, label %34

31:                                               ; preds = %.thread
  %32 = load ptr, ptr @stderr, align 8, !tbaa !9
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str.2) #6
  br label %53

34:                                               ; preds = %.thread41, %.thread
  %.144 = phi ptr [ %16, %.thread41 ], [ %30, %.thread ]
  %35 = tail call ptr @alcCreateContext(ptr noundef nonnull %.144, ptr noundef null) #5
  %cond = icmp eq ptr %35, null
  br i1 %cond, label %40, label %36

36:                                               ; preds = %34
  %37 = tail call signext i8 @alcMakeContextCurrent(ptr noundef nonnull %35) #5
  %38 = icmp eq i8 %37, 0
  br i1 %38, label %39, label %44

39:                                               ; preds = %36
  tail call void @alcDestroyContext(ptr noundef nonnull %35) #5
  br label %40

40:                                               ; preds = %34, %39
  %41 = tail call signext i8 @alcCloseDevice(ptr noundef nonnull %.144) #5
  %42 = load ptr, ptr @stderr, align 8, !tbaa !9
  %43 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef nonnull @.str.3) #6
  br label %53

44:                                               ; preds = %36
  %45 = tail call signext i8 @alcIsExtensionPresent(ptr noundef nonnull %.144, ptr noundef nonnull @.str.4) #5
  %.not33 = icmp eq i8 %45, 0
  br i1 %.not33, label %.thread45, label %46

46:                                               ; preds = %44
  %47 = tail call ptr @alcGetString(ptr noundef nonnull %.144, i32 noundef 4115) #5
  %.not34 = icmp eq ptr %47, null
  br i1 %.not34, label %.thread45, label %48

48:                                               ; preds = %46
  %49 = tail call i32 @alcGetError(ptr noundef nonnull %.144) #5
  %.not35 = icmp eq i32 %49, 0
  br i1 %.not35, label %51, label %.thread45

.thread45:                                        ; preds = %44, %48, %46
  %50 = tail call ptr @alcGetString(ptr noundef nonnull %.144, i32 noundef 4101) #5
  br label %51

51:                                               ; preds = %.thread45, %48
  %.126 = phi ptr [ %50, %.thread45 ], [ %47, %48 ]
  %52 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef %.126)
  br label %53

53:                                               ; preds = %51, %40, %31
  %.0 = phi i32 [ 1, %40 ], [ 0, %51 ], [ 1, %31 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

declare ptr @alcOpenDevice(ptr noundef) local_unnamed_addr #2

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

declare ptr @alcCreateContext(ptr noundef, ptr noundef) local_unnamed_addr #2

declare signext i8 @alcMakeContextCurrent(ptr noundef) local_unnamed_addr #2

declare void @alcDestroyContext(ptr noundef) local_unnamed_addr #2

declare signext i8 @alcCloseDevice(ptr noundef) local_unnamed_addr #2

declare signext i8 @alcIsExtensionPresent(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @alcGetString(ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @alcGetError(ptr noundef) local_unnamed_addr #2

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

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 nofree nounwind willreturn memory(argmem: read) "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 = { nounwind willreturn memory(read) }
attributes #5 = { nounwind }
attributes #6 = { cold 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}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass