Luce / engineering
Learn Luce LuciaOS

Enums, unions, and match

A union stores two things: which case is active and the data carried by that case. match reads the tag before it is allowed to read the payload.

Follow one tagged value

The example constructs State.running with a progress value and immediately matches it. MIR records the tag test and payload extraction. LLVM gives both a concrete layout. Optimization may remove the test when the active case is already known.

Compiler traceFollow one program through four representations
compiler build information

Luce source. Names and indentation describe the program for a reader.

open source file

union State:
    idle
    running(progress: i64)

func score(state: State) -> i64:
    match state:
        idle:
            return 0
        running(progress):
            return progress

func main(args: list[str]):
    let state = State.running(progress = len(args))
    print(str(score(state)))

Luce MIR. Types, registers, blocks, calls, and lifetime operations form the instruction plan sent to the LLVM backend.

open MIR file
MIR instruction guide hover, focus, or tap dotted terms

r7 is one typed intermediate value, %2 is a local storage slot, and b1 is a basic block. Read each block from top to bottom, then follow its final control-flow instruction.

Hover or focus a dotted term in the file for its explanation. On a touch screen, tap a term to keep the note open and tap elsewhere to close it. The list includes the operations that appear in this file.

union NAME
Declares a tagged value whose active case determines the payload layout and match path.
func …
Starts one MIR function and lists the source-level parameters with their resolved types.
local %N
Reserves a typed local slot. The slot gives later blocks a stable place to read or replace.
b0, b1, …
Names a basic block. Control enters at the label and runs until a branch, jump, trap, or return chooses what happens next.
r0, r1, …
Names one typed intermediate result. Each register is assigned once, which makes data flow explicit.
local_get
Reads a local slot into a fresh MIR register so this use has a precise value and type.
local_set
Writes a register into a local slot. Later blocks read that slot after control-flow paths join.
const
Creates a typed literal such as 2 or 10 inside the instruction stream.
equal.i64
Tests two signed 64-bit values for equality.
intrinsic NAME
Invokes a language operation with runtime rules recorded by the compiler. The name identifies the operation.
intrinsic len
Reads the logical length defined by the value's type, such as argument count or Unicode-scalar count.
intrinsic str_value
Converts a typed value into owned text through Luce's string conversion rules.
intrinsic print
Sends text through the installed host output capability.
intrinsic drop_storage
Releases any reference held by a temporary value and leaves that temporary in its empty state.
call NAME
Calls a resolved function directly. MIR already knows the target and argument order.
variant_make
Builds a tagged union value from a case tag and its payload.
variant_tag
Reads the active union case so control flow can select the matching arm.
variant_field
Reads the payload after the active case has been established.
branch CONDITION, TRUE, FALSE
Chooses one of two basic blocks from a Boolean register.
trap
Ends the run with a stable trap code and source position.
ret
Returns the current function's result to its caller and closes the current control-flow path.

union State:
    idle
    running(progress: i64)
func score(state: State) -> i64
    local %1 (temporary): State
    local %2 progress: i64
  b0:
    r0 = local_get %0
    local_set %1, r0
    r2 = local_get %1
    r3 = variant_tag r2
    r4 = const 0
    r5 = equal.i64 r3, r4
    branch r5, b1, b3
  b1:
    r7 = const 0
    ret r7
  b2:
    trap missing_return
  b3:
    r9 = local_get %1
    r10 = variant_field r9, State.running.progress
    local_set %2, r10
    r12 = local_get %2
    ret r12
func main(args: list[str]) -> None
    local %1 (temporary): State
    local %2 state: State
    local %3 (temporary): str
  b0:
    r0 = local_get %0
    r1 = intrinsic len, r0
    r2 = variant_make State.running, r1
    local_set %2, r2
    r4 = local_get %2
    r5 = call score, r4
    r6 = intrinsic str_value, r5
    local_set %3, r6
    intrinsic print, r6
    r9 = local_get %3
    r10 = intrinsic drop_storage, r9
    local_set %3, r10
    r12 = local_get %2
    r13 = intrinsic drop_storage, r12
    local_set %2, r13
    ret

LLVM IR. The backend expands MIR into typed memory operations, calls, checks, and control-flow blocks for LLVM.

open LLVM IR file
LLVM IR instruction guide hover, focus, or tap dotted terms

%7 is an SSA value, i64 is a 64-bit integer type, ptr is a pointer, and @name is a module symbol. Numbered labels divide the function into basic blocks.

Hover or focus a dotted term in the file for its explanation. On a touch screen, tap a term to keep the note open and tap elsewhere to close it. The list includes the operations that appear in this file.

@name = …
Defines module data such as text constants, source positions, function records, and the artifact identity tag.
define … @name
Begins a generated function. The parameter attributes tell LLVM which pointers are valid, writable, or read-only.
declare … @name
Declares a runtime or LLVM helper whose body is provided elsewhere.
numeric label
Starts an LLVM basic block. Every branch names one of these labels as its destination.
%0, %1, …
Names an SSA value. Each name is assigned once, allowing LLVM to trace definitions and uses directly.
alloca
Reserves a stack slot for a local value, return area, or temporary aggregate.
getelementptr
Calculates the address of a field or indexed element while preserving LLVM's type and bounds information.
load
Copies a typed value from memory into an SSA value.
store
Copies an SSA value into a stack slot, object field, return area, or runtime structure.
icmp
Compares integers or pointers and produces the one-bit condition consumed by a branch or select.
br
Transfers control to another block. With an i1 operand it chooses between two destinations.
select
Chooses one of two SSA values from a condition, which can become a branch-free machine instruction.
call
Invokes a generated function, a runtime helper, a host callback, or an LLVM intrinsic.
extractvalue
Reads one field from an SSA aggregate, such as the result and overflow bit returned together.
insertvalue
Builds an SSA aggregate one field at a time.
ptrtoint
Encodes a pointer as an integer field inside Luce's uniform runtime value representation.
inttoptr
Recovers a pointer from the integer field of Luce's uniform runtime value representation.
zext
Widens an unsigned value by filling the new high bits with zero.
trunc
Keeps the low bits while converting to a narrower integer representation.
lshr
Shifts bits right and fills the high side with zero; this is useful for unpacking handle fields.
and
Combines or masks bits, often to inspect a flag in a packed handle or status value.
or
Sets or combines bits in a packed value.
sub
Subtracts integer values; the generated entry code also uses it to update the call-depth budget.
mul
Multiplies integers after the language-specific checks have been represented.
ret
Returns a status or value and ends the current basic block.
@llvm.memcpy.inline
Copies a small fixed-size value representation; LLVM can expand it directly for the target.
@luce_rt_open
Creates the per-run runtime state and installs the table used to turn function numbers into source-aware traces.
@luce_rt_close
Closes the per-run runtime state after the final status and reports have been collected.
@luce_rt_args_list
Builds the owned list[str] passed to main from the host's argument callbacks.
@luce_rt_status
Combines the generated function result with runtime trap, error, exhaustion, and exit state.
@luce_rt_report_error
Sends an uncaught recoverable error through the host's error-report callback.
@luce_rt_report
Sends the completed trap report through the host callback selected by the entry wrapper.
@luce_rt_leaked
Reads the live-object count used to detect references that remain after program cleanup.
@luce_rt_exhaust
Records allocation exhaustion in the current run so the entry wrapper returns the corresponding status.
@luce_rt_raise
Records a source-aware trap in the runtime so every execution path reports the same code and location.
@luce_rt_unwound
Adds one generated function frame while a trap or uncaught error travels toward the entry point.
@luce_rt_release
Removes a strong owner and triggers destruction at zero.
@luce_rt_drop_storage
Releases reference-bearing fields in a temporary runtime value.
@luce_rt_str
Converts a uniform runtime value into owned UTF-8 text.
@luce_rt_struct_make
Builds a value aggregate from typed fields while retaining any reference-bearing fields.
@luce_rt_files_install
Copies file-related callbacks from the host table into the current runtime context.
@luce_rt_sockets_install
Copies network callbacks from the host table into the current runtime context.
@luce_rt_graphics_install
Copies window and graphics callbacks from the host table into the current runtime context.
!prof
Attaches branch-probability metadata so LLVM can place common and failure paths efficiently.

