#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*/ printf(char *);
int /*<<< orphan*/ trocaColunaPeq(int, int);
void trocaColunaGrande(int cgrande1, int cgrande2) {
  if (cgrande1 > 2 || cgrande2 > 2)
    printf("ERRO COLUNA GRANDE");
  else {
    trocaColunaPeq(cgrande1 * 3, cgrande2 * 3);
    trocaColunaPeq(cgrande1 * 3 + 1, cgrande2 * 3 + 1);
    trocaColunaPeq(cgrande1 * 3 + 2, cgrande2 * 3 + 2);
  }
}


x86 assembly (clang, -O0):
<trocaColunaGrande>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x2,-0x4(%rbp)
jg     1142 <trocaColunaGrande+0x22>
cmpl   $0x2,-0x8(%rbp)
jle    1153 <trocaColunaGrande+0x33>
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
jmp    1186 <trocaColunaGrande+0x66>
imul   $0x3,-0x4(%rbp),%edi
imul   $0x3,-0x8(%rbp),%esi
call   1030 <trocaColunaPeq@plt>
imul   $0x3,-0x4(%rbp),%edi
add    $0x1,%edi
imul   $0x3,-0x8(%rbp),%esi
add    $0x1,%esi
call   1030 <trocaColunaPeq@plt>
imul   $0x3,-0x4(%rbp),%edi
add    $0x2,%edi
imul   $0x3,-0x8(%rbp),%esi
add    $0x2,%esi
call   1030 <trocaColunaPeq@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trocaColunaGrande>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jg     116a <trocaColunaGrande+0x4a>
mov    %esi,%r14d
cmp    $0x3,%esi
jge    116a <trocaColunaGrande+0x4a>
mov    %edi,%ebx
lea    (%rbx,%rbx,2),%edi
lea    (%r14,%r14,2),%esi
call   1030 <trocaColunaPeq@plt>
lea    (%rbx,%rbx,2),%edi
add    $0x1,%edi
lea    (%r14,%r14,2),%esi
add    $0x1,%esi
call   1030 <trocaColunaPeq@plt>
lea    (%rbx,%rbx,2),%edi
add    $0x2,%edi
lea    (%r14,%r14,2),%esi
add    $0x2,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <trocaColunaPeq@plt>
lea    0xe8f(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"ERRO COLUNA GRANDE\00"
define void @trocaColunaGrande(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp sgt i32 %5, 2
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %7, %2
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %32
12: ; preds = %7
%13 = load i32, i32* %3
%14 = mul nsw i32 %13, 3
%15 = load i32, i32* %4
%16 = mul nsw i32 %15, 3
%17 = call i32 @trocaColunaPeq(i32 %14, i32 %16)
%18 = load i32, i32* %3
%19 = mul nsw i32 %18, 3
%20 = add nsw i32 %19, 1
%21 = load i32, i32* %4
%22 = mul nsw i32 %21, 3
%23 = add nsw i32 %22, 1
%24 = call i32 @trocaColunaPeq(i32 %20, i32 %23)
%25 = load i32, i32* %3
%26 = mul nsw i32 %25, 3
%27 = add nsw i32 %26, 2
%28 = load i32, i32* %4
%29 = mul nsw i32 %28, 3
%30 = add nsw i32 %29, 2
%31 = call i32 @trocaColunaPeq(i32 %27, i32 %30)
br label %32
32: ; preds = %12, %10
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"ERRO COLUNA GRANDE\00"
define void @trocaColunaGrande(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, 2
%4 = icmp sgt i32 %1, 2
%5 = or i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %18
8: ; preds = %2
%9 = mul nsw i32 %0, 3
%10 = mul nsw i32 %1, 3
%11 = tail call i32 @trocaColunaPeq(i32 %9, i32 %10)
%12 = add nsw i32 %9, 1
%13 = add nsw i32 %10, 1
%14 = tail call i32 @trocaColunaPeq(i32 %12, i32 %13)
%15 = add nsw i32 %9, 2
%16 = add nsw i32 %10, 2
%17 = tail call i32 @trocaColunaPeq(i32 %15, i32 %16)
br label %18
18: ; preds = %8, %6
ret void
}