int add_and(base) {
  int dest = 0b0000111000000000, src1 = 0b0000000111000000,
      src2 = 0b000000000000000111, dir_addr = 0b0000000000100000,
      op_c = 0b1111000000000000;
  int direct_addr, dest_reg, src1_reg, src2_reg, opcode_r = 0;
  char assembly[50] = "";
  char string_print;
  dest_reg = base & dest;
  src1_reg = base & src1;
  src2_reg = base & src2;
  direct_addr = base & dir_addr;
  opcode_r = base & op_c;
  if (opcode_r == 0b0001000000000000) {
    printf("add ");
  } else if (opcode_r == 0b0101000000000000) {
    printf("and ");
  }
  printf("r%d,", dest_reg >> 9);
  printf("r%d,", src1_reg >> 6);
  if (direct_addr == 0b0000000000100000) {
    immediate_addressing(base);
  } else {
    printf("r%d\n", src2_reg);
  }
  return 0;
}


x86 assembly (clang, -O0):
<add_and>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xe00,-0x8(%rbp)
movl   $0x1c0,-0xc(%rbp)
movl   $0x7,-0x10(%rbp)
movl   $0x20,-0x14(%rbp)
movl   $0xf000,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
and    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%eax
and    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x1000,-0x2c(%rbp)
jne    11c2 <add_and+0x92>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e2 <add_and+0xb2>
cmpl   $0x5000,-0x2c(%rbp)
jne    11dd <add_and+0xad>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e2 <add_and+0xb2>
mov    -0x20(%rbp),%esi
sar    $0x9,%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
sar    $0x6,%esi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x20,-0x1c(%rbp)
jne    1223 <add_and+0xf3>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1040 <immediate_addressing@plt>
jmp    1234 <add_and+0x104>
mov    -0x28(%rbp),%esi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_and>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%eax
and    $0xf000,%eax
cmp    $0x1000,%eax
je     1147 <add_and+0x27>
movzwl %ax,%eax
cmp    $0x5000,%eax
jne    1155 <add_and+0x35>
lea    0xec0(%rip),%rdi
jmp    114e <add_and+0x2e>
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%esi
shr    $0x9,%esi
and    $0x7,%esi
lea    0xea6(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%esi
shr    $0x6,%esi
and    $0x7,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   $0x20,%bl
jne    119a <add_and+0x7a>
and    $0x7,%ebx
lea    0xe80(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11a3 <add_and+0x83>
mov    %ebx,%edi
xor    %eax,%eax
call   1040 <immediate_addressing@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"add \00"
@.str.1 = [5 x i8] c"and \00"
@.str.2 = [5 x i8] c"r%d,\00"
@.str.3 = [5 x i8] c"r%d\0A\00"
define i32 @add_and(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [50 x i8]
%14 = alloca i8
store i32 %0, i32* %2
store i32 3584, i32* %3
store i32 448, i32* %4
store i32 7, i32* %5
store i32 32, i32* %6
store i32 61440, i32* %7
store i32 0, i32* %12
%15 = bitcast [50 x i8]* %13 to i8*
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = and i32 %16, %17
store i32 %18, i32* %9
%19 = load i32, i32* %2
%20 = load i32, i32* %4
%21 = and i32 %19, %20
store i32 %21, i32* %10
%22 = load i32, i32* %2
%23 = load i32, i32* %5
%24 = and i32 %22, %23
store i32 %24, i32* %11
%25 = load i32, i32* %2
%26 = load i32, i32* %6
%27 = and i32 %25, %26
store i32 %27, i32* %8
%28 = load i32, i32* %2
%29 = load i32, i32* %7
%30 = and i32 %28, %29
store i32 %30, i32* %12
%31 = load i32, i32* %12
%32 = icmp eq i32 %31, 4096
br i1 %32, label %33, label %35
33: ; preds = %1
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %41
35: ; preds = %1
%36 = load i32, i32* %12
%37 = icmp eq i32 %36, 20480
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38, %35
br label %41
41: ; preds = %40, %33
%42 = load i32, i32* %9
%43 = ashr i32 %42, 9
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %10
%46 = ashr i32 %45, 6
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %8
%49 = icmp eq i32 %48, 32
br i1 %49, label %50, label %53
50: ; preds = %41
%51 = load i32, i32* %2
%52 = call i32 (i32, ...) bitcast (i32 (...)* @immediate_addressing to i32 (i32, ...)*)(i32 %51)
br label %56
53: ; preds = %41
%54 = load i32, i32* %11
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %53, %50
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"add \00"
@.str.1 = [5 x i8] c"and \00"
@.str.2 = [5 x i8] c"r%d,\00"
@.str.3 = [5 x i8] c"r%d\0A\00"
define i32 @add_and(i32 %0) {
%2 = and i32 %0, 7
%3 = and i32 %0, 32
%4 = trunc i32 %0 to i16
%5 = and i16 %4, -4096
switch i16 %5, label %10 [
i16 4096, label %7
i16 20480, label %6
]
6: ; preds = %1
br label %7
7: ; preds = %1, %6
%8 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %1 ]
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %8)
br label %10
10: ; preds = %7, %1
%11 = lshr i32 %0, 9
%12 = and i32 %11, 7
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = lshr i32 %0, 6
%15 = and i32 %14, 7
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = icmp eq i32 %3, 0
br i1 %17, label %20, label %18
18: ; preds = %10
%19 = tail call i32 (i32, ...) bitcast (i32 (...)* @immediate_addressing to i32 (i32, ...)*)(i32 %0)
br label %22
20: ; preds = %10
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %2)
br label %22
22: ; preds = %20, %18
ret i32 0
}