#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*/ getchar();
int /*<<< orphan*/ mostra_bin(int);
int /*<<< orphan*/ printf(char *);
void teste_macros() {
  int i, portC = 0, size = 8 * sizeof(int);
  printf(":: TESTE DAS MACROS ::\n");
  printf("\nTestando a macro set_bit(var,bit): \n");
  getchar();
  for (i = 0; i < 2 * size; i++) {
    mostra_bin(portC);
    printf("\t -> \t");
    mostra_bin(portC |= (1 << i));
    printf("\n");
  }
  printf("\nTestando a macro clear_bit(var,bit): \n");
  getchar();
  for (i = 0; i < 2 * size; i++) {
    mostra_bin(portC);
    printf("\t -> \t");
    mostra_bin(portC &= ~(1 << i));
    printf("\n");
  }
  printf("\nTestando a macro cpl_bit(var,bit): \n");
  getchar();
  for (i = 0; i < 2 * size; i++) {
    mostra_bin(1 << i);
    printf("\t -> \t");
    mostra_bin(portC ^= (1 << i));
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<teste_macros>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x20,-0xc(%rbp)
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    11c0 <teste_macros+0x90>
mov    -0x8(%rbp),%edi
call   1030 <mostra_bin@plt>
lea    0xeb2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    $0x1,%edi
shl    %cl,%edi
or     -0x8(%rbp),%edi
mov    %edi,-0x8(%rbp)
call   1030 <mostra_bin@plt>
lea    0xee4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    116c <teste_macros+0x3c>
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1231 <teste_macros+0x101>
mov    -0x8(%rbp),%edi
call   1030 <mostra_bin@plt>
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    $0x1,%edi
shl    %cl,%edi
xor    $0xffffffff,%edi
and    -0x8(%rbp),%edi
mov    %edi,-0x8(%rbp)
call   1030 <mostra_bin@plt>
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11da <teste_macros+0xaa>
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    12a6 <teste_macros+0x176>
mov    -0x4(%rbp),%ecx
mov    $0x1,%edi
shl    %cl,%edi
call   1030 <mostra_bin@plt>
lea    0xdcc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    $0x1,%edi
shl    %cl,%edi
xor    -0x8(%rbp),%edi
mov    %edi,-0x8(%rbp)
call   1030 <mostra_bin@plt>
lea    0xdfe(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    124b <teste_macros+0x11b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<teste_macros>:
push   %rbp
push   %r14
push   %rbx
lea    0xeac(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <getchar@plt>
lea    0xe84(%rip),%r14
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %ebp,%edi
call   1050 <mostra_bin@plt>
mov    %r14,%rdi
call   1060 <printf@plt>
bts    %ebx,%ebp
mov    %ebp,%edi
call   1050 <mostra_bin@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    $0x40,%ebx
jne    1180 <teste_macros+0x30>
lea    0xe91(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>

LLVM IR (-O0):
@.str = [24 x i8] c":: TESTE DAS MACROS ::\0A\00"
@.str.1 = [38 x i8] c"\0ATestando a macro set_bit(var,bit): \0A\00"
@.str.2 = [7 x i8] c"\09 -> \09\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [40 x i8] c"\0ATestando a macro clear_bit(var,bit): \0A\00"
@.str.5 = [38 x i8] c"\0ATestando a macro cpl_bit(var,bit): \0A\00"
define void @teste_macros() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
store i32 32, i32* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (...) @getchar()
store i32 0, i32* %1
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %1
%9 = load i32, i32* %3
%10 = mul nsw i32 2, %9
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %25
12: ; preds = %7
%13 = load i32, i32* %2
%14 = call i32 @mostra_bin(i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* %1
%17 = shl i32 1, %16
%18 = load i32, i32* %2
%19 = or i32 %18, %17
store i32 %19, i32* %2
%20 = call i32 @mostra_bin(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %12
%23 = load i32, i32* %1
%24 = add nsw i32 %23, 1
store i32 %24, i32* %1
br label %7
25: ; preds = %7
%26 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 (...) @getchar()
store i32 0, i32* %1
br label %28
28: ; preds = %44, %25
%29 = load i32, i32* %1
%30 = load i32, i32* %3
%31 = mul nsw i32 2, %30
%32 = icmp slt i32 %29, %31
br i1 %32, label %33, label %47
33: ; preds = %28
%34 = load i32, i32* %2
%35 = call i32 @mostra_bin(i32 %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32, i32* %1
%38 = shl i32 1, %37
%39 = xor i32 %38, -1
%40 = load i32, i32* %2
%41 = and i32 %40, %39
store i32 %41, i32* %2
%42 = call i32 @mostra_bin(i32 %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %44
44: ; preds = %33
%45 = load i32, i32* %1
%46 = add nsw i32 %45, 1
store i32 %46, i32* %1
br label %28
47: ; preds = %28
%48 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%49 = call i32 (...) @getchar()
store i32 0, i32* %1
br label %50
50: ; preds = %66, %47
%51 = load i32, i32* %1
%52 = load i32, i32* %3
%53 = mul nsw i32 2, %52
%54 = icmp slt i32 %51, %53
br i1 %54, label %55, label %69
55: ; preds = %50
%56 = load i32, i32* %1
%57 = shl i32 1, %56
%58 = call i32 @mostra_bin(i32 %57)
%59 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%60 = load i32, i32* %1
%61 = shl i32 1, %60
%62 = load i32, i32* %2
%63 = xor i32 %62, %61
store i32 %63, i32* %2
%64 = call i32 @mostra_bin(i32 %63)
%65 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %66
66: ; preds = %55
%67 = load i32, i32* %1
%68 = add nsw i32 %67, 1
store i32 %68, i32* %1
br label %50
69: ; preds = %50
ret void
}

LLVM IR (-O2):
@.str.2 = [7 x i8] c"\09 -> \09\00"
@str = [23 x i8] c":: TESTE DAS MACROS ::\00"
@str.6 = [37 x i8] c"\0ATestando a macro set_bit(var,bit): \00"
@str.7 = [39 x i8] c"\0ATestando a macro clear_bit(var,bit): \00"
define void @teste_macros() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.6, i64 0, i64 0))
%3 = tail call i32 (...) @getchar()
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %13, %4 ]
%6 = phi i32 [ 0, %0 ], [ %10, %4 ]
%7 = tail call i32 @mostra_bin(i32 %6)
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%9 = shl nuw i32 1, %5
%10 = or i32 %9, %6
%11 = tail call i32 @mostra_bin(i32 %10)
%12 = tail call i32 @putchar(i32 10)
%13 = add nuw nsw i32 %5, 1
%14 = icmp eq i32 %13, 64
br i1 %14, label %15, label %4
15: ; preds = %4
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.7, i64 0, i64 0))
%17 = tail call i32 (...) @getchar()
unreachable
}