#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*/ PRIO_PROCESS;
scalar_t__ errno;
int getpriority(int /*<<< orphan*/, int /*<<< orphan*/);
int setpriority(int /*<<< orphan*/, int /*<<< orphan*/, int);
int nice(int incr) {
  int prior;
  errno = 0;
  prior = getpriority(PRIO_PROCESS, 0);
  if ((prior == -1) && (errno != 0)) {
    return -1;
  }
  return setpriority(PRIO_PROCESS, 0, prior + incr);
}


x86 assembly (clang, -O0):
<nice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2ea6(%rip),%rax
movq   $0x0,(%rax)
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1030 <getpriority@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1173 <nice+0x53>
mov    0x2e7b(%rip),%rax
cmpq   $0x0,(%rax)
je     1173 <nice+0x53>
movl   $0xffffffff,-0x4(%rbp)
jmp    118c <nice+0x6c>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
add    -0x8(%rbp),%edx
xor    %esi,%esi
call   1040 <setpriority@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nice>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
mov    0x2eab(%rip),%rbx
movq   $0x0,(%rbx)
mov    0x2ea5(%rip),%r14
mov    (%r14),%edi
xor    %esi,%esi
call   1030 <getpriority@plt>
cmp    $0xffffffff,%eax
jne    115a <nice+0x3a>
cmpq   $0x0,(%rbx)
je     115a <nice+0x3a>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    (%r14),%edi
add    %ebp,%eax
xor    %esi,%esi
mov    %eax,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <setpriority@plt>

LLVM IR (-O0):
@errno = global i64 0
@PRIO_PROCESS = global i32 0
define i32 @nice(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i64 0, i64* @errno
%5 = load i32, i32* @PRIO_PROCESS
%6 = call i32 @getpriority(i32 %5, i32 0)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i64, i64* @errno
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 -1, i32* %2
br label %19
13: ; preds = %9, %1
%14 = load i32, i32* @PRIO_PROCESS
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = add nsw i32 %15, %16
%18 = call i32 @setpriority(i32 %14, i32 0, i32 %17)
store i32 %18, i32* %2
br label %19
19: ; preds = %13, %12
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@errno = global i64 0
@PRIO_PROCESS = global i32 0
define i32 @nice(i32 %0) {
store i64 0, i64* @errno
%2 = load i32, i32* @PRIO_PROCESS
%3 = tail call i32 @getpriority(i32 %2, i32 0)
%4 = icmp eq i32 %3, -1
%5 = load i64, i64* @errno
%6 = icmp ne i64 %5, 0
%7 = select i1 %4, i1 %6, i1 false
br i1 %7, label %12, label %8
8: ; preds = %1
%9 = load i32, i32* @PRIO_PROCESS
%10 = add nsw i32 %3, %0
%11 = tail call i32 @setpriority(i32 %9, i32 0, i32 %10)
br label %12
12: ; preds = %1, %8
%13 = phi i32 [ %11, %8 ], [ -1, %1 ]
ret i32 %13
}