#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 RandomInteger(int /*<<< orphan*/, int);
int maximoR(int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main(void) {
  int max;
  printf("Insira a quantidade maxima de elementos: ");
  scanf("%d", &max);
  int vetor[max];
  for (int i = 0; i < max; i++) {
    vetor[i] = RandomInteger(0, 99);
  };
  printf("Os elementos gerados foram: \n");
  for (int i = 0; i < max; i++) {
    printf(" %d ", vetor[i]);
  }
  printf("\n");
  printf("O maior elemento é \n");
  printf("%d\n", maximoR(max, vetor));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c7 <main+0x87>
xor    %edi,%edi
mov    $0x63,%esi
call   1060 <RandomInteger@plt>
mov    %eax,%edx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1194 <main+0x54>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    120f <main+0xcf>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11dc <main+0x9c>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    -0x4(%rbp),%edi
call   1030 <maximoR@plt>
mov    %eax,%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea6(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1070 <scanf@plt>
mov    %rsp,%r15
mov    -0x24(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmpl   $0x0,-0x24(%rbp)
jle    11cd <main+0x6d>
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0x63,%esi
call   1080 <RandomInteger@plt>
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
movslq -0x24(%rbp),%rax
cmp    %rax,%rbx
jl     11b0 <main+0x50>
lea    0xe62(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,-0x24(%rbp)
jle    120b <main+0xab>
lea    0xe47(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
movslq -0x24(%rbp),%rax
cmp    %rax,%rbx
jl     11f0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe37(%rip),%rdi
call   1040 <puts@plt>
mov    -0x24(%rbp),%edi
mov    %r12,%rsi
call   1050 <maximoR@plt>
lea    0xdff(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rsp
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Insira a quantidade maxima de elementos: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Os elementos gerados foram: \0A\00"
@.str.3 = [5 x i8] c" %d \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [22 x i8] c"O maior elemento \C3\A9 \0A\00"
@.str.6 = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %2
%11 = alloca i32, i64 %9
store i64 %9, i64* %3
store i32 0, i32* %4
br label %12
12: ; preds = %21, %0
%13 = load i32, i32* %4
%14 = load i32, i32* %1
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = call i32 @RandomInteger(i32 0, i32 99)
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %11, i64 %19
store i32 %17, i32* %20
br label %21
21: ; preds = %16
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %12
24: ; preds = %12
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %26
26: ; preds = %36, %24
%27 = load i32, i32* %5
%28 = load i32, i32* %1
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %39
30: ; preds = %26
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %11, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %30
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %26
39: ; preds = %26
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%42 = load i32, i32* %1
%43 = call i32 @maximoR(i32 %42, i32* %11)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %43)
%45 = load i8*, i8** %2
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"Insira a quantidade maxima de elementos: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c" %d \00"
@.str.6 = [4 x i8] c"%d\0A\00"
@str = [29 x i8] c"Os elementos gerados foram: \00"
@str.7 = [21 x i8] c"O maior elemento \C3\A9 \00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 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 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i32, i64 %6
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %15, %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %29, label %23
15: ; preds = %0, %15
%16 = phi i64 [ %19, %15 ], [ 0, %0 ]
%17 = call i32 @RandomInteger(i32 0, i32 99)
%18 = getelementptr inbounds i32, i32* %8, i64 %16
store i32 %17, i32* %18
%19 = add nuw nsw i64 %16, 1
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %15, label %11
23: ; preds = %29, %11
%24 = call i32 @putchar(i32 10)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
%26 = load i32, i32* %1
%27 = call i32 @maximoR(i32 %26, i32* %8)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %27)
ret void
29: ; preds = %11, %29
%30 = phi i64 [ %34, %29 ], [ 0, %11 ]
%31 = getelementptr inbounds i32, i32* %8, i64 %30
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = add nuw nsw i64 %30, 1
%35 = load i32, i32* %1
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %34, %36
br i1 %37, label %29, label %23
}