; ModuleID = '/Users/sedov/Dev/luciaos/www/lucelang/examples/sum_types.luc'
source_filename = "/Users/sedov/Dev/luciaos/www/lucelang/examples/sum_types.luc"
target triple = "arm64-apple-darwin24.6.0"

@luce.zero.State = private constant [2 x { i8, i8, [6 x i8], i64, i64 }] [{ i8, i8, [6 x i8], i64, i64 } { i8 2, i8 0, [6 x i8] zeroinitializer, i64 0, i64 0 }, { i8, i8, [6 x i8], i64, i64 } zeroinitializer]
@luce.text.0 = private unnamed_addr constant [40 x i8] c"function ended without returning a value"
@luce.text.1 = private unnamed_addr constant [0 x i8] zeroinitializer
@luce.text.2 = private unnamed_addr constant [21 x i8] c"null object reference"
@luce.text.3 = private unnamed_addr constant [22 x i8] c"object used after free"
@luce.text.4 = private unnamed_addr constant [19 x i8] c"call depth exceeded"
@luce.text.5 = private unnamed_addr constant [24 x i8] c"host service unavailable"
@luce.text.6 = private unnamed_addr constant [5 x i8] c"score"
@luce.text.7 = private unnamed_addr constant [60 x i8] c"/Users/sedov/Dev/luciaos/www/lucelang/examples/sum_types.luc"
@luce.origins.0 = private constant [15 x { i32, i32 }] [{ i32, i32 } { i32 6, i32 5 }, { i32, i32 } { i32 6, i32 5 }, { i32, i32 } { i32 6, i32 5 }, { i32, i32 } { i32 6, i32 5 }, { i32, i32 } { i32 6, i32 5 }, { i32, i32 } { i32 6, i32 5 }, { i32, i32 } { i32 6, i32 5 }, { i32, i32 } { i32 8, i32 13 }, { i32, i32 } { i32 8, i32 13 }, { i32, i32 } { i32 8, i32 13 }, { i32, i32 } { i32 8, i32 13 }, { i32, i32 } { i32 8, i32 13 }, { i32, i32 } { i32 10, i32 13 }, { i32, i32 } { i32 10, i32 13 }, { i32, i32 } { i32 10, i32 13 }]
@luce.text.8 = private unnamed_addr constant [4 x i8] c"main"
@luce.origins.1 = private constant [16 x { i32, i32 }] [{ i32, i32 } { i32 13, i32 5 }, { i32, i32 } { i32 13, i32 5 }, { i32, i32 } { i32 13, i32 5 }, { i32, i32 } { i32 13, i32 5 }, { i32, i32 } { i32 14, i32 5 }, { i32, i32 } { i32 14, i32 5 }, { i32, i32 } { i32 14, i32 5 }, { i32, i32 } { i32 14, i32 5 }, { i32, i32 } { i32 14, i32 5 }, { i32, i32 } { i32 14, i32 5 }, { i32, i32 } { i32 14, i32 5 }, { i32, i32 } { i32 14, i32 5 }, { i32, i32 } { i32 14, i32 5 }, { i32, i32 } { i32 14, i32 5 }, { i32, i32 } { i32 14, i32 5 }, { i32, i32 } { i32 14, i32 5 }]
@luce.functions = private constant [2 x { ptr, i64, ptr, i64, ptr, i64 }] [{ ptr, i64, ptr, i64, ptr, i64 } { ptr @luce.text.6, i64 5, ptr @luce.text.7, i64 60, ptr @luce.origins.0, i64 15 }, { ptr, i64, ptr, i64, ptr, i64 } { ptr @luce.text.8, i64 4, ptr @luce.text.7, i64 60, ptr @luce.origins.1, i64 16 }]
@luce_artifact = constant { i64, i64, i64, i32, i32, i32, i32, { i32, [52 x i8] } } { i64 23734338332087628, i64 0, i64 -7092229304759745108, i32 3, i32 29, i32 1, i32 0, { i32, [52 x i8] } { i32 18, [52 x i8] c"aarch64-macos-none\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" } }

define internal i32 @luce.0.score(ptr align 8 nocapture readonly nonnull dereferenceable(472) noundef %0, ptr align 8 nocapture nonnull noundef %1, i64 noundef %2, ptr align 8 readonly nonnull noundef %3, ptr align 8 nocapture nonnull dereferenceable(8) writeonly noundef %4) {
5:
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  store ptr %3, ptr %6, align 8
  store ptr @luce.zero.State, ptr %7, align 8
  store i64 0, ptr %8, align 8
  br label %9

9:
  %10 = load ptr, ptr %6, align 8
  store ptr %10, ptr %7, align 8
  %11 = load ptr, ptr %7, align 8
  %12 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %11, i64 0
  %13 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %12, i32 0, i32 3
  %14 = load i64, ptr %13, align 8
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %16, label %20

16:
  store i64 0, ptr %4, align 8
  ret i32 0

17:
  %18 = extractvalue { ptr, i64 } { ptr @luce.text.0, i64 40 }, 0
  %19 = extractvalue { ptr, i64 } { ptr @luce.text.0, i64 40 }, 1
  call void @luce_rt_raise(ptr %1, i32 5, ptr %18, i64 %19)
  call void @luce_rt_unwound(ptr %1, i32 0, i32 14)
  ret i32 1

20:
  %21 = load ptr, ptr %7, align 8
  %22 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %21, i64 1
  %23 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %22, i32 0, i32 3
  %24 = load i64, ptr %23, align 8
  store i64 %24, ptr %8, align 8
  %25 = load i64, ptr %8, align 8
  store i64 %25, ptr %4, align 8
  ret i32 0
}

