#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 */
struct rlimit {
  scalar_t__ rlim_max;
  scalar_t__ rlim_cur;
};

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_STACK;
int /*<<< orphan*/ funcao_recursiva();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ getrlimit(int /*<<< orphan*/, struct rlimit *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  struct rlimit rlim;
  getrlimit(RLIMIT_STACK, &rlim);
  printf("\nSoft limite da pilha (bytes): %d  (%d KB)\n",
         (unsigned int)rlim.rlim_cur, (unsigned int)rlim.rlim_cur / 1024);
  printf("Hard limite da pilha (bytes): %ld\n",
         (unsigned long int)rlim.rlim_max);
  printf("Pressione ENTER para continuar...\n");
  getchar();
  funcao_recursiva();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1060 <getrlimit@plt>
mov    -0x8(%rbp),%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rax
mov    %eax,%edx
shr    $0xa,%edx
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    $0x0,%al
call   1030 <funcao_recursiva@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1070 <getrlimit@plt>
mov    0x10(%rsp),%esi
mov    %esi,%edx
shr    $0xa,%edx
lea    0xe89(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
call   1040 <funcao_recursiva@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.rlimit = type { i64, i64 }
@RLIMIT_STACK = global i32 0
@.str = [44 x i8] c"\0ASoft limite da pilha (bytes): %d (%d KB)\0A\00"
@.str.1 = [35 x i8] c"Hard limite da pilha (bytes): %ld\0A\00"
@.str.2 = [35 x i8] c"Pressione ENTER para continuar...\0A\00"
define i32 @main() {
%1 = alloca %struct.rlimit
%2 = load i32, i32* @RLIMIT_STACK
%3 = call i32 @getrlimit(i32 %2, %struct.rlimit* %1)
%4 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 1
%5 = load i64, i64* %4
%6 = trunc i64 %5 to i32
%7 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 1
%8 = load i64, i64* %7
%9 = trunc i64 %8 to i32
%10 = udiv i32 %9, 1024
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %10)
%12 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 0
%13 = load i64, i64* %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i64 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (...) @getchar()
%17 = call i32 (...) @funcao_recursiva()
ret i32 0
}

LLVM IR (-O2):
%struct.rlimit = type { i64, i64 }
@RLIMIT_STACK = global i32 0
@.str = [44 x i8] c"\0ASoft limite da pilha (bytes): %d (%d KB)\0A\00"
@.str.1 = [35 x i8] c"Hard limite da pilha (bytes): %ld\0A\00"
@str = [34 x i8] c"Pressione ENTER para continuar...\00"
define i32 @main() {
%1 = alloca %struct.rlimit
%2 = bitcast %struct.rlimit* %1 to i8*
%3 = load i32, i32* @RLIMIT_STACK
%4 = call i32 @getrlimit(i32 %3, %struct.rlimit* %1)
%5 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 1
%6 = load i64, i64* %5
%7 = trunc i64 %6 to i32
%8 = lshr i32 %7, 10
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 0
%11 = load i64, i64* %10
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i64 %11)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%14 = call i32 (...) @getchar()
%15 = call i32 (...) @funcao_recursiva()
ret i32 0
}