#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*/ PR_SET_DUMPABLE;
int /*<<< orphan*/ core_rlimit_get(struct rlimit *);
scalar_t__ core_rlimit_set(struct rlimit *);
int errno;
scalar_t__ prctl(int /*<<< orphan*/, int);
int core_enable(void) {
  struct rlimit lim;
  core_rlimit_get(&lim);
  lim.rlim_cur = lim.rlim_max;
  return (core_rlimit_set(&lim) || prctl(PR_SET_DUMPABLE, 1)) ? errno : 0;
}


x86 assembly (clang, -O0):
<core_enable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
call   1030 <core_rlimit_get@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <core_rlimit_set@plt>
cmp    $0x0,%rax
jne    1177 <core_enable+0x47>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1040 <prctl@plt>
cmp    $0x0,%rax
je     1188 <core_enable+0x58>
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <core_enable+0x62>
xor    %eax,%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <core_enable+0x62>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<core_enable>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <core_rlimit_get@plt>
mov    0x8(%rsp),%eax
mov    %eax,0xc(%rsp)
mov    %rbx,%rdi
call   1050 <core_rlimit_set@plt>
test   %rax,%rax
jne    116f <core_enable+0x3f>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1040 <prctl@plt>
test   %rax,%rax
je     117e <core_enable+0x4e>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret
xor    %eax,%eax
jmp    1178 <core_enable+0x48>

LLVM IR (-O0):
%struct.rlimit = type { i32, i32 }
@PR_SET_DUMPABLE = global i32 0
@errno = global i32 0
define i32 @core_enable() {
%1 = alloca %struct.rlimit
%2 = call i32 @core_rlimit_get(%struct.rlimit* %1)
%3 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 0
%4 = load i32, i32* %3
%5 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 1
store i32 %4, i32* %5
%6 = call i64 @core_rlimit_set(%struct.rlimit* %1)
%7 = icmp ne i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = load i32, i32* @PR_SET_DUMPABLE
%10 = call i64 @prctl(i32 %9, i32 1)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8, %0
%13 = load i32, i32* @errno
br label %15
14: ; preds = %8
br label %15
15: ; preds = %14, %12
%16 = phi i32 [ %13, %12 ], [ 0, %14 ]
ret i32 %16
}

LLVM IR (-O2):
%struct.rlimit = type { i32, i32 }
@PR_SET_DUMPABLE = global i32 0
@errno = global i32 0
define i32 @core_enable() {
%1 = alloca %struct.rlimit
%2 = bitcast %struct.rlimit* %1 to i8*
%3 = call i32 @core_rlimit_get(%struct.rlimit* %1)
%4 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 1
store i32 %5, i32* %6
%7 = call i64 @core_rlimit_set(%struct.rlimit* %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = load i32, i32* @PR_SET_DUMPABLE
%11 = call i64 @prctl(i32 %10, i32 1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9, %0
%14 = load i32, i32* @errno
br label %15
15: ; preds = %9, %13
%16 = phi i32 [ %14, %13 ], [ 0, %9 ]
ret i32 %16
}