#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*/ print(int *);
int /*<<< orphan*/ print_inverso(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int vet[50] = {0};
  int cod;
  printf("Informe o codigo: ");
  scanf("%d", &cod);
  printf("---Alimente o vetor---\n");
  for (int i = 0; i < 50; i++) {
    printf("Posicao %d: ", i + 1);
    scanf("%d", &vet[i]);
  }
  switch (cod) {
  case 1:
    print(vet);
    break;
  case 2:
    print_inverso(vet);
    break;
  default:
    printf("Operacao invalida!\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1040 <memset@plt>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
lea    -0xd4(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xd8(%rbp)
cmpl   $0x32,-0xd8(%rbp)
jge    1200 <main+0xb0>
mov    -0xd8(%rbp),%esi
add    $0x1,%esi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xd8(%rbp),%rax
lea    -0xd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2c(%rip),%rdi
call   1060 <scanf@plt>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    11a7 <main+0x57>
mov    -0xd4(%rbp),%eax
mov    %eax,-0xdc(%rbp)
sub    $0x1,%eax
je     122e <main+0xde>
jmp    121a <main+0xca>
mov    -0xdc(%rbp),%eax
sub    $0x2,%eax
je     123f <main+0xef>
jmp    1250 <main+0x100>
lea    -0xd0(%rbp),%rdi
call   1050 <print@plt>
jmp    125e <main+0x10e>
lea    -0xd0(%rbp),%rdi
call   1070 <print_inverso@plt>
jmp    125e <main+0x10e>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0xd0(%rsp)
lea    0xe41(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe46(%rip),%r14
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%r12
mov    $0xffffffffffffffce,%rbx
lea    0xe1d(%rip),%r15
nopl   0x0(%rax)
lea    0x33(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
add    $0x4,%r12
inc    %rbx
jne    1200 <main+0xb0>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
je     123b <main+0xeb>
cmp    $0x2,%eax
jne    1247 <main+0xf7>
lea    0x10(%rsp),%rdi
call   1070 <print_inverso@plt>
jmp    1253 <main+0x103>
lea    0x10(%rsp),%rdi
call   1050 <print@plt>
jmp    1253 <main+0x103>
lea    0xdec(%rip),%rdi
call   1030 <puts@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Informe o codigo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"---Alimente o vetor---\0A\00"
@.str.3 = [13 x i8] c"Posicao %d: \00"
@.str.4 = [20 x i8] c"Operacao invalida!\0A\00"
define void @main() {
%1 = alloca [50 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [50 x i32]* %1 to i8*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %8
8: ; preds = %19, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 50
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
br label %19
19: ; preds = %11
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %8
22: ; preds = %8
%23 = load i32, i32* %2
switch i32 %23, label %30 [
i32 1, label %24
i32 2, label %27
]
24: ; preds = %22
%25 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
%26 = call i32 @print(i32* %25)
br label %32
27: ; preds = %22
%28 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
%29 = call i32 @print_inverso(i32* %28)
br label %32
30: ; preds = %22
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %27, %24
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Informe o codigo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [13 x i8] c"Posicao %d: \00"
@str = [23 x i8] c"---Alimente o vetor---\00"
@str.5 = [19 x i8] c"Operacao invalida!\00"
define void @main() {
%1 = alloca [50 x i32]
%2 = alloca i32
%3 = bitcast [50 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %10
8: ; preds = %10
%9 = load i32, i32* %2
switch i32 %9, label %24 [
i32 1, label %18
i32 2, label %21
]
10: ; preds = %0, %10
%11 = phi i64 [ 0, %0 ], [ %12, %10 ]
%12 = add nuw nsw i64 %11, 1
%13 = trunc i64 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %11
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = icmp eq i64 %12, 50
br i1 %17, label %8, label %10
18: ; preds = %8
%19 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
%20 = call i32 @print(i32* %19)
br label %26
21: ; preds = %8
%22 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
%23 = call i32 @print_inverso(i32* %22)
br label %26
24: ; preds = %8
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
br label %26
26: ; preds = %24, %21, %18
ret void
}