define internal i32 @luce.1.main(ptr align 8 nocapture readonly nonnull dereferenceable(472) noundef %0, ptr align 8 nocapture nonnull noundef %1, i64 noundef %2, i64 %3) {
4:
  %5 = alloca i64, align 8
  %6 = alloca { i8, i8, [6 x i8], i64, i64 }, align 8
  %7 = alloca { i8, i8, [6 x i8], i64, i64 }, align 8
  %8 = alloca { i8, i8, [6 x i8], i64, i64 }, align 8
  store i64 %3, ptr %5, align 8
  %9 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %6, i32 0, i32 0
  store i8 5, ptr %9, align 1
  %10 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %6, i32 0, i32 4
  store i64 2, ptr %10, align 8
  %11 = ptrtoint ptr null to i64
  %12 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %6, i32 0, i32 3
  store i64 %11, ptr %12, align 8
  %13 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %7, i32 0, i32 0
  store i8 5, ptr %13, align 1
  %14 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %7, i32 0, i32 4
  store i64 2, ptr %14, align 8
  %15 = ptrtoint ptr null to i64
  %16 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %7, i32 0, i32 3
  store i64 %15, ptr %16, align 8
  %17 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %8, i32 0, i32 0
  store i8 4, ptr %17, align 1
  %18 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %8, i32 0, i32 1
  store i8 -1, ptr %18, align 1
  %19 = extractvalue { ptr, i64 } { ptr @luce.text.1, i64 0 }, 0
  %20 = ptrtoint ptr %19 to i64
  %21 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %8, i32 0, i32 3
  store i64 %20, ptr %21, align 8
  %22 = extractvalue { ptr, i64 } { ptr @luce.text.1, i64 0 }, 1
  %23 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %8, i32 0, i32 4
  store i64 %22, ptr %23, align 8
  %24 = alloca { i8, i8, [6 x i8], i64, i64 },i64 2, align 8
  %25 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %24, i64 0
  %26 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %25, i32 0, i32 0
  store i8 2, ptr %26, align 1
  %27 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %25, i32 0, i32 4
  store i64 0, ptr %27, align 8
  %28 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %24, i64 1
  %29 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %28, i32 0, i32 0
  store i8 2, ptr %29, align 1
  %30 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %28, i32 0, i32 4
  store i64 0, ptr %30, align 8
  %31 = alloca { i8, i8, [6 x i8], i64, i64 }, align 8
  %32 = sub nsw i64 %2, 1
  %33 = alloca i64, align 8
  %34 = alloca { i8, i8, [6 x i8], i64, i64 }, align 8
  %35 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %34, i32 0, i32 0
  store i8 2, ptr %35, align 1
  %36 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %34, i32 0, i32 4
  store i64 0, ptr %36, align 8
  %37 = alloca { i8, i8, [6 x i8], i64, i64 }, align 8
  %38 = alloca { i8, i8, [6 x i8], i64, i64 }, align 8
  %39 = alloca { i8, i8, [6 x i8], i64, i64 }, align 8
  br label %40

40:
  %41 = load i64, ptr %5, align 8
  %42 = trunc i64 %41 to i32
  %43 = lshr i64 %41, 32
  %44 = trunc i64 %43 to i32
  %45 = icmp eq i32 %42, -1
  br i1 %45, label %46, label %49, !prof !0

46:
  %47 = extractvalue { ptr, i64 } { ptr @luce.text.2, i64 21 }, 0
  %48 = extractvalue { ptr, i64 } { ptr @luce.text.2, i64 21 }, 1
  call void @luce_rt_raise(ptr %1, i32 14, ptr %47, i64 %48)
  call void @luce_rt_unwound(ptr %1, i32 1, i32 1)
  ret i32 1

49:
  %50 = getelementptr inbounds i8, ptr %1, i64 96
  %51 = load ptr, ptr %50, align 8!alias.scope !1, !noalias !2
  %52 = zext i32 %42 to i64
  %53 = mul nsw i64 %52, 112
  %54 = getelementptr inbounds i8, ptr %51, i64 %53
  %55 = getelementptr inbounds i8, ptr %54, i64 96
  %56 = load i32, ptr %55, align 4, !alias.scope !1, !noalias !2
  %57 = icmp ne i32 %56, %44
  br i1 %57, label %58, label %61, !prof !0

58:
  %59 = extractvalue { ptr, i64 } { ptr @luce.text.3, i64 22 }, 0
  %60 = extractvalue { ptr, i64 } { ptr @luce.text.3, i64 22 }, 1
  call void @luce_rt_raise(ptr %1, i32 13, ptr %59, i64 %60)
  call void @luce_rt_unwound(ptr %1, i32 1, i32 1)
  ret i32 1

61:
  %62 = and i32 %56, 1
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %67, !prof !0

64:
  %65 = extractvalue { ptr, i64 } { ptr @luce.text.3, i64 22 }, 0
  %66 = extractvalue { ptr, i64 } { ptr @luce.text.3, i64 22 }, 1
  call void @luce_rt_raise(ptr %1, i32 13, ptr %65, i64 %66)
  call void @luce_rt_unwound(ptr %1, i32 1, i32 1)
  ret i32 1

67:
  %68 = getelementptr inbounds i8, ptr %54, i64 16
  %69 = load i64, ptr %68, align 8!alias.scope !1, !noalias !2
  %70 = load ptr, ptr %54, align 8, !alias.scope !1, !noalias !2
  %71 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %25, i32 0, i32 3
  store i64 1, ptr %71, align 8
  %72 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %28, i32 0, i32 3
  store i64 %69, ptr %72, align 8
  %73 = call i32 @luce_rt_struct_make(ptr %1, ptr %24, i64 2, ptr %31)
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %76, !prof !0

75:
  call void @luce_rt_unwound(ptr %1, i32 1, i32 2)
  ret i32 1

76:
  %77 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %31, i32 0, i32 3
  %78 = load i64, ptr %77, align 8
  %79 = inttoptr i64 %78 to ptr
  call void @llvm.memcpy.inline.p0.p0.i64(ptr align 8 %7, ptr align 8 %31, i64 24, i1 false)
  %80 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %7, i32 0, i32 3
  %81 = load i64, ptr %80, align 8
  %82 = inttoptr i64 %81 to ptr
  %83 = icmp slt i64 %32, 1
  br i1 %83, label %84, label %87, !prof !0

84:
  %85 = extractvalue { ptr, i64 } { ptr @luce.text.4, i64 19 }, 0
  %86 = extractvalue { ptr, i64 } { ptr @luce.text.4, i64 19 }, 1
  call void @luce_rt_raise(ptr %1, i32 6, ptr %85, i64 %86)
  call void @luce_rt_unwound(ptr %1, i32 1, i32 5)
  ret i32 1

87:
  %88 = call i32 @luce.0.score(ptr %0, ptr %1, i64 %32, ptr %82, ptr %33)
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %90, label %91, !prof !0

90:
  call void @luce_rt_unwound(ptr %1, i32 1, i32 5)
  ret i32 1

91:
  %92 = load i64, ptr %33, align 8
  %93 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %34, i32 0, i32 3
  store i64 %92, ptr %93, align 8
  %94 = call i32 @luce_rt_str(ptr %1, ptr %34, ptr %37)
  %95 = icmp ne i32 %94, 0
  br i1 %95, label %96, label %97, !prof !0

96:
  call void @luce_rt_unwound(ptr %1, i32 1, i32 6)
  ret i32 1

97:
  %98 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %37, i32 0, i32 3
  %99 = load i64, ptr %98, align 8
  %100 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %37, i32 0, i32 1
  %101 = load i8, ptr %100, align 1
  %102 = icmp eq i8 %101, -1
  %103 = inttoptr i64 %99 to ptr
  %104 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %37, i32 0, i32 2
  %105 = select i1 %102, ptr %103, ptr %104
  %106 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %37, i32 0, i32 4
  %107 = load i64, ptr %106, align 8
  %108 = zext i8 %101 to i64
  %109 = select i1 %102, i64 %107, i64 %108
  %110 = insertvalue { ptr, i64 } poison, ptr %105, 0
  %111 = insertvalue { ptr, i64 } %110, i64 %109, 1
  call void @llvm.memcpy.inline.p0.p0.i64(ptr align 8 %8, ptr align 8 %37, i64 24, i1 false)
  %112 = extractvalue { ptr, i64 } %111, 0
  %113 = extractvalue { ptr, i64 } %111, 1
  %114 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 1
  %115 = load ptr, ptr %114, align 8
  %116 = icmp eq ptr %115, null
  br i1 %116, label %117, label %120, !prof !0

117:
  %118 = extractvalue { ptr, i64 } { ptr @luce.text.5, i64 24 }, 0
  %119 = extractvalue { ptr, i64 } { ptr @luce.text.5, i64 24 }, 1
  call void @luce_rt_raise(ptr %1, i32 9, ptr %118, i64 %119)
  call void @luce_rt_unwound(ptr %1, i32 1, i32 8)
  ret i32 1

120:
  %121 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 0
  %122 = load ptr, ptr %121, align 8
  %123 = call i32 %115(ptr %122, ptr %112, i64 %113)
  %124 = icmp eq i32 %123, -1
  br i1 %124, label %125, label %126, !prof !0

125:
  call void @luce_rt_exhaust(ptr %1)
  ret i32 1

126:
  %127 = icmp ne i32 %123, 0
  %128 = icmp ne i32 %123, 1
  %129 = and i1 %127, %128
  br i1 %129, label %130, label %133, !prof !0

130:
  %131 = extractvalue { ptr, i64 } { ptr @luce.text.5, i64 24 }, 0
  %132 = extractvalue { ptr, i64 } { ptr @luce.text.5, i64 24 }, 1
  call void @luce_rt_raise(ptr %1, i32 9, ptr %131, i64 %132)
  call void @luce_rt_unwound(ptr %1, i32 1, i32 8)
  ret i32 1

133:
  %134 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %8, i32 0, i32 3
  %135 = load i64, ptr %134, align 8
  %136 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %8, i32 0, i32 1
  %137 = load i8, ptr %136, align 1
  %138 = icmp eq i8 %137, -1
  %139 = inttoptr i64 %135 to ptr
  %140 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %8, i32 0, i32 2
  %141 = select i1 %138, ptr %139, ptr %140
  %142 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %8, i32 0, i32 4
  %143 = load i64, ptr %142, align 8
  %144 = zext i8 %137 to i64
  %145 = select i1 %138, i64 %143, i64 %144
  %146 = insertvalue { ptr, i64 } poison, ptr %141, 0
  %147 = insertvalue { ptr, i64 } %146, i64 %145, 1
  call void @luce_rt_drop_storage(ptr %1, ptr %8, ptr %38)
  %148 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %38, i32 0, i32 3
  %149 = load i64, ptr %148, align 8
  %150 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %38, i32 0, i32 1
  %151 = load i8, ptr %150, align 1
  %152 = icmp eq i8 %151, -1
  %153 = inttoptr i64 %149 to ptr
  %154 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %38, i32 0, i32 2
  %155 = select i1 %152, ptr %153, ptr %154
  %156 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %38, i32 0, i32 4
  %157 = load i64, ptr %156, align 8
  %158 = zext i8 %151 to i64
  %159 = select i1 %152, i64 %157, i64 %158
  %160 = insertvalue { ptr, i64 } poison, ptr %155, 0
  %161 = insertvalue { ptr, i64 } %160, i64 %159, 1
  call void @llvm.memcpy.inline.p0.p0.i64(ptr align 8 %8, ptr align 8 %38, i64 24, i1 false)
  %162 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %7, i32 0, i32 3
  %163 = load i64, ptr %162, align 8
  %164 = inttoptr i64 %163 to ptr
  call void @luce_rt_drop_storage(ptr %1, ptr %7, ptr %39)
  %165 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %39, i32 0, i32 3
  %166 = load i64, ptr %165, align 8
  %167 = inttoptr i64 %166 to ptr
  call void @llvm.memcpy.inline.p0.p0.i64(ptr align 8 %7, ptr align 8 %39, i64 24, i1 false)
  ret i32 0
}

