#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*/ RLIMIT_DATA;
int /*<<< orphan*/ log_message(char *, ...);
scalar_t__ set_limit(int /*<<< orphan*/, int);
int set_data_size(int n) {
  if (set_limit(RLIMIT_DATA, n)) {
    log_message("set_data_size: unable to set resource limit");
    return -1;
  }
  log_message("set_data_size: max data segment size set to %d", n);
  return 0;
}


x86 assembly (clang, -O0):
<set_data_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2eb6(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
call   1040 <set_limit@plt>
cmp    $0x0,%rax
je     1160 <set_data_size+0x40>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <log_message@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1178 <set_data_size+0x58>
mov    -0x8(%rbp),%esi
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <log_message@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_data_size>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2ebc(%rip),%rax
mov    (%rax),%edi
mov    %ebx,%esi
call   1040 <set_limit@plt>
test   %rax,%rax
je     114f <set_data_size+0x2f>
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1030 <log_message@plt>
mov    $0xffffffff,%ebp
jmp    1161 <set_data_size+0x41>
lea    0xed6(%rip),%rdi
xor    %ebp,%ebp
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <log_message@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@RLIMIT_DATA = global i32 0
@.str = [44 x i8] c"set_data_size: unable to set resource limit\00"
@.str.1 = [47 x i8] c"set_data_size: max data segment size set to %d\00"
define i32 @set_data_size(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* @RLIMIT_DATA
%5 = load i32, i32* %3
%6 = call i64 @set_limit(i32 %4, i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 (i8*, ...) @log_message(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %13
10: ; preds = %1
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @log_message(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %11)
store i32 0, i32* %2
br label %13
13: ; preds = %10, %8
%14 = load i32, i32* %2
ret i32 %14
}

LLVM IR (-O2):
@RLIMIT_DATA = global i32 0
@.str = [44 x i8] c"set_data_size: unable to set resource limit\00"
@.str.1 = [47 x i8] c"set_data_size: max data segment size set to %d\00"
define i32 @set_data_size(i32 %0) {
%2 = load i32, i32* @RLIMIT_DATA
%3 = tail call i64 @set_limit(i32 %2, i32 %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 (i8*, ...) @log_message(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %9
7: ; preds = %1
%8 = tail call i32 (i8*, ...) @log_message(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ -1, %5 ], [ 0, %7 ]
ret i32 %10
}