#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 *_add(int /*<<< orphan*/, int /*<<< orphan*/);
int *_and(int /*<<< orphan*/, int /*<<< orphan*/);
int *_or(int /*<<< orphan*/, int /*<<< orphan*/);
int *_sub(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ binToDec(int);
int /*<<< orphan*/ print_bin(int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int op_byte = 1;
  int p_entry;
  int s_entry;
  int *result;
  printf("\t .:Multiplexador:.");
  printf("\n0001 - AND operation.\n0010 - OR operation.\n0100 - ADD "
         "operation\n1000 - SUB operation\n0000 - Sair.\n");
  while (op_byte != 0) {
    printf("Byte de operação:");
    scanf("%d", &op_byte);
    printf("Primeira Entrada(Decimal):");
    scanf("%d", &p_entry);
    printf("Segunda Entrada(Decimal):");
    scanf("%d", &s_entry);
    switch (op_byte) {
    case 0:
      printf("Saindo.\n");
      break;
    case 1:
      result = _and(binToDec(p_entry), binToDec(s_entry));
      printf("_AND:");
      print_bin(result);
      printf("\n");
      break;
    case 10:
      result = _or(binToDec(p_entry), binToDec(s_entry));
      printf("_OR:");
      print_bin(result);
      printf("\n");
      break;
    case 100:
      result = _add(binToDec(p_entry), binToDec(s_entry));
      printf("_ADD:");
      print_bin(result);
      printf("\n");
      break;
    case 1000:
      result = _sub(binToDec(p_entry), binToDec(s_entry));
      printf("_SUB:");
      print_bin(result);
      printf("\n");
      break;
    default:
      printf("> Erro: Byte de Operação Inválido.\n");
    }
  };
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     13a1 <main+0x221>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
mov    %rdi,-0x28(%rbp)
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     1263 <main+0xe3>
jmp    121d <main+0x9d>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
je     1274 <main+0xf4>
jmp    122e <main+0xae>
mov    -0x1c(%rbp),%eax
sub    $0xa,%eax
je     12bb <main+0x13b>
jmp    123f <main+0xbf>
mov    -0x1c(%rbp),%eax
sub    $0x64,%eax
je     1302 <main+0x182>
jmp    1250 <main+0xd0>
mov    -0x1c(%rbp),%eax
sub    $0x3e8,%eax
je     1349 <main+0x1c9>
jmp    1390 <main+0x210>
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
jmp    139c <main+0x21c>
mov    -0xc(%rbp),%edi
call   1080 <binToDec@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%edi
call   1080 <binToDec@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
call   1090 <_and@plt>
mov    %rax,-0x18(%rbp)
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <print_bin@plt>
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
jmp    139c <main+0x21c>
mov    -0xc(%rbp),%edi
call   1080 <binToDec@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%edi
call   1080 <binToDec@plt>
mov    -0x30(%rbp),%edi
mov    %eax,%esi
call   10a0 <_or@plt>
mov    %rax,-0x18(%rbp)
lea    0xdf0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <print_bin@plt>
lea    0xe11(%rip),%rdi
call   1030 <printf@plt>
jmp    139c <main+0x21c>
mov    -0xc(%rbp),%edi
call   1080 <binToDec@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%edi
call   1080 <binToDec@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%esi
call   1040 <_add@plt>
mov    %rax,-0x18(%rbp)
lea    0xdae(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <print_bin@plt>
lea    0xdca(%rip),%rdi
call   1030 <printf@plt>
jmp    139c <main+0x21c>
mov    -0xc(%rbp),%edi
call   1080 <binToDec@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%edi
call   1080 <binToDec@plt>
mov    -0x38(%rbp),%edi
mov    %eax,%esi
call   1050 <_sub@plt>
mov    %rax,-0x18(%rbp)
lea    0xd6d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <print_bin@plt>
lea    0xd83(%rip),%rdi
call   1030 <printf@plt>
jmp    139c <main+0x21c>
lea    0xd4d(%rip),%rdi
call   1030 <printf@plt>
jmp    11ae <main+0x2e>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x1,0x14(%rsp)
lea    0xe43(%rip),%rdi
call   1050 <printf@plt>
lea    0xeae(%rip),%rdi
call   1040 <puts@plt>
lea    0xe3f(%rip),%r15
lea    0xe4c(%rip),%rbx
lea    0x10(%rsp),%r13
lea    0xe5e(%rip),%r12
lea    0xc(%rsp),%r14
jmp    1238 <main+0x98>
mov    0x10(%rsp),%edi
call   10a0 <binToDec@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
call   10a0 <binToDec@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   10c0 <_or@plt>
mov    %rax,%rbp
lea    0xe50(%rip),%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1080 <print_bin@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x14(%rsp)
je     1359 <main+0x1b9>
mov    %r15,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
lea    0x14(%rsp),%rsi
call   1090 <scanf@plt>
lea    0xdd7(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <scanf@plt>
mov    %r12,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x9,%eax
jle    12d0 <main+0x130>
cmp    $0xa,%eax
je     11ef <main+0x4f>
cmp    $0x64,%eax
je     130d <main+0x16d>
cmp    $0x3e8,%eax
jne    1342 <main+0x1a2>
mov    0x10(%rsp),%edi
call   10a0 <binToDec@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
call   10a0 <binToDec@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1070 <_sub@plt>
mov    %rax,%rbp
lea    0xdb1(%rip),%rdi
jmp    1216 <main+0x76>
cs nopw 0x0(%rax,%rax,1)
nop
test   %eax,%eax
je     1339 <main+0x199>
cmp    $0x1,%eax
jne    1342 <main+0x1a2>
mov    0x10(%rsp),%edi
call   10a0 <binToDec@plt>
mov    %r15,%rbp
mov    %eax,%r15d
mov    0xc(%rsp),%edi
call   10a0 <binToDec@plt>
mov    %r15d,%edi
mov    %rbp,%r15
mov    %eax,%esi
call   10b0 <_and@plt>
mov    %rax,%rbp
lea    0xd58(%rip),%rdi
jmp    1216 <main+0x76>
mov    0x10(%rsp),%edi
call   10a0 <binToDec@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
call   10a0 <binToDec@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <_add@plt>
mov    %rax,%rbp
lea    0xd37(%rip),%rdi
jmp    1216 <main+0x76>
lea    0xd9a(%rip),%rdi
jmp    1349 <main+0x1a9>
lea    0xd99(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x14(%rsp)
jne    1238 <main+0x98>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\09 .:Multiplexador:.\00"
@.str.1 = [100 x i8] c"\0A0001 - AND operation.\0A0010 - OR operation.\0A0100 - ADD operation\0A1000 - SUB operation\0A0000 - Sair.\0A\00"
@.str.2 = [20 x i8] c"Byte de opera\C3\A7\C3\A3o:\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [27 x i8] c"Primeira Entrada(Decimal):\00"
@.str.5 = [26 x i8] c"Segunda Entrada(Decimal):\00"
@.str.6 = [9 x i8] c"Saindo.\0A\00"
@.str.7 = [6 x i8] c"_AND:\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [5 x i8] c"_OR:\00"
@.str.10 = [6 x i8] c"_ADD:\00"
@.str.11 = [6 x i8] c"_SUB:\00"
@.str.12 = [39 x i8] c"> Erro: Byte de Opera\C3\A7\C3\A3o Inv\C3\A1lido.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 0, i32* %1
store i32 1, i32* %2
%6 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %63, %0
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %64
11: ; preds = %8
%12 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%14 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%16 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%18 = load i32, i32* %2
switch i32 %18, label %61 [
i32 0, label %19
i32 1, label %21
i32 10, label %31
i32 100, label %41
i32 1000, label %51
]
19: ; preds = %11
%20 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %63
21: ; preds = %11
%22 = load i32, i32* %3
%23 = call i32 @binToDec(i32 %22)
%24 = load i32, i32* %4
%25 = call i32 @binToDec(i32 %24)
%26 = call i32* @_and(i32 %23, i32 %25)
store i32* %26, i32** %5
%27 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%28 = load i32*, i32** %5
%29 = call i32 @print_bin(i32* %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %63
31: ; preds = %11
%32 = load i32, i32* %3
%33 = call i32 @binToDec(i32 %32)
%34 = load i32, i32* %4
%35 = call i32 @binToDec(i32 %34)
%36 = call i32* @_or(i32 %33, i32 %35)
store i32* %36, i32** %5
%37 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%38 = load i32*, i32** %5
%39 = call i32 @print_bin(i32* %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %63
41: ; preds = %11
%42 = load i32, i32* %3
%43 = call i32 @binToDec(i32 %42)
%44 = load i32, i32* %4
%45 = call i32 @binToDec(i32 %44)
%46 = call i32* @_add(i32 %43, i32 %45)
store i32* %46, i32** %5
%47 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%48 = load i32*, i32** %5
%49 = call i32 @print_bin(i32* %48)
%50 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %63
51: ; preds = %11
%52 = load i32, i32* %3
%53 = call i32 @binToDec(i32 %52)
%54 = load i32, i32* %4
%55 = call i32 @binToDec(i32 %54)
%56 = call i32* @_sub(i32 %53, i32 %55)
store i32* %56, i32** %5
%57 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%58 = load i32*, i32** %5
%59 = call i32 @print_bin(i32* %58)
%60 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %63
61: ; preds = %11
%62 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0))
br label %63
63: ; preds = %61, %51, %41, %31, %21, %19
br label %8
64: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"\09 .:Multiplexador:.\00"
@.str.2 = [20 x i8] c"Byte de opera\C3\A7\C3\A3o:\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [27 x i8] c"Primeira Entrada(Decimal):\00"
@.str.5 = [26 x i8] c"Segunda Entrada(Decimal):\00"
@.str.7 = [6 x i8] c"_AND:\00"
@.str.9 = [5 x i8] c"_OR:\00"
@.str.10 = [6 x i8] c"_ADD:\00"
@.str.11 = [6 x i8] c"_SUB:\00"
@str = [99 x i8] c"\0A0001 - AND operation.\0A0010 - OR operation.\0A0100 - ADD operation\0A1000 - SUB operation\0A0000 - Sair.\00"
@str.13 = [8 x i8] c"Saindo.\00"
@str.14 = [38 x i8] c"> Erro: Byte de Opera\C3\A7\C3\A3o Inv\C3\A1lido.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([99 x i8], [99 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %0, %57
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %1
switch i32 %16, label %55 [
i32 0, label %17
i32 1, label %19
i32 10, label %28
i32 100, label %37
i32 1000, label %46
]
17: ; preds = %9
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.13, i64 0, i64 0))
br label %57
19: ; preds = %9
%20 = load i32, i32* %2
%21 = call i32 @binToDec(i32 %20)
%22 = load i32, i32* %3
%23 = call i32 @binToDec(i32 %22)
%24 = call i32* @_and(i32 %21, i32 %23)
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%26 = call i32 @print_bin(i32* %24)
%27 = call i32 @putchar(i32 10)
br label %57
28: ; preds = %9
%29 = load i32, i32* %2
%30 = call i32 @binToDec(i32 %29)
%31 = load i32, i32* %3
%32 = call i32 @binToDec(i32 %31)
%33 = call i32* @_or(i32 %30, i32 %32)
%34 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%35 = call i32 @print_bin(i32* %33)
%36 = call i32 @putchar(i32 10)
br label %57
37: ; preds = %9
%38 = load i32, i32* %2
%39 = call i32 @binToDec(i32 %38)
%40 = load i32, i32* %3
%41 = call i32 @binToDec(i32 %40)
%42 = call i32* @_add(i32 %39, i32 %41)
%43 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%44 = call i32 @print_bin(i32* %42)
%45 = call i32 @putchar(i32 10)
br label %57
46: ; preds = %9
%47 = load i32, i32* %2
%48 = call i32 @binToDec(i32 %47)
%49 = load i32, i32* %3
%50 = call i32 @binToDec(i32 %49)
%51 = call i32* @_sub(i32 %48, i32 %50)
%52 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%53 = call i32 @print_bin(i32* %51)
%54 = call i32 @putchar(i32 10)
br label %57
55: ; preds = %9
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.14, i64 0, i64 0))
br label %57
57: ; preds = %55, %46, %37, %28, %19, %17
%58 = load i32, i32* %1
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %9
60: ; preds = %57
ret i32 0
}