; Function Attrs: nounwind cold willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @luce_rt_raise(ptr nocapture nonnull noundef %0, i32 %1, ptr nocapture readonly %2, i64 %3) #0

; Function Attrs: nounwind cold willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @luce_rt_unwound(ptr nocapture nonnull noundef %0, i32 %1, i32 %2) #0

; Function Attrs: nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare i32 @luce_rt_struct_make(ptr nocapture nonnull noundef %0, ptr align 8 nocapture readonly nonnull noundef %1, i64 %2, ptr align 8 nocapture nonnull dereferenceable(24) writeonly noundef %3) #1

; Function Attrs: nounwind willreturn nofree nocallback memory(argmem: readwrite)
declare void @llvm.memcpy.inline.p0.p0.i64(ptr noalias nocapture writeonly %0, ptr noalias nocapture readonly %1, i64 %2, i1 immarg %3) #2

; Function Attrs: nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: readwrite)
declare i32 @luce_rt_str(ptr nocapture nonnull noundef %0, ptr align 8 nocapture readonly nonnull dereferenceable(24) noundef %1, ptr align 8 nocapture nonnull dereferenceable(24) writeonly noundef %2) #3

; Function Attrs: nounwind cold willreturn memory(argmem: write)
declare void @luce_rt_exhaust(ptr nocapture nonnull noundef %0) #4

