; LLVM IR from Montimage/mmt-security :: src/lib (expression)

; 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.variable_t = type { i32, i32, ptr, ptr, i32, i32, i16 }

@.str = external hidden unnamed_addr constant [46 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [54 x i8], align 1

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @convert_data_type(i32 noundef) #0

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

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

declare ptr @mmt_mem_alloc(i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @expr_create_a_variable(ptr noundef %0, ptr noundef %1, i16 noundef zeroext %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i16 %2, ptr %6, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %8 = call ptr @mmt_mem_alloc(i64 noundef 40)
  store ptr %8, ptr %7, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.variable_t, ptr %10, i32 0, i32 2
  store ptr %9, ptr %11, align 8, !tbaa !11
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.variable_t, ptr %13, i32 0, i32 3
  store ptr %12, ptr %14, align 8, !tbaa !14
  %15 = load i16, ptr %6, align 2, !tbaa !9
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.variable_t, ptr %16, i32 0, i32 6
  store i16 %15, ptr %17, align 8, !tbaa !15
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.variable_t, ptr %18, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = call i32 @get_protocol_id_by_name(ptr noundef %20)
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.variable_t, ptr %22, i32 0, i32 4
  store i32 %21, ptr %23, align 8, !tbaa !16
  br label %24

24:                                               ; preds = %3
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.variable_t, ptr %25, i32 0, i32 4
  %27 = load i32, ptr %26, align 8, !tbaa !16
  %28 = icmp ne i32 %27, -1
  %29 = xor i1 %28, true
  %30 = xor i1 %29, true
  %31 = xor i1 %30, true
  %32 = zext i1 %31 to i32
  %33 = sext i32 %32 to i64
  %34 = call i64 @llvm.expect.i64(i64 %33, i64 0)
  %35 = icmp ne i64 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %24
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 4, ptr noundef @.str, ptr noundef %37)
  call void @exit(i32 noundef 0) #7
  unreachable

38:                                               ; preds = %24
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.variable_t, ptr %39, i32 0, i32 4
  %41 = load i32, ptr %40, align 8, !tbaa !16
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.variable_t, ptr %42, i32 0, i32 3
  %44 = load ptr, ptr %43, align 8, !tbaa !14
  %45 = call i32 @get_attribute_id_by_protocol_id_and_attribute_name(i32 noundef %41, ptr noundef %44)
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.variable_t, ptr %46, i32 0, i32 5
  store i32 %45, ptr %47, align 4, !tbaa !17
  br label %48

48:                                               ; preds = %38
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.variable_t, ptr %49, i32 0, i32 5
  %51 = load i32, ptr %50, align 4, !tbaa !17
  %52 = icmp ne i32 %51, -1
  %53 = xor i1 %52, true
  %54 = xor i1 %53, true
  %55 = xor i1 %54, true
  %56 = zext i1 %55 to i32
  %57 = sext i32 %56 to i64
  %58 = call i64 @llvm.expect.i64(i64 %57, i64 0)
  %59 = icmp ne i64 %58, 0
  br i1 %59, label %60, label %63

60:                                               ; preds = %48
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 4, ptr noundef @.str.1, ptr noundef %61, ptr noundef %62)
  call void @exit(i32 noundef 0) #7
  unreachable

63:                                               ; preds = %48
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.variable_t, ptr %64, i32 0, i32 4
  %66 = load i32, ptr %65, align 8, !tbaa !16
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.variable_t, ptr %67, i32 0, i32 5
  %69 = load i32, ptr %68, align 4, !tbaa !17
  %70 = call i64 @get_attribute_data_type(i32 noundef %66, i32 noundef %69)
  %71 = trunc i64 %70 to i32
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.variable_t, ptr %72, i32 0, i32 1
  store i32 %71, ptr %73, align 4, !tbaa !18
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.variable_t, ptr %74, i32 0, i32 1
  %76 = load i32, ptr %75, align 4, !tbaa !18
  %77 = call i32 @convert_data_type(i32 noundef %76)
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.variable_t, ptr %78, i32 0, i32 0
  store i32 %77, ptr %79, align 8, !tbaa !19
  br label %80

80:                                               ; preds = %63
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.variable_t, ptr %81, i32 0, i32 0
  %83 = load i32, ptr %82, align 8, !tbaa !19
  %84 = icmp ne i32 %83, -1
  %85 = xor i1 %84, true
  %86 = xor i1 %85, true
  %87 = xor i1 %86, true
  %88 = zext i1 %87 to i32
  %89 = sext i32 %88 to i64
  %90 = call i64 @llvm.expect.i64(i64 %89, i64 0)
  %91 = icmp ne i64 %90, 0
  br i1 %91, label %92, label %95

92:                                               ; preds = %80
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 4, ptr noundef @.str.2, ptr noundef %93, ptr noundef %94)
  call void @exit(i32 noundef 0) #7
  unreachable

