WebAssembly control flow is expressed in structured instructions such as if, else, br, loop, return and block. Below is a list of the instructions.
If the value of $x is less than 10, then return the value of 10, else return the value of $x.
(module
(func $min10 (param $x i32) (result i32)
(if (result i32)
(i32.lt_s
(get_local $x)
(i32.const 10)
)
(then
(i32.const 10)
)
(else
(get_local $x)
)
)
)
(export "min10" (func $min10))
)
Complete Sample Source code