DISCRETE_STEP(dst_adder) {
  if (DISCRETE_INPUT(0)) {
    set_output(0, DISCRETE_INPUT(1) + DISCRETE_INPUT(2) + DISCRETE_INPUT(3) +
                      DISCRETE_INPUT(4));
  } else {
    set_output(0, 0);
  }
}


x86 assembly (clang, -O0):
<DISCRETE_STEP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
xor    %edi,%edi
mov    $0x0,%al
call   1030 <DISCRETE_INPUT@plt>
cmp    $0x0,%eax
je     1197 <DISCRETE_STEP+0x77>
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <DISCRETE_INPUT@plt>
mov    %eax,-0x14(%rbp)
mov    $0x2,%edi
mov    $0x0,%al
call   1030 <DISCRETE_INPUT@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    $0x3,%edi
mov    $0x0,%al
call   1030 <DISCRETE_INPUT@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    $0x4,%edi
mov    $0x0,%al
call   1030 <DISCRETE_INPUT@plt>
mov    -0xc(%rbp),%esi
add    %eax,%esi
xor    %edi,%edi
mov    $0x0,%al
call   1040 <set_output@plt>
jmp    11a2 <DISCRETE_STEP+0x82>
xor    %esi,%esi
mov    %esi,%edi
mov    $0x0,%al
call   1040 <set_output@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DISCRETE_STEP>:
push   %rbp
push   %r14
push   %rbx
xor    %ebx,%ebx
xor    %edi,%edi
xor    %eax,%eax
call   1030 <DISCRETE_INPUT@plt>
test   %eax,%eax
je     1174 <DISCRETE_STEP+0x54>
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <DISCRETE_INPUT@plt>
mov    %eax,%ebx
mov    $0x2,%edi
xor    %eax,%eax
call   1030 <DISCRETE_INPUT@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    $0x3,%edi
xor    %eax,%eax
call   1030 <DISCRETE_INPUT@plt>
mov    %eax,%r14d
add    %ebp,%r14d
mov    $0x4,%edi
xor    %eax,%eax
call   1030 <DISCRETE_INPUT@plt>
mov    %eax,%ebx
add    %r14d,%ebx
xor    %edi,%edi
mov    %ebx,%esi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <set_output@plt>

LLVM IR (-O0):
define i32 @DISCRETE_STEP(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = call i32 (i32, ...) bitcast (i32 (...)* @DISCRETE_INPUT to i32 (i32, ...)*)(i32 0)
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = call i32 (i32, ...) bitcast (i32 (...)* @DISCRETE_INPUT to i32 (i32, ...)*)(i32 1)
%8 = call i32 (i32, ...) bitcast (i32 (...)* @DISCRETE_INPUT to i32 (i32, ...)*)(i32 2)
%9 = add nsw i32 %7, %8
%10 = call i32 (i32, ...) bitcast (i32 (...)* @DISCRETE_INPUT to i32 (i32, ...)*)(i32 3)
%11 = add nsw i32 %9, %10
%12 = call i32 (i32, ...) bitcast (i32 (...)* @DISCRETE_INPUT to i32 (i32, ...)*)(i32 4)
%13 = add nsw i32 %11, %12
%14 = call i32 (i32, i32, ...) bitcast (i32 (...)* @set_output to i32 (i32, i32, ...)*)(i32 0, i32 %13)
br label %17
15: ; preds = %1
%16 = call i32 (i32, i32, ...) bitcast (i32 (...)* @set_output to i32 (i32, i32, ...)*)(i32 0, i32 0)
br label %17
17: ; preds = %15, %6
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
define i32 @DISCRETE_STEP(i32 %0) {
%2 = tail call i32 (i32, ...) bitcast (i32 (...)* @DISCRETE_INPUT to i32 (i32, ...)*)(i32 0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @DISCRETE_INPUT to i32 (i32, ...)*)(i32 1)
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @DISCRETE_INPUT to i32 (i32, ...)*)(i32 2)
%7 = add nsw i32 %6, %5
%8 = tail call i32 (i32, ...) bitcast (i32 (...)* @DISCRETE_INPUT to i32 (i32, ...)*)(i32 3)
%9 = add nsw i32 %7, %8
%10 = tail call i32 (i32, ...) bitcast (i32 (...)* @DISCRETE_INPUT to i32 (i32, ...)*)(i32 4)
%11 = add nsw i32 %9, %10
br label %12
12: ; preds = %1, %4
%13 = phi i32 [ %11, %4 ], [ 0, %1 ]
%14 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @set_output to i32 (i32, i32, ...)*)(i32 0, i32 %13)
ret i32 undef
}