#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 *, int, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ socarrega(int *, int);
int carregarray(int *v, int *elementos) {
  scanf("%d\n", elementos);
  if (0)
    printf("Total de elementos a serem lidos: %d\n", *elementos);
  if (*elementos > 5000) {
    printf("Total de elementos a serem lidos é maior que o #define, ajustar! "
           "\n Elementos: %d\n MAX: %d",
           *elementos, 5000);
    return 1;
  }
  socarrega(v, *elementos);
  return 0;
}


x86 assembly (clang, -O0):
<carregarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xeb5(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x1388,(%rax)
jle    1185 <carregarray+0x55>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe97(%rip),%rdi
mov    $0x1388,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    119b <carregarray+0x6b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1030 <socarrega@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<carregarray>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xebf(%rip),%rdi
call   1050 <scanf@plt>
mov    (%rbx),%esi
cmp    $0x1389,%esi
jl     116a <carregarray+0x3a>
lea    0xead(%rip),%rdi
mov    $0x1388,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
jmp    1174 <carregarray+0x44>
mov    %r14,%rdi
call   1030 <socarrega@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [91 x i8] c"Total de elementos a serem lidos \C3\A9 maior que o #define, ajustar! \0A Elementos: %d\0A MAX: %d\00"
define i32 @carregarray(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
store i32* %0, i32** %4
store i32* %1, i32** %5
%6 = load i32*, i32** %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %6)
%8 = load i32*, i32** %5
%9 = load i32, i32* %8
%10 = icmp sgt i32 %9, 5000
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32*, i32** %5
%13 = load i32, i32* %12
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 5000)
store i32 1, i32* %3
br label %20
15: ; preds = %2
%16 = load i32*, i32** %4
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = call i32 @socarrega(i32* %16, i32 %18)
store i32 0, i32* %3
br label %20
20: ; preds = %15, %11
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [91 x i8] c"Total de elementos a serem lidos \C3\A9 maior que o #define, ajustar! \0A Elementos: %d\0A MAX: %d\00"
define i32 @carregarray(i32* %0, i32* %1) {
%3 = tail call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp sgt i32 %4, 5000
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 5000)
br label %10
8: ; preds = %2
%9 = tail call i32 @socarrega(i32* %0, i32 %4)
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ 1, %6 ], [ 0, %8 ]
ret i32 %11
}