#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 *);
void imprimirDirecao(int direcaoDaFace) {
  direcaoDaFace = direcaoDaFace % 4;
  direcaoDaFace = direcaoDaFace < 0 ? 4 + direcaoDaFace : direcaoDaFace;
  switch (direcaoDaFace) {
  case 0:
    printf("N\n");
    break;
  case 1:
    printf("L\n");
    break;
  case 2:
    printf("S\n");
    break;
  case 3:
    printf("O\n");
    break;
  }
}


x86 assembly (clang, -O0):
<imprimirDirecao>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1141 <imprimirDirecao+0x31>
mov    -0x4(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x8(%rbp)
jmp    1147 <imprimirDirecao+0x37>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x3,%rax
ja     11b1 <imprimirDirecao+0xa1>
mov    -0x10(%rbp),%rax
lea    0xe97(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
jmp    11b1 <imprimirDirecao+0xa1>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
jmp    11b1 <imprimirDirecao+0xa1>
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
jmp    11b1 <imprimirDirecao+0xa1>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imprimirDirecao>:
lea    0x3(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
and    $0xfffffffc,%eax
mov    %edi,%ecx
sub    %eax,%ecx
neg    %eax
test   %ecx,%ecx
lea    0x4(%rdi,%rax,1),%eax
cmovns %ecx,%eax
cmp    $0x3,%eax
ja     1144 <imprimirDirecao+0x34>
cltq
lea    0xed0(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1030 <puts@plt>
ret

LLVM IR (-O0):
@.str = [3 x i8] c"N\0A\00"
@.str.1 = [3 x i8] c"L\0A\00"
@.str.2 = [3 x i8] c"S\0A\00"
@.str.3 = [3 x i8] c"O\0A\00"
define void @imprimirDirecao(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = srem i32 %3, 4
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %2
%9 = add nsw i32 4, %8
br label %12
10: ; preds = %1
%11 = load i32, i32* %2
br label %12
12: ; preds = %10, %7
%13 = phi i32 [ %9, %7 ], [ %11, %10 ]
store i32 %13, i32* %2
%14 = load i32, i32* %2
switch i32 %14, label %23 [
i32 0, label %15
i32 1, label %17
i32 2, label %19
i32 3, label %21
]
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %23
17: ; preds = %12
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %23
19: ; preds = %12
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %23
21: ; preds = %12
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %12, %21, %19, %17, %15
ret void
}

LLVM IR (-O2):
@str = [2 x i8] c"O\00"
@str.4 = [2 x i8] c"S\00"
@str.5 = [2 x i8] c"L\00"
@str.6 = [2 x i8] c"N\00"
@reltable.imprimirDirecao = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @str.6 to i64), i64 ptrtoint ([4 x i32]* @reltable.imprimirDirecao to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @str.5 to i64), i64 ptrtoint ([4 x i32]* @reltable.imprimirDirecao to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.imprimirDirecao to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @str to i64), i64 ptrtoint ([4 x i32]* @reltable.imprimirDirecao to i64)) to i32)]
define void @imprimirDirecao(i32 %0) {
%2 = srem i32 %0, 4
%3 = icmp slt i32 %2, 0
%4 = add nsw i32 %2, 4
%5 = select i1 %3, i32 %4, i32 %2
%6 = icmp ult i32 %5, 4
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.imprimirDirecao to i8*), i64 %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
br label %12
12: ; preds = %1, %7
ret void
}