#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 */
scalar_t__ malloc(int);
scalar_t__ ordenado(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, *src, n;
  printf("Introduza o número de numeros: ");
  scanf("%d", &n);
  if (n > 100) {
    printf("So sao permitidas sequencias ate 100 numeros");
    n = 100;
  }
  src = (int *)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) {
    printf("Introduza o %d numero: ", i + 1);
    scanf("%d", &src[i]);
  }
  if (ordenado(src, n)) {
    printf("\nO vetor esta ordenado!\nElementos do vetor por ordem "
           "decrescente\n{");
    for (i = n - 1; i > 0; i--) {
      printf("%d,", src[i]);
    }
    printf("%d}\n", src[i]);
  } else {
    printf("\nO vetor não esta ordenado\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x64,-0x14(%rbp)
jle    118c <main+0x4c>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x64,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ef <main+0xaf>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe45(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a6 <main+0x66>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <ordenado@plt>
cmp    $0x0,%rax
je     126b <main+0x12b>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    124d <main+0x10d>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    121c <main+0xdc>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1279 <main+0x139>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%edi
cmp    $0x65,%edi
jl     119e <main+0x4e>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x64,0x4(%rsp)
mov    $0x64,%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11f9 <main+0xa9>
lea    0xe99(%rip),%r15
lea    0xe62(%rip),%r12
mov    %r14,%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
movslq 0x4(%rsp),%rsi
add    $0x4,%r13
cmp    %rsi,%rbx
jl     11d0 <main+0x80>
mov    %r14,%rdi
call   1030 <ordenado@plt>
test   %rax,%rax
je     1260 <main+0x110>
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ebp
cmp    $0x2,%eax
jl     1249 <main+0xf9>
mov    %ebp,%ebx
add    $0x1,%rbx
lea    0xe7f(%rip),%r15
xor    %ebp,%ebp
nop
mov    -0x4(%r14,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1230 <main+0xe0>
movslq %ebp,%rax
mov    (%r14,%rax,4),%esi
lea    0xe59(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    126c <main+0x11c>
lea    0xe4e(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Introduza o n\C3\BAmero de numeros: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [45 x i8] c"So sao permitidas sequencias ate 100 numeros\00"
@.str.3 = [24 x i8] c"Introduza o %d numero: \00"
@.str.4 = [67 x i8] c"\0AO vetor esta ordenado!\0AElementos do vetor por ordem decrescente\0A{\00"
@.str.5 = [4 x i8] c"%d,\00"
@.str.6 = [5 x i8] c"%d}\0A\00"
@.str.7 = [29 x i8] c"\0AO vetor n\C3\A3o esta ordenado\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 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* %4)
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 100
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
store i32 100, i32* %4
br label %11
11: ; preds = %9, %0
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = mul i64 4, %13
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %3
store i32 0, i32* %2
br label %18
18: ; preds = %31, %11
%19 = load i32, i32* %2
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %34
22: ; preds = %18
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32*, i32** %3
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %29)
br label %31
31: ; preds = %22
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %18
34: ; preds = %18
%35 = load i32*, i32** %3
%36 = load i32, i32* %4
%37 = call i64 @ordenado(i32* %35, i32 %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %63
39: ; preds = %34
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.4, i64 0, i64 0))
%41 = load i32, i32* %4
%42 = sub nsw i32 %41, 1
store i32 %42, i32* %2
br label %43
43: ; preds = %53, %39
%44 = load i32, i32* %2
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %56
46: ; preds = %43
%47 = load i32*, i32** %3
%48 = load i32, i32* %2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %47, i64 %49
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %46
%54 = load i32, i32* %2
%55 = add nsw i32 %54, -1
store i32 %55, i32* %2
br label %43
56: ; preds = %43
%57 = load i32*, i32** %3
%58 = load i32, i32* %2
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %57, i64 %59
%61 = load i32, i32* %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %61)
br label %65
63: ; preds = %34
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
br label %65
65: ; preds = %63, %56
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Introduza o n\C3\BAmero de numeros: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [45 x i8] c"So sao permitidas sequencias ate 100 numeros\00"
@.str.3 = [24 x i8] c"Introduza o %d numero: \00"
@.str.4 = [67 x i8] c"\0AO vetor esta ordenado!\0AElementos do vetor por ordem decrescente\0A{\00"
@.str.5 = [4 x i8] c"%d,\00"
@.str.6 = [5 x i8] c"%d}\0A\00"
@str = [28 x i8] c"\0AO vetor n\C3\A3o esta ordenado\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 100
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
store i32 100, i32* %1
br label %9
9: ; preds = %7, %0
%10 = phi i32 [ 100, %7 ], [ %5, %0 ]
%11 = shl i32 %10, 2
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %9, %16
%17 = phi i64 [ %18, %16 ], [ 0, %9 ]
%18 = add nuw nsw i64 %17, 1
%19 = trunc i64 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds i32, i32* %13, i64 %17
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %18, %24
br i1 %25, label %16, label %26
26: ; preds = %16, %9
%27 = phi i32 [ %14, %9 ], [ %23, %16 ]
%28 = call i64 @ordenado(i32* %13, i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %50, label %30
30: ; preds = %26
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32, i32* %1
%33 = add i32 %32, -1
%34 = icmp sgt i32 %32, 1
br i1 %34, label %35, label %44
35: ; preds = %30
%36 = zext i32 %33 to i64
br label %37
37: ; preds = %35, %37
%38 = phi i64 [ %36, %35 ], [ %42, %37 ]
%39 = getelementptr inbounds i32, i32* %13, i64 %38
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %40)
%42 = add nsw i64 %38, -1
%43 = icmp ugt i64 %38, 1
br i1 %43, label %37, label %44
44: ; preds = %37, %30
%45 = phi i32 [ %33, %30 ], [ 0, %37 ]
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %13, i64 %46
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %48)
br label %52
50: ; preds = %26
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %52
52: ; preds = %50, %44
ret i32 0
}