; Function Attrs: nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @luce_rt_drop_storage(ptr nocapture nonnull noundef %0, ptr align 8 nocapture readonly nonnull dereferenceable(24) noundef %1, ptr align 8 nocapture nonnull dereferenceable(24) writeonly noundef %2) #1

define i32 @luce_main(ptr align 8 nocapture readonly nonnull dereferenceable(472) noundef %0) {
1:
  %2 = alloca i64, align 8
  %3 = alloca i32, align 8
  store i64 256, ptr %2, align 8
  %4 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 0
  %5 = load ptr, ptr %4, align 8
  %6 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 14
  %7 = load ptr, ptr %6, align 8
  %8 = icmp eq ptr %7, null
  br i1 %8, label %11, label %9

9:
  %10 = call i64 %7(ptr %5)
  store i64 %10, ptr %2, align 8
  br label %11

11:
  %12 = load i64, ptr %2, align 8
  %13 = call ptr @luce_rt_open(ptr @luce.functions, i64 2)
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16, !prof !0

15:
  ret i32 2

16:
  %17 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 28
  %18 = load ptr, ptr %17, align 8
  %19 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 54
  %20 = load ptr, ptr %19, align 8
  %21 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 55
  %22 = load ptr, ptr %21, align 8
  %23 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 56
  %24 = load ptr, ptr %23, align 8
  %25 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 57
  %26 = load ptr, ptr %25, align 8
  %27 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 58
  %28 = load ptr, ptr %27, align 8
  %29 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 29
  %30 = load ptr, ptr %29, align 8
  %31 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 30
  %32 = load ptr, ptr %31, align 8
  %33 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 31
  %34 = load ptr, ptr %33, align 8
  %35 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 32
  %36 = load ptr, ptr %35, align 8
  call void @luce_rt_files_install(ptr %13, ptr %5, ptr %18, ptr %20, ptr %22, ptr %24, ptr %26, ptr %28, ptr %30, ptr %32, ptr %34, ptr %36)
  %37 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 48
  %38 = load ptr, ptr %37, align 8
  %39 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 49
  %40 = load ptr, ptr %39, align 8
  %41 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 50
  %42 = load ptr, ptr %41, align 8
  %43 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 51
  %44 = load ptr, ptr %43, align 8
  %45 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 52
  %46 = load ptr, ptr %45, align 8
  call void @luce_rt_sockets_install(ptr %13, ptr %5, ptr %38, ptr %40, ptr %42, ptr %44, ptr %46)
  %47 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 40
  %48 = load ptr, ptr %47, align 8
  %49 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 41
  %50 = load ptr, ptr %49, align 8
  %51 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 42
  %52 = load ptr, ptr %51, align 8
  %53 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 43
  %54 = load ptr, ptr %53, align 8
  %55 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 44
  %56 = load ptr, ptr %55, align 8
  %57 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 45
  %58 = load ptr, ptr %57, align 8
  %59 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 46
  %60 = load ptr, ptr %59, align 8
  %61 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 47
  %62 = load ptr, ptr %61, align 8
  call void @luce_rt_graphics_install(ptr %13, ptr %5, ptr %48, ptr %50, ptr %52, ptr %54, ptr %56, ptr %58, ptr %60, ptr %62)
  %63 = icmp slt i64 %12, 1
  br i1 %63, label %64, label %65, !prof !0

64:
  call void @luce_rt_raise(ptr %13, i32 6, ptr @luce.text.4, i64 19)
  store i32 1, ptr %3, align 8
  br label %73

65:
  %66 = alloca { i8, i8, [6 x i8], i64, i64 }, align 8
  %67 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 4
  %68 = load ptr, ptr %67, align 8
  %69 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 5
  %70 = load ptr, ptr %69, align 8
  %71 = call i32 @luce_rt_args_list(ptr %13, ptr %5, ptr %68, ptr %70, ptr %66)
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %77, label %78, !prof !0

73:
  %74 = load i32, ptr %3, align 8
  %75 = icmp eq i32 %74, 1
  %76 = icmp eq i32 %74, 2
  br i1 %75, label %83, label %86, !prof !0

77:
  store i32 1, ptr %3, align 8
  br label %73

78:
  %79 = getelementptr inbounds { i8, i8, [6 x i8], i64, i64 }, ptr %66, i32 0, i32 3
  %80 = load i64, ptr %79, align 8
  %81 = call i32 @luce.1.main(ptr %0, ptr %13, i64 %12, i64 %80)
  store i32 %81, ptr %3, align 8
  %82 = call i32 @luce_rt_release(ptr %13, ptr %66)
  br label %73

83:
  %84 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 2
  %85 = load ptr, ptr %84, align 8
  call void @luce_rt_report(ptr %13, ptr %5, ptr %85)
  br label %86

86:
  br i1 %76, label %87, label %90, !prof !0

87:
  %88 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 15
  %89 = load ptr, ptr %88, align 8
  call void @luce_rt_report_error(ptr %13, ptr %5, ptr %89)
  br label %90

90:
  %91 = call i32 @luce_rt_status(ptr %13, i32 %74)
  %92 = icmp eq i32 %91, 2
  %93 = getelementptr inbounds { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }, ptr %0, i32 0, i32 3
  %94 = load ptr, ptr %93, align 8
  %95 = icmp eq ptr %94, null
  %96 = or i1 %95, %92
  br i1 %96, label %97, label %98

97:
  call void @luce_rt_close(ptr %13)
  ret i32 %91

98:
  %99 = call i64 @luce_rt_leaked(ptr %13)
  call void %94(ptr %5, i64 %99)
  br label %97
}

; Function Attrs: nounwind willreturn memory(argmem: read, inaccessiblemem: readwrite)
declare noalias ptr @luce_rt_open(ptr readonly %0, i64 %1) #5

