#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 rlim_cur;
  int rlim_max;
};

/* Variables and functions */
scalar_t__ setrlimit(int, struct rlimit *);
int /*<<< orphan*/ writeResult(int, char *, int /*<<< orphan*/,
                               int /*<<< orphan*/, char *);
void setLimitDiff(int resource, int softLimit, int hardLimit) {
  struct rlimit lim;
  lim.rlim_cur = softLimit;
  lim.rlim_max = hardLimit;
  if (setrlimit(resource, &lim) != 0) {
    writeResult(-1, "Set limit Diff Error", 0, 0, "null");
  }
}


x86 assembly (clang, -O0):
<setLimitDiff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1040 <setrlimit@plt>
cmp    $0x0,%rax
je     116f <setLimitDiff+0x4f>
mov    $0xffffffff,%edi
lea    0xea1(%rip),%rsi
xor    %ecx,%ecx
lea    0xead(%rip),%r8
mov    %ecx,%edx
call   1030 <writeResult@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setLimitDiff>:
push   %rax
mov    %esi,(%rsp)
mov    %edx,0x4(%rsp)
mov    %rsp,%rsi
call   1040 <setrlimit@plt>
test   %rax,%rax
je     1151 <setLimitDiff+0x31>
lea    0xec4(%rip),%rsi
lea    0xed2(%rip),%r8
mov    $0xffffffff,%edi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <writeResult@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.rlimit = type { i32, i32 }
@.str = [21 x i8] c"Set limit Diff Error\00"
@.str.1 = [5 x i8] c"null\00"
define void @setLimitDiff(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.rlimit
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %7, i32 0, i32 0
store i32 %8, i32* %9
%10 = load i32, i32* %6
%11 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %7, i32 0, i32 1
store i32 %10, i32* %11
%12 = load i32, i32* %4
%13 = call i64 @setrlimit(i32 %12, %struct.rlimit* %7)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @writeResult(i32 -1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %3
ret void
}

LLVM IR (-O2):
%struct.rlimit = type { i32, i32 }
@.str = [21 x i8] c"Set limit Diff Error\00"
@.str.1 = [5 x i8] c"null\00"
define void @setLimitDiff(i32 %0, i32 %1, i32 %2) {
%4 = alloca %struct.rlimit
%5 = bitcast %struct.rlimit* %4 to i8*
%6 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %4, i64 0, i32 0
store i32 %1, i32* %6
%7 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %4, i64 0, i32 1
store i32 %2, i32* %7
%8 = call i64 @setrlimit(i32 %0, %struct.rlimit* %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = call i32 @writeResult(i32 -1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %3
ret void
}