#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*/ calcula(int);
int /*<<< orphan*/ imprimir(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  int n, i;
  printf("Digite o tamanho do vetor: ");
  scanf("%d", &n);
  int v[n];
  for (i = 0; i < n; i++) {
    printf("Digite a posição %d: ", i + 1);
    scanf("%d", &v[i]);
  }
  int ordenado = 1;
  for (i = 1; i < n; i++) {
    if (v[i - 1] > v[i]) {
      ordenado = 0;
      break;
    }
  }
  if (ordenado) {
    printf("O vetor esta ordenado.");
  } else {
    printf("O vetor esta sem ordem definida.");
  }
  imprimir(v, n);
  int x = v[0];
  calcula(x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11eb <main+0xab>
mov    -0x18(%rbp),%esi
add    $0x1,%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe44(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a2 <main+0x62>
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1240 <main+0x100>
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cltq
mov    (%rcx,%rax,4),%eax
movslq -0x18(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    122d <main+0xed>
movl   $0x0,-0x2c(%rbp)
jmp    1240 <main+0x100>
jmp    1232 <main+0xf2>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11f9 <main+0xb9>
cmpl   $0x0,-0x2c(%rbp)
je     125d <main+0x11d>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    126b <main+0x12b>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <imprimir@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
call   1030 <calcula@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1060 <scanf@plt>
mov    %rsp,%rbx
mov    -0x2c(%rbp),%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    0xea6(%rip),%rdi
cmpl   $0x0,-0x2c(%rbp)
jle    123c <main+0xfc>
mov    %rbx,-0x38(%rbp)
lea    0xe79(%rip),%r12
lea    0xe6f(%rip),%r13
mov    %r15,%rbx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14
mov    %r12,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r14
jl     11c0 <main+0x80>
mov    %eax,%eax
cmp    $0x2,%eax
jl     122c <main+0xec>
mov    (%r15),%edx
mov    $0x1,%esi
lea    0xe4f(%rip),%rcx
mov    -0x38(%rbp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %edx,%edi
mov    (%r15,%rsi,4),%edx
cmp    %edx,%edi
jg     1239 <main+0xf9>
add    $0x1,%rsi
cmp    %rsi,%rax
jne    1210 <main+0xd0>
lea    0xe0d(%rip),%rdi
jmp    123c <main+0xfc>
mov    -0x38(%rbp),%rbx
lea    0xe00(%rip),%rdi
jmp    123c <main+0xfc>
mov    %rcx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
mov    %r15,%rdi
call   1050 <imprimir@plt>
mov    (%r15),%edi
call   1030 <calcula@plt>
mov    %rbx,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Digite o tamanho do vetor: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Digite a posi\C3\A7\C3\A3o %d: \00"
@.str.3 = [23 x i8] c"O vetor esta ordenado.\00"
@.str.4 = [33 x i8] c"O vetor esta sem ordem definida.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%14 = load i32, i32* %6
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %8
%17 = alloca i32, i64 %15
store i64 %15, i64* %9
store i32 0, i32* %7
br label %18
18: ; preds = %30, %2
%19 = load i32, i32* %7
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %17, i64 %27
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
br label %30
30: ; preds = %22
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %18
33: ; preds = %18
store i32 1, i32* %10
store i32 1, i32* %7
br label %34
34: ; preds = %51, %33
%35 = load i32, i32* %7
%36 = load i32, i32* %6
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %54
38: ; preds = %34
%39 = load i32, i32* %7
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %17, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %17, i64 %45
%47 = load i32, i32* %46
%48 = icmp sgt i32 %43, %47
br i1 %48, label %49, label %50
49: ; preds = %38
store i32 0, i32* %10
br label %54
50: ; preds = %38
br label %51
51: ; preds = %50
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %34
54: ; preds = %49, %34
%55 = load i32, i32* %10
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %61
59: ; preds = %54
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %61
61: ; preds = %59, %57
%62 = load i32, i32* %6
%63 = call i32 @imprimir(i32* %17, i32 %62)
%64 = getelementptr inbounds i32, i32* %17, i64 0
%65 = load i32, i32* %64
store i32 %65, i32* %11
%66 = load i32, i32* %11
%67 = call i32 @calcula(i32 %66)
store i32 0, i32* %3
%68 = load i8*, i8** %8
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@.str = [28 x i8] c"Digite o tamanho do vetor: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Digite a posi\C3\A7\C3\A3o %d: \00"
@.str.3 = [23 x i8] c"O vetor esta ordenado.\00"
@.str.4 = [33 x i8] c"O vetor esta sem ordem definida.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 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* %3)
%7 = load i32, i32* %3
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = alloca i32, i64 %8
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %18, label %37
13: ; preds = %18
%14 = icmp sgt i32 %25, 1
br i1 %14, label %15, label %37
15: ; preds = %13
%16 = zext i32 %25 to i64
%17 = load i32, i32* %10
br label %30
18: ; preds = %2, %18
%19 = phi i64 [ %20, %18 ], [ 0, %2 ]
%20 = add nuw nsw i64 %19, 1
%21 = trunc i64 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds i32, i32* %10, i64 %19
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %20, %26
br i1 %27, label %18, label %13
28: ; preds = %30
%29 = icmp eq i64 %36, %16
br i1 %29, label %37, label %30
30: ; preds = %15, %28
%31 = phi i32 [ %17, %15 ], [ %34, %28 ]
%32 = phi i64 [ 1, %15 ], [ %36, %28 ]
%33 = getelementptr inbounds i32, i32* %10, i64 %32
%34 = load i32, i32* %33
%35 = icmp sgt i32 %31, %34
%36 = add nuw nsw i64 %32, 1
br i1 %35, label %37, label %28
37: ; preds = %30, %28, %13, %2
%38 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), %2 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), %13 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), %28 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), %30 ]
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %38)
%40 = load i32, i32* %3
%41 = call i32 @imprimir(i32* %10, i32 %40)
%42 = load i32, i32* %10
%43 = call i32 @calcula(i32 %42)
ret i32 0
}