#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 {
  void *rlim_max;
  void *rlim_cur;
};

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_CORE;
void *RLIM_INFINITY;
int /*<<< orphan*/ qfprintf(char *, char *);
int /*<<< orphan*/ setrlimit(int /*<<< orphan*/, struct rlimit *);
void enable_coredumps(void) {
  struct rlimit unlim;
  unlim.rlim_cur = RLIM_INFINITY;
  unlim.rlim_max = RLIM_INFINITY;
  qfprintf("/proc/sys/kernel/core_pattern", "/var/core-%%e");
  setrlimit(RLIMIT_CORE, &unlim);
}


x86 assembly (clang, -O0):
<enable_coredumps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
lea    0xeb5(%rip),%rdi
lea    0xecc(%rip),%rsi
call   1030 <qfprintf@plt>
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1040 <setrlimit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enable_coredumps>:
sub    $0x18,%rsp
mov    0x2ead(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
mov    %rax,0x8(%rsp)
lea    0xec1(%rip),%rdi
lea    0xed8(%rip),%rsi
call   1030 <qfprintf@plt>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1040 <setrlimit@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.rlimit = type { i8*, i8* }
@RLIM_INFINITY = global i8* null
@.str = [30 x i8] c"/proc/sys/kernel/core_pattern\00"
@.str.1 = [14 x i8] c"/var/core-%%e\00"
@RLIMIT_CORE = global i32 0
define void @enable_coredumps() {
%1 = alloca %struct.rlimit
%2 = load i8*, i8** @RLIM_INFINITY
%3 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 1
store i8* %2, i8** %3
%4 = load i8*, i8** @RLIM_INFINITY
%5 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 0
store i8* %4, i8** %5
%6 = call i32 @qfprintf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @RLIMIT_CORE
%8 = call i32 @setrlimit(i32 %7, %struct.rlimit* %1)
ret void
}

LLVM IR (-O2):
%struct.rlimit = type { i8*, i8* }
@RLIM_INFINITY = global i8* null
@.str = [30 x i8] c"/proc/sys/kernel/core_pattern\00"
@.str.1 = [14 x i8] c"/var/core-%%e\00"
@RLIMIT_CORE = global i32 0
define void @enable_coredumps() {
%1 = alloca %struct.rlimit
%2 = bitcast %struct.rlimit* %1 to i8*
%3 = load i8*, i8** @RLIM_INFINITY
%4 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 1
store i8* %3, i8** %4
%5 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 0
store i8* %3, i8** %5
%6 = tail call i32 @qfprintf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @RLIMIT_CORE
%8 = call i32 @setrlimit(i32 %7, %struct.rlimit* %1)
ret void
}