95:                                               ; preds = %80
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret ptr %96
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @get_protocol_id_by_name(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #4

declare void @mmt_sec_log(i32 noundef, ptr noundef, ...) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @get_attribute_id_by_protocol_id_and_attribute_name(i32 noundef, ptr noundef) #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @get_attribute_data_type(i32 noundef, i32 noundef) #0

attributes #0 = { inlinehint 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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { 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 = !{!"short", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !13, i64 24, !13, i64 28, !10, i64 32}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !10, i64 32}
!16 = !{!12, !13, i64 24}
!17 = !{!12, !13, i64 28}
!18 = !{!12, !13, i64 4}
!19 = !{!12, !13, 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 [46 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [54 x i8], align 1

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @convert_data_type(i32 noundef) local_unnamed_addr #0

declare ptr @mmt_mem_alloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @expr_create_a_variable(ptr noundef %0, ptr noundef %1, i16 noundef zeroext %2) local_unnamed_addr #2 {
  %4 = tail call ptr @mmt_mem_alloc(i64 noundef 40) #4
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr %1, ptr %6, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %4, i64 32
  store i16 %2, ptr %7, align 8, !tbaa !13
  %8 = tail call i32 @get_protocol_id_by_name(ptr noundef %0)
  %9 = getelementptr inbounds i8, ptr %4, i64 24
  store i32 %8, ptr %9, align 8, !tbaa !14
  %.not = icmp eq i32 %8, -1
  br i1 %.not, label %10, label %11, !prof !15

10:                                               ; preds = %3
  tail call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 4, ptr noundef nonnull @.str, ptr noundef %0) #4
  tail call void @exit(i32 noundef 0) #5
  unreachable

11:                                               ; preds = %3
  %12 = load ptr, ptr %6, align 8, !tbaa !12
  %13 = tail call i32 @get_attribute_id_by_protocol_id_and_attribute_name(i32 noundef %8, ptr noundef %12)
  %14 = getelementptr inbounds i8, ptr %4, i64 28
  store i32 %13, ptr %14, align 4, !tbaa !16
  %.not24 = icmp eq i32 %13, -1
  br i1 %.not24, label %15, label %16, !prof !15

15:                                               ; preds = %11
  tail call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 4, ptr noundef nonnull @.str.1, ptr noundef %0, ptr noundef %1) #4
  tail call void @exit(i32 noundef 0) #5
  unreachable

16:                                               ; preds = %11
  %17 = load i32, ptr %9, align 8, !tbaa !14
  %18 = tail call i64 @get_attribute_data_type(i32 noundef %17, i32 noundef %13)
  %19 = trunc i64 %18 to i32
  %20 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 %19, ptr %20, align 4, !tbaa !17
  %21 = tail call i32 @convert_data_type(i32 noundef %19)
  store i32 %21, ptr %4, align 8, !tbaa !18
  %.not25 = icmp eq i32 %21, -1
  br i1 %.not25, label %22, label %23, !prof !15

22:                                               ; preds = %16
  tail call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 4, ptr noundef nonnull @.str.2, ptr noundef %0, ptr noundef %1) #4
  tail call void @exit(i32 noundef 0) #5
  unreachable

23:                                               ; preds = %16
  ret ptr %4
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @get_protocol_id_by_name(ptr noundef) local_unnamed_addr #0

declare void @mmt_sec_log(i32 noundef, ptr noundef, ...) local_unnamed_addr #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @get_attribute_id_by_protocol_id_and_attribute_name(i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @get_attribute_data_type(i32 noundef, i32 noundef) local_unnamed_addr #0

attributes #0 = { inlinehint 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 = { "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 = { 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { 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 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !11, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !11, i64 32}
!14 = !{!6, !7, i64 24}
!15 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!16 = !{!6, !7, i64 28}
!17 = !{!6, !7, i64 4}
!18 = !{!6, !7, i64 0}


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