; Function Attrs: nounwind willreturn memory(argmem: readwrite)
declare void @luce_rt_files_install(ptr nocapture nonnull noundef %0, ptr %1, ptr %2, ptr %3, ptr %4, ptr %5, ptr %6, ptr %7, ptr %8, ptr %9, ptr %10, ptr %11) #6

; Function Attrs: nounwind willreturn memory(readwrite)
declare void @luce_rt_sockets_install(ptr nocapture nonnull noundef %0, ptr %1, ptr %2, ptr %3, ptr %4, ptr %5, ptr %6) #7

; Function Attrs: nounwind willreturn memory(argmem: readwrite)
declare void @luce_rt_graphics_install(ptr nocapture nonnull noundef %0, ptr %1, ptr %2, ptr %3, ptr %4, ptr %5, ptr %6, ptr %7, ptr %8, ptr %9) #6

; Function Attrs: nounwind memory(readwrite)
declare i32 @luce_rt_args_list(ptr nocapture nonnull noundef %0, ptr %1, ptr %2, ptr %3, ptr align 8 nocapture nonnull dereferenceable(24) writeonly noundef %4) #8

; Function Attrs: nounwind memory(readwrite)
declare i32 @luce_rt_release(ptr nocapture nonnull noundef %0, ptr align 8 nocapture readonly nonnull dereferenceable(24) noundef %1) #8

; Function Attrs: cold
declare void @luce_rt_report(ptr nocapture nonnull noundef %0, ptr %1, ptr %2) #9

; Function Attrs: cold
declare void @luce_rt_report_error(ptr nocapture nonnull noundef %0, ptr %1, ptr %2) #9

; Function Attrs: nounwind willreturn memory(argmem: read)
declare i32 @luce_rt_status(ptr nocapture nonnull noundef %0, i32 %1) #10

; Function Attrs: nounwind willreturn memory(argmem: read)
declare i64 @luce_rt_leaked(ptr nocapture nonnull noundef %0) #10

; Function Attrs: nounwind memory(readwrite)
declare void @luce_rt_close(ptr nocapture nonnull noundef %0) #8

attributes #0 = { nounwind cold willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) }
attributes #1 = { nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) }
attributes #2 = { nounwind willreturn nofree nocallback memory(argmem: readwrite) }
attributes #3 = { nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: readwrite) }
attributes #4 = { nounwind cold willreturn memory(argmem: write) }
attributes #5 = { nounwind willreturn memory(argmem: read, inaccessiblemem: readwrite) }
attributes #6 = { nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind willreturn memory(readwrite) }
attributes #8 = { nounwind memory(readwrite) }
attributes #9 = { cold }
attributes #10 = { nounwind willreturn memory(argmem: read) }

!0 = !{!"branch_weights", i32 1, i32 2000}
!1 = !{!3}
!2 = !{!4}
!3 = !{!"luce.rows", !5}
!4 = !{!"luce.elements", !5}
!5 = !{!"luce.alias"}

ARM64 object code. LLVM selected these instructions, registers, calls, and branch conditions for this target.

open assembly file
ARM64 instruction guide hover, focus, or tap dotted terms

x8 is a 64-bit register; w8 is its low 32 bits. A leading # marks a constant, brackets describe a memory address, and conditional instructions read the processor flags set by the preceding arithmetic or comparison.

Hover or focus a dotted term in the file for its explanation. On a touch screen, tap a term to keep the note open and tap elsewhere to close it. The list includes the operations that appear in this file.

mov
Copies a register value or loads a small constant. Calls also use it to place arguments in the required registers.
add
Adds registers or a constant. Address setup and stack restoration frequently use this instruction.
sub
Subtracts registers or a constant. Function prologues use it to reserve stack space.
cmp
Performs a subtraction solely to set condition flags; a following branch or select consumes those flags.
cmn
Performs an addition solely to set condition flags. The checked multiply-by-two path uses it to recognize unsafe inputs.
csel
Selects one of two registers from the current condition flags. The clamp uses it to choose the doubled value or limit.
ldr
Loads a register from memory using a scaled address offset.
str
Stores one register into memory using a scaled address offset.
ldp
Loads two adjacent registers, often restoring saved registers or reading neighboring fields.
stp
Stores two adjacent registers, often saving the caller's registers in a function prologue.
ldur
Loads from an unscaled byte offset, which is useful for stack slots below the frame pointer.
stur
Stores to an unscaled byte offset, which is useful for stack slots below the frame pointer.
ldurb
Loads one byte using an unscaled byte offset.
sturb
Stores one byte using an unscaled byte offset.
adrp
Loads the page address of a symbol. The linker fills in the final page-relative relocation.
bl
Calls a direct target and records the return address in x30.
blr
Calls the function address held in a register, as required for host callbacks and function values.
b
Jumps to another instruction address.
b.eq
Branches when the previous comparison reported equality.
b.ne
Branches when the previous comparison reported different values.
b.le
Branches when the signed left operand was smaller or equal.
b.hs
Branches when an unsigned comparison found higher-or-same, represented by a set carry flag.
cbz
Compares a register with zero and branches when it is zero.
cbnz
Compares a register with zero and branches when it contains a nonzero value.
tbnz
Tests one selected bit and branches when that bit is set; packed runtime flags use this form.
lsr
Shifts bits right and fills with zero, often extracting the upper field of a packed handle.
umaddl
Widens two 32-bit unsigned operands, multiplies them, and adds a 64-bit base address.
orr
Combines bits, commonly setting tag or flag bits in a packed value.
ret
Returns to the address in x30 and ends the current machine function.


/Users/sedov/Dev/luciaos/www/lucelang/out/traces/sum_types.o:	file format mach-o arm64

Disassembly of section __TEXT,__text:

