#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;
int _nice_error(char *, int);
int /*<<< orphan*/ execvp(char *, char **);
scalar_t__ setpriority(int /*<<< orphan*/, int /*<<< orphan*/, int);
int _nice(int nice, char *argv[]) {
  if (setpriority(PRIO_PROCESS, 0, nice) != 0)
    return _nice_error("Unable to set priority", 1);
  execvp(argv[0], argv);
  return _nice_error(argv[0], 1);
}


x86 assembly (clang, -O0):
<_nice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
xor    %esi,%esi
call   1030 <setpriority@plt>
cmp    $0x0,%rax
je     1175 <_nice+0x45>
lea    0xe9d(%rip),%rdi
mov    $0x1,%esi
call   1040 <_nice_error@plt>
mov    %eax,-0x4(%rbp)
jmp    1199 <_nice+0x69>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <execvp@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x1,%esi
call   1040 <_nice_error@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_nice>:
push   %rbx
mov    %rsi,%rbx
mov    %edi,%edx
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1030 <setpriority@plt>
test   %rax,%rax
je     1154 <_nice+0x24>
lea    0xeae(%rip),%rdi
jmp    1162 <_nice+0x32>
mov    (%rbx),%rdi
mov    %rbx,%rsi
call   1050 <execvp@plt>
mov    (%rbx),%rdi
mov    $0x1,%esi
pop    %rbx
jmp    1040 <_nice_error@plt>

LLVM IR (-O0):
@PRIO_PROCESS = global i32 0
@.str = [23 x i8] c"Unable to set priority\00"
define i32 @_nice(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @PRIO_PROCESS
%7 = load i32, i32* %4
%8 = call i64 @setpriority(i32 %6, i32 0, i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @_nice_error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 1)
store i32 %11, i32* %3
br label %22
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = load i8**, i8*** %5
%17 = call i32 @execvp(i8* %15, i8** %16)
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @_nice_error(i8* %20, i32 1)
store i32 %21, i32* %3
br label %22
22: ; preds = %12, %10
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@PRIO_PROCESS = global i32 0
@.str = [23 x i8] c"Unable to set priority\00"
define i32 @_nice(i32 %0, i8** %1) {
%3 = load i32, i32* @PRIO_PROCESS
%4 = tail call i64 @setpriority(i32 %3, i32 0, i32 %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @execvp(i8* %7, i8** %1)
%9 = load i8*, i8** %1
br label %10
10: ; preds = %2, %6
%11 = phi i8* [ %9, %6 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), %2 ]
%12 = tail call i32 @_nice_error(i8* %11, i32 1)
ret i32 %12
}