#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ op_adc(char *, char *, char *, char *);
int /*<<< orphan*/ op_add(char *, char *, char *, char *);
int /*<<< orphan*/ op_alu_asl(char *, char *, char *, char *);
int /*<<< orphan*/ op_alu_lsr(char *, char *, char *, char *);
int /*<<< orphan*/ op_alu_reset(char *, char *, char *, char *);
int /*<<< orphan*/ op_alu_rol(char *, char *, char *, char *);
int /*<<< orphan*/ op_alu_ror(char *, char *, char *, char *);
int /*<<< orphan*/ op_alu_sbc(char *, char *, char *, char *);
int /*<<< orphan*/ op_and(char *, char *, char *, char *);
int /*<<< orphan*/ op_neg_a(char *, char *, char *, char *);
int /*<<< orphan*/ op_neg_b(char *, char *, char *, char *);
int /*<<< orphan*/ op_not_a(char *, char *, char *, char *);
int /*<<< orphan*/ op_not_b(char *, char *, char *, char *);
int /*<<< orphan*/ op_or(char *, char *, char *, char *);
int /*<<< orphan*/ op_sub(char *, char *, char *, char *);
int /*<<< orphan*/ op_xor(char *, char *, char *, char *);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int);
void alu(unsigned int alu_opcode, char reg_in_a[], char reg_in_b[],
         char reg_out_accu[], char flags[]) {
  char dummyflags[9] = "00000000";
  switch (alu_opcode) {
  case 1:
    op_add(reg_in_a, reg_in_b, reg_out_accu,
           (flags == NULL) ? dummyflags : flags);
    break;
  case 10:
    op_adc(reg_in_a, reg_in_b, reg_out_accu,
           (flags == NULL) ? dummyflags : flags);
    break;
  case 2:
    op_sub(reg_in_a, reg_in_b, reg_out_accu,
           (flags == NULL) ? dummyflags : flags);
    break;
  case 11:
    op_alu_sbc(reg_in_a, reg_in_b, reg_out_accu,
               (flags == NULL) ? dummyflags : flags);
    break;
  case 3:
    op_and(reg_in_a, reg_in_b, reg_out_accu,
           (flags == NULL) ? dummyflags : flags);
    break;
  case 4:
    op_or(reg_in_a, reg_in_b, reg_out_accu,
          (flags == NULL) ? dummyflags : flags);
    break;
  case 5:
    op_xor(reg_in_a, reg_in_b, reg_out_accu,
           (flags == NULL) ? dummyflags : flags);
    break;
  case 6:
    op_neg_a(reg_in_a, reg_in_b, reg_out_accu,
             (flags == NULL) ? dummyflags : flags);
    break;
  case 7:
    op_neg_b(reg_in_a, reg_in_b, reg_out_accu,
             (flags == NULL) ? dummyflags : flags);
    break;
  case 8:
    op_not_a(reg_in_a, reg_in_b, reg_out_accu,
             (flags == NULL) ? dummyflags : flags);
    break;
  case 9:
    op_not_b(reg_in_a, reg_in_b, reg_out_accu,
             (flags == NULL) ? dummyflags : flags);
    break;
  case 12:
    op_alu_asl(reg_in_a, reg_in_b, reg_out_accu,
               (flags == NULL) ? dummyflags : flags);
    break;
  case 13:
    op_alu_lsr(reg_in_a, reg_in_b, reg_out_accu,
               (flags == NULL) ? dummyflags : flags);
    break;
  case 14:
    op_alu_rol(reg_in_a, reg_in_b, reg_out_accu,
               (flags == NULL) ? dummyflags : flags);
    break;
  case 15:
    op_alu_ror(reg_in_a, reg_in_b, reg_out_accu,
               (flags == NULL) ? dummyflags : flags);
    break;
  case 0:
    op_alu_reset(reg_in_a, reg_in_b, reg_out_accu,
                 (flags == NULL) ? dummyflags : flags);
    break;
  default:
    printf("ALU(%i): Invalide operation %i selected", alu_opcode, alu_opcode);
  }
}