0000000000000000 <ltmp0>:
; luce_main():
       0:      	stp	x24, x23, [sp, #-0x40]!
       4:      	stp	x22, x21, [sp, #0x10]
       8:      	stp	x20, x19, [sp, #0x20]
       c:      	stp	x29, x30, [sp, #0x30]
      10:      	add	x29, sp, #0x30
      14:      	sub	sp, sp, #0xd0
      18:      	ldr	x8, [x0, #0x70]
      1c:      	ldr	x19, [x0]
      20:      	mov	x20, x0
      24:      	cbz	x8, 0x50 <ltmp0+0x50>
      28:      	mov	x0, x19
      2c:      	blr	x8
      30:      	mov	x23, x0
      34:      	adrp	x0, 0x0 <ltmp0>
      38:      	add	x0, x0, #0x0
      3c:      	mov	w1, #0x2                ; =2
      40:      	mov	w22, #0x2               ; =2
      44:      	bl	0x44 <ltmp0+0x44>
      48:      	cbnz	x0, 0x6c <ltmp0+0x6c>
      4c:      	b	0x264 <ltmp0+0x264>
      50:      	mov	w23, #0x100             ; =256
      54:      	adrp	x0, 0x0 <ltmp0>
      58:      	add	x0, x0, #0x0
      5c:      	mov	w1, #0x2                ; =2
      60:      	mov	w22, #0x2               ; =2
      64:      	bl	0x64 <ltmp0+0x64>
      68:      	cbz	x0, 0x264 <ltmp0+0x264>
      6c:      	ldp	x3, x4, [x20, #0x1b0]
      70:      	mov	x21, x0
      74:      	ldp	x5, x6, [x20, #0x1c0]
      78:      	ldr	x2, [x20, #0xe0]
      7c:      	ldp	x8, x9, [x20, #0xf8]
      80:      	ldr	x7, [x20, #0x1d0]
      84:      	ldur	q0, [x20, #0xe8]
      88:      	sub	sp, sp, #0x20
      8c:      	mov	x1, x19
      90:      	stp	x8, x9, [sp, #0x10]
      94:      	str	q0, [sp]
      98:      	bl	0x98 <ltmp0+0x98>
      9c:      	add	sp, sp, #0x20
      a0:      	ldp	x2, x3, [x20, #0x180]
      a4:      	mov	x0, x21
      a8:      	ldp	x4, x5, [x20, #0x190]
      ac:      	mov	x1, x19
      b0:      	ldr	x6, [x20, #0x1a0]
      b4:      	bl	0xb4 <ltmp0+0xb4>
      b8:      	ldp	x8, x9, [x20, #0x170]
      bc:      	ldp	x2, x3, [x20, #0x140]
      c0:      	ldp	x4, x5, [x20, #0x150]
      c4:      	ldp	x6, x7, [x20, #0x160]
      c8:      	stp	x8, x9, [sp, #-0x10]!
      cc:      	mov	x0, x21
      d0:      	mov	x1, x19
      d4:      	bl	0xd4 <ltmp0+0xd4>
      d8:      	add	sp, sp, #0x10
      dc:      	cmp	x23, #0x0
      e0:      	b.le	0x2e8 <ltmp0+0x2e8>
      e4:      	sub	x22, sp, #0x20
      e8:      	mov	sp, x22
      ec:      	ldp	x2, x3, [x20, #0x20]
      f0:      	mov	x0, x21
      f4:      	mov	x1, x19
      f8:      	mov	x4, x22
      fc:      	bl	0xfc <ltmp0+0xfc>
     100:      	cbnz	w0, 0x370 <ltmp0+0x370>
     104:      	ldr	x8, [x22, #0x8]
     108:      	mov	w9, #0x2                ; =2
     10c:      	stur	xzr, [x29, #-0x90]
     110:      	sturb	w9, [x29, #-0xa0]
     114:      	cmn	w8, #0x1
     118:      	sturb	w9, [x29, #-0x88]
     11c:      	stur	xzr, [x29, #-0x78]
     120:      	sturb	w9, [x29, #-0xd0]
     124:      	stur	xzr, [x29, #-0xc0]
     128:      	b.eq	0x304 <ltmp0+0x304>
     12c:      	mov	w9, #0x70               ; =112
     130:      	ldr	x10, [x21, #0x60]
     134:      	umaddl	x9, w8, w9, x10
     138:      	lsr	x8, x8, #32
     13c:      	ldr	w10, [x9, #0x60]
     140:      	cmp	w10, w8
     144:      	b.ne	0x2a8 <ltmp0+0x2a8>
     148:      	tbnz	w8, #0x0, 0x2a8 <ltmp0+0x2a8>
     14c:      	ldr	x8, [x9, #0x10]
     150:      	mov	w9, #0x1                ; =1
     154:      	sub	x1, x29, #0xa0
     158:      	sub	x3, x29, #0xb8
     15c:      	mov	x0, x21
     160:      	mov	w2, #0x2                ; =2
     164:      	stur	x9, [x29, #-0x98]
     168:      	stur	x8, [x29, #-0x80]
     16c:      	bl	0x16c <ltmp0+0x16c>
     170:      	cbnz	w0, 0x32c <ltmp0+0x32c>
     174:      	ldur	q0, [x29, #-0xb8]
     178:      	ldur	x8, [x29, #-0xa8]
     17c:      	cmp	x23, #0x1
     180:      	stur	q0, [x29, #-0x50]
     184:      	stur	x8, [x29, #-0x40]
     188:      	b.eq	0x33c <ltmp0+0x33c>
     18c:      	ldur	x8, [x29, #-0x48]
     190:      	ldr	x9, [x8, #0x8]
     194:      	cbz	x9, 0x280 <ltmp0+0x280>
     198:      	ldr	x8, [x8, #0x20]
     19c:      	sub	x1, x29, #0xd0
     1a0:      	sub	x2, x29, #0xe8
     1a4:      	mov	x0, x21
     1a8:      	stur	x8, [x29, #-0xc8]
     1ac:      	bl	0x1ac <ltmp0+0x1ac>
     1b0:      	cbnz	w0, 0x298 <ltmp0+0x298>
     1b4:      	ldp	x9, x10, [x29, #-0xe0]
     1b8:      	ldur	q0, [x29, #-0xe8]
     1bc:      	ldr	x8, [x20, #0x8]
     1c0:      	ldurb	w11, [x29, #-0xe7]
     1c4:      	stur	q0, [x29, #-0x70]
     1c8:      	stur	x10, [x29, #-0x60]
     1cc:      	cbz	x8, 0x2c0 <ltmp0+0x2c0>
     1d0:      	sub	x12, x29, #0xe8
     1d4:      	cmp	w11, #0xff
     1d8:      	ldr	x0, [x20]
     1dc:      	orr	x12, x12, #0x2
     1e0:      	csel	x2, x10, x11, eq
     1e4:      	csel	x1, x9, x12, eq
     1e8:      	blr	x8
     1ec:      	cmn	w0, #0x1
     1f0:      	b.eq	0x39c <ltmp0+0x39c>
     1f4:      	cmp	w0, #0x2
     1f8:      	b.hs	0x2c0 <ltmp0+0x2c0>
     1fc:      	sub	x1, x29, #0x70
     200:      	sub	x2, x29, #0x100
     204:      	mov	x0, x21
     208:      	bl	0x208 <ltmp0+0x208>
     20c:      	sub	x1, x29, #0xb8
     210:      	sub	x2, x29, #0x50
     214:      	mov	x0, x21
     218:      	bl	0x218 <ltmp0+0x218>
     21c:      	mov	x0, x21
     220:      	mov	x1, x22
     224:      	bl	0x224 <ltmp0+0x224>
     228:      	mov	w1, wzr
     22c:      	mov	x0, x21
     230:      	bl	0x230 <ltmp0+0x230>
     234:      	mov	w22, w0
     238:      	cmp	w0, #0x2
     23c:      	b.eq	0x25c <ltmp0+0x25c>
     240:      	ldr	x20, [x20, #0x18]
     244:      	cbz	x20, 0x25c <ltmp0+0x25c>
     248:      	mov	x0, x21
     24c:      	bl	0x24c <ltmp0+0x24c>
     250:      	mov	x1, x0
     254:      	mov	x0, x19
     258:      	blr	x20
     25c:      	mov	x0, x21
     260:      	bl	0x260 <ltmp0+0x260>
     264:      	mov	w0, w22
     268:      	sub	sp, x29, #0x30
     26c:      	ldp	x29, x30, [sp, #0x30]
     270:      	ldp	x20, x19, [sp, #0x20]
     274:      	ldp	x22, x21, [sp, #0x10]
     278:      	ldp	x24, x23, [sp], #0x40
     27c:      	ret
     280:      	sub	x1, x29, #0xd0
     284:      	sub	x2, x29, #0xe8
     288:      	mov	x0, x21
     28c:      	stur	xzr, [x29, #-0xc8]
     290:      	bl	0x290 <ltmp0+0x290>
     294:      	cbz	w0, 0x1b4 <ltmp0+0x1b4>
     298:      	mov	x0, x21
     29c:      	mov	w1, #0x1                ; =1
     2a0:      	mov	w2, #0x6                ; =6
     2a4:      	b	0x360 <ltmp0+0x360>
     2a8:      	adrp	x2, 0x0 <ltmp0>
     2ac:      	add	x2, x2, #0x0
     2b0:      	mov	x0, x21
     2b4:      	mov	w1, #0xd                ; =13
     2b8:      	mov	w3, #0x16               ; =22
     2bc:      	b	0x318 <ltmp0+0x318>
     2c0:      	adrp	x2, 0x0 <ltmp0>
     2c4:      	add	x2, x2, #0x0
     2c8:      	mov	x0, x21
     2cc:      	mov	w1, #0x9                ; =9
     2d0:      	mov	w3, #0x18               ; =24
     2d4:      	bl	0x2d4 <ltmp0+0x2d4>
     2d8:      	mov	x0, x21
     2dc:      	mov	w1, #0x1                ; =1
     2e0:      	mov	w2, #0x8                ; =8
     2e4:      	b	0x360 <ltmp0+0x360>
     2e8:      	adrp	x2, 0x0 <ltmp0>
     2ec:      	add	x2, x2, #0x0
     2f0:      	mov	x0, x21
     2f4:      	mov	w1, #0x6                ; =6
     2f8:      	mov	w3, #0x13               ; =19
     2fc:      	bl	0x2fc <ltmp0+0x2fc>
     300:      	b	0x370 <ltmp0+0x370>
     304:      	adrp	x2, 0x0 <ltmp0>
     308:      	add	x2, x2, #0x0
     30c:      	mov	x0, x21
     310:      	mov	w1, #0xe                ; =14
     314:      	mov	w3, #0x15               ; =21
     318:      	bl	0x318 <ltmp0+0x318>
     31c:      	mov	x0, x21
     320:      	mov	w1, #0x1                ; =1
     324:      	mov	w2, #0x1                ; =1
     328:      	b	0x360 <ltmp0+0x360>
     32c:      	mov	x0, x21
     330:      	mov	w1, #0x1                ; =1
     334:      	mov	w2, #0x2                ; =2
     338:      	b	0x360 <ltmp0+0x360>
     33c:      	adrp	x2, 0x0 <ltmp0>
     340:      	add	x2, x2, #0x0
     344:      	mov	x0, x21
     348:      	mov	w1, #0x6                ; =6
     34c:      	mov	w3, #0x13               ; =19
     350:      	bl	0x350 <ltmp0+0x350>
     354:      	mov	x0, x21
     358:      	mov	w1, #0x1                ; =1
     35c:      	mov	w2, #0x5                ; =5
     360:      	bl	0x360 <ltmp0+0x360>
     364:      	mov	x0, x21
     368:      	mov	x1, x22
     36c:      	bl	0x36c <ltmp0+0x36c>
     370:      	ldr	x2, [x20, #0x10]
     374:      	mov	x0, x21
     378:      	mov	x1, x19
     37c:      	bl	0x37c <ltmp0+0x37c>
     380:      	mov	w1, #0x1                ; =1
     384:      	mov	x0, x21
     388:      	bl	0x388 <ltmp0+0x388>
     38c:      	mov	w22, w0
     390:      	cmp	w0, #0x2
     394:      	b.ne	0x240 <ltmp0+0x240>
     398:      	b	0x25c <ltmp0+0x25c>
     39c:      	mov	x0, x21
     3a0:      	bl	0x3a0 <ltmp0+0x3a0>
     3a4:      	b	0x364 <ltmp0+0x364>

Enums name integer states

An enum has an explicit or inferred integer backing width. Members are always namespaced. Converting a member to its number is explicit. Constructing from a number returns an optional because the backing representation can contain bit patterns outside the declared members.

sourceState.ready — nominal member identity
semantic typeState — a distinct type with named members
runtime bitsthe selected explicit-width integer representation

Unions carry tagged payloads

A union member carries either an empty payload or named payload fields. Construction goes through the union namespace. The tag is always present; payload storage is sized and aligned for the alternatives. A match arm establishes the active tag before it receives that member’s fields.

Tagged-union layoutConceptual representation
tagwhich member is active
payload areaenough aligned storage for the largest member; ownership follows the active member only

Exhaustiveness turns change into a diagnostic

An enum or union match without else must cover every member. Adding a new alternative then finds each incomplete match at compile time. A union arm binds only the named fields of that member, with their exact types and ordinary value/reference lifetime.

Recursive values need a terminator

A union needs a finite payload layout. Recursive unions therefore cross an optional or reference boundary: absence can terminate a value chain, and a reference has fixed handle width regardless of the object graph behind it.

Finite

A recursive union member carries an optional next value or a list/class reference.

Infinite

A union member directly embeds the same union again with no terminating representation.

Equality, methods, and containers

Enums have value equality and may serve as map keys when the exact enum type matches. Union code compares the active tag through match and can compare payload fields whose own types define equality. Both enums and unions can declare methods and static functions; union member constructors are function values.