#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 {
  int /*<<< orphan*/ rlim_max;
  int /*<<< orphan*/ rlim_cur;
};

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_CORE;
int /*<<< orphan*/ RLIM_INFINITY;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setrlimit(int /*<<< orphan*/, struct rlimit *);
void enableCoreDump() {
  printf("We are making sure that we can write a core dump file...\n");
  printf("(You could do this yourself by running 'ulimit -c unlimited' at the "
         "command line and 'ulimit -c' to see the current allowed max core "
         "size file.)\n");
  struct rlimit core_limits;
  core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY;
  setrlimit(RLIMIT_CORE, &core_limits);
}


x86 assembly (clang, -O0):
<enableCoreDump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    %eax,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
call   1040 <setrlimit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enableCoreDump>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xf05(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e98(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    %eax,0x4(%rsp)
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1040 <setrlimit@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.rlimit = type { i32, i32 }
@.str = [58 x i8] c"We are making sure that we can write a core dump file...\0A\00"
@.str.1 = [146 x i8] c"(You could do this yourself by running 'ulimit -c unlimited' at the command line and 'ulimit -c' to see the current allowed max core size file.)\0A\00"
@RLIM_INFINITY = global i32 0
@RLIMIT_CORE = global i32 0
define void @enableCoreDump() {
%1 = alloca %struct.rlimit
%2 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0))
%4 = load i32, i32* @RLIM_INFINITY
%5 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 0
store i32 %4, i32* %5
%6 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 1
store i32 %4, i32* %6
%7 = load i32, i32* @RLIMIT_CORE
%8 = call i32 @setrlimit(i32 %7, %struct.rlimit* %1)
ret void
}

LLVM IR (-O2):
%struct.rlimit = type { i32, i32 }
@RLIM_INFINITY = global i32 0
@RLIMIT_CORE = global i32 0
@str = [57 x i8] c"We are making sure that we can write a core dump file...\00"
@str.2 = [145 x i8] c"(You could do this yourself by running 'ulimit -c unlimited' at the command line and 'ulimit -c' to see the current allowed max core size file.)\00"
define void @enableCoreDump() {
%1 = alloca %struct.rlimit
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([145 x i8], [145 x i8]* @str.2, i64 0, i64 0))
%4 = bitcast %struct.rlimit* %1 to i8*
%5 = load i32, i32* @RLIM_INFINITY
%6 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 0
store i32 %5, i32* %6
%7 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 1
store i32 %5, i32* %7
%8 = load i32, i32* @RLIMIT_CORE
%9 = call i32 @setrlimit(i32 %8, %struct.rlimit* %1)
ret void
}