x86 assembly (clang, -O0):
<alu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movabs $0x3030303030303030,%rax
30 30 30
mov    %rax,-0x38(%rbp)
movb   $0x0,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0xf,%rax
ja     18ff <alu+0x6ef>
mov    -0x40(%rbp),%rax
lea    0xda4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1295 <alu+0x85>
lea    -0x38(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    129d <alu+0x8d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rcx
call   10f0 <op_add@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12e7 <alu+0xd7>
lea    -0x38(%rbp),%rax
mov    %rax,-0x80(%rbp)
jmp    12ef <alu+0xdf>
mov    -0x28(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x68(%rbp),%rdx
mov    -0x70(%rbp),%rsi
mov    -0x78(%rbp),%rdi
mov    -0x80(%rbp),%rcx
call   1080 <op_adc@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1345 <alu+0x135>
lea    -0x38(%rbp),%rax
mov    %rax,-0xa0(%rbp)
jmp    1350 <alu+0x140>
mov    -0x28(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x88(%rbp),%rdx
mov    -0x90(%rbp),%rsi
mov    -0x98(%rbp),%rdi
mov    -0xa0(%rbp),%rcx
call   1110 <op_sub@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    13b2 <alu+0x1a2>
lea    -0x38(%rbp),%rax
mov    %rax,-0xc0(%rbp)
jmp    13bd <alu+0x1ad>
mov    -0x28(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0xa8(%rbp),%rdx
mov    -0xb0(%rbp),%rsi
mov    -0xb8(%rbp),%rdi
mov    -0xc0(%rbp),%rcx
call   1130 <op_alu_sbc@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xc8(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    141f <alu+0x20f>
lea    -0x38(%rbp),%rax
mov    %rax,-0xe0(%rbp)
jmp    142a <alu+0x21a>
mov    -0x28(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0xc8(%rbp),%rdx
mov    -0xd0(%rbp),%rsi
mov    -0xd8(%rbp),%rdi
mov    -0xe0(%rbp),%rcx
call   1040 <op_and@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xe8(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    148c <alu+0x27c>
lea    -0x38(%rbp),%rax
mov    %rax,-0x100(%rbp)
jmp    1497 <alu+0x287>
mov    -0x28(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0xe8(%rbp),%rdx
mov    -0xf0(%rbp),%rsi
mov    -0xf8(%rbp),%rdi
mov    -0x100(%rbp),%rcx
call   1030 <op_or@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x108(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    14f9 <alu+0x2e9>
lea    -0x38(%rbp),%rax
mov    %rax,-0x120(%rbp)
jmp    1504 <alu+0x2f4>
mov    -0x28(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x108(%rbp),%rdx
mov    -0x110(%rbp),%rsi
mov    -0x118(%rbp),%rdi
mov    -0x120(%rbp),%rcx
call   10e0 <op_xor@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1566 <alu+0x356>
lea    -0x38(%rbp),%rax
mov    %rax,-0x140(%rbp)
jmp    1571 <alu+0x361>
mov    -0x28(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x128(%rbp),%rdx
mov    -0x130(%rbp),%rsi
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rcx
call   1090 <op_neg_a@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0x158(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x148(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    15d3 <alu+0x3c3>
lea    -0x38(%rbp),%rax
mov    %rax,-0x160(%rbp)
jmp    15de <alu+0x3ce>
mov    -0x28(%rbp),%rax
mov    %rax,-0x160(%rbp)
mov    -0x148(%rbp),%rdx
mov    -0x150(%rbp),%rsi
mov    -0x158(%rbp),%rdi
mov    -0x160(%rbp),%rcx
call   1120 <op_neg_b@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0x178(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x170(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x168(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1640 <alu+0x430>
lea    -0x38(%rbp),%rax
mov    %rax,-0x180(%rbp)
jmp    164b <alu+0x43b>
mov    -0x28(%rbp),%rax
mov    %rax,-0x180(%rbp)
mov    -0x168(%rbp),%rdx
mov    -0x170(%rbp),%rsi
mov    -0x178(%rbp),%rdi
mov    -0x180(%rbp),%rcx
call   1050 <op_not_a@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0x198(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x190(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x188(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    16ad <alu+0x49d>
lea    -0x38(%rbp),%rax
mov    %rax,-0x1a0(%rbp)
jmp    16b8 <alu+0x4a8>
mov    -0x28(%rbp),%rax
mov    %rax,-0x1a0(%rbp)
mov    -0x188(%rbp),%rdx
mov    -0x190(%rbp),%rsi
mov    -0x198(%rbp),%rdi
mov    -0x1a0(%rbp),%rcx
call   10d0 <op_not_b@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0x1b8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x1a8(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    171a <alu+0x50a>
lea    -0x38(%rbp),%rax
mov    %rax,-0x1c0(%rbp)
jmp    1725 <alu+0x515>
mov    -0x28(%rbp),%rax
mov    %rax,-0x1c0(%rbp)
mov    -0x1a8(%rbp),%rdx
mov    -0x1b0(%rbp),%rsi
mov    -0x1b8(%rbp),%rdi
mov    -0x1c0(%rbp),%rcx
call   10a0 <op_alu_asl@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0x1d8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x1d0(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x1c8(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1787 <alu+0x577>
lea    -0x38(%rbp),%rax
mov    %rax,-0x1e0(%rbp)
jmp    1792 <alu+0x582>
mov    -0x28(%rbp),%rax
mov    %rax,-0x1e0(%rbp)
mov    -0x1c8(%rbp),%rdx
mov    -0x1d0(%rbp),%rsi
mov    -0x1d8(%rbp),%rdi
mov    -0x1e0(%rbp),%rcx
call   1100 <op_alu_lsr@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0x1f8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x1f0(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x1e8(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    17f4 <alu+0x5e4>
lea    -0x38(%rbp),%rax
mov    %rax,-0x200(%rbp)
jmp    17ff <alu+0x5ef>
mov    -0x28(%rbp),%rax
mov    %rax,-0x200(%rbp)
mov    -0x1e8(%rbp),%rdx
mov    -0x1f0(%rbp),%rsi
mov    -0x1f8(%rbp),%rdi
mov    -0x200(%rbp),%rcx
call   10c0 <op_alu_rol@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0x218(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x210(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x208(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1861 <alu+0x651>
lea    -0x38(%rbp),%rax
mov    %rax,-0x220(%rbp)
jmp    186c <alu+0x65c>
mov    -0x28(%rbp),%rax
mov    %rax,-0x220(%rbp)
mov    -0x208(%rbp),%rdx
mov    -0x210(%rbp),%rsi
mov    -0x218(%rbp),%rdi
mov    -0x220(%rbp),%rcx
call   10b0 <op_alu_ror@plt>
jmp    1911 <alu+0x701>
mov    -0x10(%rbp),%rax
mov    %rax,-0x238(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x230(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x228(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    18ce <alu+0x6be>
lea    -0x38(%rbp),%rax
mov    %rax,-0x240(%rbp)
jmp    18d9 <alu+0x6c9>
mov    -0x28(%rbp),%rax
mov    %rax,-0x240(%rbp)
mov    -0x228(%rbp),%rdx
mov    -0x230(%rbp),%rsi
mov    -0x238(%rbp),%rdi
mov    -0x240(%rbp),%rcx
call   1070 <op_alu_reset@plt>
jmp    1911 <alu+0x701>
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0x73d(%rip),%rdi
call   1060 <printf@plt>
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alu>:
sub    $0x18,%rsp
mov    %edi,%eax
movabs $0x3030303030303030,%rdi
30 30 30
mov    %rdi,0x8(%rsp)
movb   $0x0,0x10(%rsp)
cmp    $0xf,%eax
ja     1263 <alu+0x53>
mov    %eax,%eax
lea    0xdc8(%rip),%rdi
movslq (%rdi,%rax,4),%rax
add    %rdi,%rax
jmp    *%rax
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1070 <op_alu_reset@plt>
add    $0x18,%rsp
ret
lea    0xddf(%rip),%rdi
mov    %eax,%esi
mov    %eax,%edx
add    $0x18,%rsp
jmp    1060 <printf@plt>
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   10f0 <op_add@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1110 <op_sub@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1040 <op_and@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1030 <op_or@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   10e0 <op_xor@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1090 <op_neg_a@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1120 <op_neg_b@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1050 <op_not_a@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   10d0 <op_not_b@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1080 <op_adc@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1130 <op_alu_sbc@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   10a0 <op_alu_asl@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1100 <op_alu_lsr@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   10c0 <op_alu_rol@plt>
add    $0x18,%rsp
ret
test   %r8,%r8
lea    0x8(%rsp),%rax
cmovne %r8,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rax,%rcx
call   10b0 <op_alu_ror@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.alu.dummyflags = [9 x i8] c"00000000\00"
@.str = [40 x i8] c"ALU(%i): Invalide operation %i selected\00"
define void @alu(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [9 x i8]
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = bitcast [9 x i8]* %11 to i8*
%13 = load i32, i32* %6
switch i32 %13, label %222 [
i32 1, label %14
i32 10, label %27
i32 2, label %40
i32 11, label %53
i32 3, label %66
i32 4, label %79
i32 5, label %92
i32 6, label %105
i32 7, label %118
i32 8, label %131
i32 9, label %144
i32 12, label %157
i32 13, label %170
i32 14, label %183
i32 15, label %196
i32 0, label %209
]
14: ; preds = %5
%15 = load i8*, i8** %7
%16 = load i8*, i8** %8
%17 = load i8*, i8** %9
%18 = load i8*, i8** %10
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %24
22: ; preds = %14
%23 = load i8*, i8** %10
br label %24
24: ; preds = %22, %20
%25 = phi i8* [ %21, %20 ], [ %23, %22 ]
%26 = call i32 @op_add(i8* %15, i8* %16, i8* %17, i8* %25)
br label %226
27: ; preds = %5
%28 = load i8*, i8** %7
%29 = load i8*, i8** %8
%30 = load i8*, i8** %9
%31 = load i8*, i8** %10
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %37
35: ; preds = %27
%36 = load i8*, i8** %10
br label %37
37: ; preds = %35, %33
%38 = phi i8* [ %34, %33 ], [ %36, %35 ]
%39 = call i32 @op_adc(i8* %28, i8* %29, i8* %30, i8* %38)
br label %226
40: ; preds = %5
%41 = load i8*, i8** %7
%42 = load i8*, i8** %8
%43 = load i8*, i8** %9
%44 = load i8*, i8** %10
%45 = icmp eq i8* %44, null
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %50
48: ; preds = %40
%49 = load i8*, i8** %10
br label %50
50: ; preds = %48, %46
%51 = phi i8* [ %47, %46 ], [ %49, %48 ]
%52 = call i32 @op_sub(i8* %41, i8* %42, i8* %43, i8* %51)
br label %226
53: ; preds = %5
%54 = load i8*, i8** %7
%55 = load i8*, i8** %8
%56 = load i8*, i8** %9
%57 = load i8*, i8** %10
%58 = icmp eq i8* %57, null
br i1 %58, label %59, label %61
59: ; preds = %53
%60 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %63
61: ; preds = %53
%62 = load i8*, i8** %10
br label %63
63: ; preds = %61, %59
%64 = phi i8* [ %60, %59 ], [ %62, %61 ]
%65 = call i32 @op_alu_sbc(i8* %54, i8* %55, i8* %56, i8* %64)
br label %226
66: ; preds = %5
%67 = load i8*, i8** %7
%68 = load i8*, i8** %8
%69 = load i8*, i8** %9
%70 = load i8*, i8** %10
%71 = icmp eq i8* %70, null
br i1 %71, label %72, label %74
72: ; preds = %66
%73 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %76
74: ; preds = %66
%75 = load i8*, i8** %10
br label %76
76: ; preds = %74, %72
%77 = phi i8* [ %73, %72 ], [ %75, %74 ]
%78 = call i32 @op_and(i8* %67, i8* %68, i8* %69, i8* %77)
br label %226
79: ; preds = %5
%80 = load i8*, i8** %7
%81 = load i8*, i8** %8
%82 = load i8*, i8** %9
%83 = load i8*, i8** %10
%84 = icmp eq i8* %83, null
br i1 %84, label %85, label %87
85: ; preds = %79
%86 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %89
87: ; preds = %79
%88 = load i8*, i8** %10
br label %89
89: ; preds = %87, %85
%90 = phi i8* [ %86, %85 ], [ %88, %87 ]
%91 = call i32 @op_or(i8* %80, i8* %81, i8* %82, i8* %90)
br label %226
92: ; preds = %5
%93 = load i8*, i8** %7
%94 = load i8*, i8** %8
%95 = load i8*, i8** %9
%96 = load i8*, i8** %10
%97 = icmp eq i8* %96, null
br i1 %97, label %98, label %100
98: ; preds = %92
%99 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %102
100: ; preds = %92
%101 = load i8*, i8** %10
br label %102
102: ; preds = %100, %98
%103 = phi i8* [ %99, %98 ], [ %101, %100 ]
%104 = call i32 @op_xor(i8* %93, i8* %94, i8* %95, i8* %103)
br label %226
105: ; preds = %5
%106 = load i8*, i8** %7
%107 = load i8*, i8** %8
%108 = load i8*, i8** %9
%109 = load i8*, i8** %10
%110 = icmp eq i8* %109, null
br i1 %110, label %111, label %113
111: ; preds = %105
%112 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %115
113: ; preds = %105
%114 = load i8*, i8** %10
br label %115
115: ; preds = %113, %111
%116 = phi i8* [ %112, %111 ], [ %114, %113 ]
%117 = call i32 @op_neg_a(i8* %106, i8* %107, i8* %108, i8* %116)
br label %226
118: ; preds = %5
%119 = load i8*, i8** %7
%120 = load i8*, i8** %8
%121 = load i8*, i8** %9
%122 = load i8*, i8** %10
%123 = icmp eq i8* %122, null
br i1 %123, label %124, label %126
124: ; preds = %118
%125 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %128
126: ; preds = %118
%127 = load i8*, i8** %10
br label %128
128: ; preds = %126, %124
%129 = phi i8* [ %125, %124 ], [ %127, %126 ]
%130 = call i32 @op_neg_b(i8* %119, i8* %120, i8* %121, i8* %129)
br label %226
131: ; preds = %5
%132 = load i8*, i8** %7
%133 = load i8*, i8** %8
%134 = load i8*, i8** %9
%135 = load i8*, i8** %10
%136 = icmp eq i8* %135, null
br i1 %136, label %137, label %139
137: ; preds = %131
%138 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %141
139: ; preds = %131
%140 = load i8*, i8** %10
br label %141
141: ; preds = %139, %137
%142 = phi i8* [ %138, %137 ], [ %140, %139 ]
%143 = call i32 @op_not_a(i8* %132, i8* %133, i8* %134, i8* %142)
br label %226
144: ; preds = %5
%145 = load i8*, i8** %7
%146 = load i8*, i8** %8
%147 = load i8*, i8** %9
%148 = load i8*, i8** %10
%149 = icmp eq i8* %148, null
br i1 %149, label %150, label %152
150: ; preds = %144
%151 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %154
152: ; preds = %144
%153 = load i8*, i8** %10
br label %154
154: ; preds = %152, %150
%155 = phi i8* [ %151, %150 ], [ %153, %152 ]
%156 = call i32 @op_not_b(i8* %145, i8* %146, i8* %147, i8* %155)
br label %226
157: ; preds = %5
%158 = load i8*, i8** %7
%159 = load i8*, i8** %8
%160 = load i8*, i8** %9
%161 = load i8*, i8** %10
%162 = icmp eq i8* %161, null
br i1 %162, label %163, label %165
163: ; preds = %157
%164 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %167
165: ; preds = %157
%166 = load i8*, i8** %10
br label %167
167: ; preds = %165, %163
%168 = phi i8* [ %164, %163 ], [ %166, %165 ]
%169 = call i32 @op_alu_asl(i8* %158, i8* %159, i8* %160, i8* %168)
br label %226
170: ; preds = %5
%171 = load i8*, i8** %7
%172 = load i8*, i8** %8
%173 = load i8*, i8** %9
%174 = load i8*, i8** %10
%175 = icmp eq i8* %174, null
br i1 %175, label %176, label %178
176: ; preds = %170
%177 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %180
178: ; preds = %170
%179 = load i8*, i8** %10
br label %180
180: ; preds = %178, %176
%181 = phi i8* [ %177, %176 ], [ %179, %178 ]
%182 = call i32 @op_alu_lsr(i8* %171, i8* %172, i8* %173, i8* %181)
br label %226
183: ; preds = %5
%184 = load i8*, i8** %7
%185 = load i8*, i8** %8
%186 = load i8*, i8** %9
%187 = load i8*, i8** %10
%188 = icmp eq i8* %187, null
br i1 %188, label %189, label %191
189: ; preds = %183
%190 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %193
191: ; preds = %183
%192 = load i8*, i8** %10
br label %193
193: ; preds = %191, %189
%194 = phi i8* [ %190, %189 ], [ %192, %191 ]
%195 = call i32 @op_alu_rol(i8* %184, i8* %185, i8* %186, i8* %194)
br label %226
196: ; preds = %5
%197 = load i8*, i8** %7
%198 = load i8*, i8** %8
%199 = load i8*, i8** %9
%200 = load i8*, i8** %10
%201 = icmp eq i8* %200, null
br i1 %201, label %202, label %204
202: ; preds = %196
%203 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %206
204: ; preds = %196
%205 = load i8*, i8** %10
br label %206
206: ; preds = %204, %202
%207 = phi i8* [ %203, %202 ], [ %205, %204 ]
%208 = call i32 @op_alu_ror(i8* %197, i8* %198, i8* %199, i8* %207)
br label %226
209: ; preds = %5
%210 = load i8*, i8** %7
%211 = load i8*, i8** %8
%212 = load i8*, i8** %9
%213 = load i8*, i8** %10
%214 = icmp eq i8* %213, null
br i1 %214, label %215, label %217
215: ; preds = %209
%216 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
br label %219
217: ; preds = %209
%218 = load i8*, i8** %10
br label %219
219: ; preds = %217, %215
%220 = phi i8* [ %216, %215 ], [ %218, %217 ]
%221 = call i32 @op_alu_reset(i8* %210, i8* %211, i8* %212, i8* %220)
br label %226
222: ; preds = %5
%223 = load i32, i32* %6
%224 = load i32, i32* %6
%225 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %223, i32 %224)
br label %226
226: ; preds = %222, %219, %206, %193, %180, %167, %154, %141, %128, %115, %102, %89, %76, %63, %50, %37, %24
ret void
}

LLVM IR (-O2):
@__const.alu.dummyflags = [9 x i8] c"00000000\00"
@.str = [40 x i8] c"ALU(%i): Invalide operation %i selected\00"
define void @alu(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca [9 x i8]
%7 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
switch i32 %0, label %72 [
i32 1, label %8
i32 10, label %12
i32 2, label %16
i32 11, label %20
i32 3, label %24
i32 4, label %28
i32 5, label %32
i32 6, label %36
i32 7, label %40
i32 8, label %44
i32 9, label %48
i32 12, label %52
i32 13, label %56
i32 14, label %60
i32 15, label %64
i32 0, label %68
]
8: ; preds = %5
%9 = icmp eq i8* %4, null
%10 = select i1 %9, i8* %7, i8* %4
%11 = call i32 @op_add(i8* %1, i8* %2, i8* %3, i8* %10)
br label %74
12: ; preds = %5
%13 = icmp eq i8* %4, null
%14 = select i1 %13, i8* %7, i8* %4
%15 = call i32 @op_adc(i8* %1, i8* %2, i8* %3, i8* %14)
br label %74
16: ; preds = %5
%17 = icmp eq i8* %4, null
%18 = select i1 %17, i8* %7, i8* %4
%19 = call i32 @op_sub(i8* %1, i8* %2, i8* %3, i8* %18)
br label %74
20: ; preds = %5
%21 = icmp eq i8* %4, null
%22 = select i1 %21, i8* %7, i8* %4
%23 = call i32 @op_alu_sbc(i8* %1, i8* %2, i8* %3, i8* %22)
br label %74
24: ; preds = %5
%25 = icmp eq i8* %4, null
%26 = select i1 %25, i8* %7, i8* %4
%27 = call i32 @op_and(i8* %1, i8* %2, i8* %3, i8* %26)
br label %74
28: ; preds = %5
%29 = icmp eq i8* %4, null
%30 = select i1 %29, i8* %7, i8* %4
%31 = call i32 @op_or(i8* %1, i8* %2, i8* %3, i8* %30)
br label %74
32: ; preds = %5
%33 = icmp eq i8* %4, null
%34 = select i1 %33, i8* %7, i8* %4
%35 = call i32 @op_xor(i8* %1, i8* %2, i8* %3, i8* %34)
br label %74
36: ; preds = %5
%37 = icmp eq i8* %4, null
%38 = select i1 %37, i8* %7, i8* %4
%39 = call i32 @op_neg_a(i8* %1, i8* %2, i8* %3, i8* %38)
br label %74
40: ; preds = %5
%41 = icmp eq i8* %4, null
%42 = select i1 %41, i8* %7, i8* %4
%43 = call i32 @op_neg_b(i8* %1, i8* %2, i8* %3, i8* %42)
br label %74
44: ; preds = %5
%45 = icmp eq i8* %4, null
%46 = select i1 %45, i8* %7, i8* %4
%47 = call i32 @op_not_a(i8* %1, i8* %2, i8* %3, i8* %46)
br label %74
48: ; preds = %5
%49 = icmp eq i8* %4, null
%50 = select i1 %49, i8* %7, i8* %4
%51 = call i32 @op_not_b(i8* %1, i8* %2, i8* %3, i8* %50)
br label %74
52: ; preds = %5
%53 = icmp eq i8* %4, null
%54 = select i1 %53, i8* %7, i8* %4
%55 = call i32 @op_alu_asl(i8* %1, i8* %2, i8* %3, i8* %54)
br label %74
56: ; preds = %5
%57 = icmp eq i8* %4, null
%58 = select i1 %57, i8* %7, i8* %4
%59 = call i32 @op_alu_lsr(i8* %1, i8* %2, i8* %3, i8* %58)
br label %74
60: ; preds = %5
%61 = icmp eq i8* %4, null
%62 = select i1 %61, i8* %7, i8* %4
%63 = call i32 @op_alu_rol(i8* %1, i8* %2, i8* %3, i8* %62)
br label %74
64: ; preds = %5
%65 = icmp eq i8* %4, null
%66 = select i1 %65, i8* %7, i8* %4
%67 = call i32 @op_alu_ror(i8* %1, i8* %2, i8* %3, i8* %66)
br label %74
68: ; preds = %5
%69 = icmp eq i8* %4, null
%70 = select i1 %69, i8* %7, i8* %4
%71 = call i32 @op_alu_reset(i8* %1, i8* %2, i8* %3, i8* %70)
br label %74
72: ; preds = %5
%73 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %0)
br label %74
74: ; preds = %72, %68, %64, %60, %56, %52, %48, %44, %40, %36, %32, %28, %24, %20, %16, %12, %8
ret void
}