#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 _renice_error(char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *);
scalar_t__ setpriority(int, int, int);
int /*<<< orphan*/ stderr;
int strtol(char *, char **, int);
int _renice(int nice, int type, int argc, char *argv[]) {
  int i;
  int ret = 0;
  int id;
  char *p;
  for (i = 0; i < argc; i++) {
    id = strtol(argv[i], &p, 10);
    if (argv[i][0] == '\0' || *p != '\0') {
      fprintf(stderr, "%s%s%s",
              "renice"
              ": ",
              argv[i], "Invalid ID\n");
      ret |= 1;
      continue;
    }
    if (setpriority(type, id, nice) != 0)
      ret |= _renice_error(argv[i], 1);
  }
  return ret;
}


x86 assembly (clang, -O0):
<_renice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1238 <_renice+0xf8>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b4 <_renice+0x74>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f1 <_renice+0xb1>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe30(%rip),%rsi
lea    0xe30(%rip),%rdx
lea    0xe32(%rip),%r8
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    122a <_renice+0xea>
mov    -0x8(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1030 <setpriority@plt>
cmp    $0x0,%rax
je     1225 <_renice+0xe5>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x1,%esi
call   1060 <_renice_error@plt>
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    122a <_renice+0xea>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1163 <_renice+0x23>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_renice>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,0xc(%rsp)
mov    %edi,0x8(%rsp)
test   %edx,%edx
jle    11f5 <_renice+0xb5>
mov    %rcx,%rbx
mov    %edx,%r13d
xor    %r14d,%r14d
lea    0x10(%rsp),%r12
lea    0xe9d(%rip),%r15
xor    %ebp,%ebp
jmp    11ab <_renice+0x6b>
nopw   0x0(%rax,%rax,1)
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
lea    0xe70(%rip),%rdx
mov    %r15,%r8
call   1040 <fprintf@plt>
or     $0x1,%ebp
add    $0x1,%r14
cmp    %r14,%r13
je     11f7 <_renice+0xb7>
mov    (%rbx,%r14,8),%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    (%rbx,%r14,8),%rcx
cmpb   $0x0,(%rcx)
je     1180 <_renice+0x40>
mov    0x10(%rsp),%rdx
cmpb   $0x0,(%rdx)
jne    1180 <_renice+0x40>
mov    0xc(%rsp),%edi
mov    %eax,%esi
mov    0x8(%rsp),%edx
call   1030 <setpriority@plt>
test   %rax,%rax
je     11a2 <_renice+0x62>
mov    (%rbx,%r14,8),%rdi
mov    $0x1,%esi
call   1060 <_renice_error@plt>
or     %eax,%ebp
jmp    11a2 <_renice+0x62>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [7 x i8] c"%s%s%s\00"
@.str.1 = [9 x i8] c"renice: \00"
@.str.2 = [12 x i8] c"Invalid ID\0A\00"
define i32 @_renice(i32 %0, i32 %1, i32 %2, i8** %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
store i32 0, i32* %10
store i32 0, i32* %9
br label %13
13: ; preds = %64, %4
%14 = load i32, i32* %9
%15 = load i32, i32* %7
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %67
17: ; preds = %13
%18 = load i8**, i8*** %8
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @strtol(i8* %22, i8** %12, i32 10)
store i32 %23, i32* %11
%24 = load i8**, i8*** %8
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 0
br i1 %32, label %38, label %33
33: ; preds = %17
%34 = load i8*, i8** %12
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %48
38: ; preds = %33, %17
%39 = load i32, i32* @stderr
%40 = load i8**, i8*** %8
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %44, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%46 = load i32, i32* %10
%47 = or i32 %46, 1
store i32 %47, i32* %10
br label %64
48: ; preds = %33
%49 = load i32, i32* %6
%50 = load i32, i32* %11
%51 = load i32, i32* %5
%52 = call i64 @setpriority(i32 %49, i32 %50, i32 %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %63
54: ; preds = %48
%55 = load i8**, i8*** %8
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 @_renice_error(i8* %59, i32 1)
%61 = load i32, i32* %10
%62 = or i32 %61, %60
store i32 %62, i32* %10
br label %63
63: ; preds = %54, %48
br label %64
64: ; preds = %63, %38
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 1
store i32 %66, i32* %9
br label %13
67: ; preds = %13
%68 = load i32, i32* %10
ret i32 %68
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [7 x i8] c"%s%s%s\00"
@.str.1 = [9 x i8] c"renice: \00"
@.str.2 = [12 x i8] c"Invalid ID\0A\00"
define i32 @_renice(i32 %0, i32 %1, i32 %2, i8** nocapture %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %38
8: ; preds = %4
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %8, %34
%11 = phi i64 [ 0, %8 ], [ %36, %34 ]
%12 = phi i32 [ 0, %8 ], [ %35, %34 ]
%13 = getelementptr inbounds i8*, i8** %3, i64 %11
%14 = load i8*, i8** %13
%15 = call i32 @strtol(i8* %14, i8** %5, i32 10)
%16 = load i8*, i8** %13
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %10
%20 = load i8*, i8** %5
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19, %10
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%26 = or i32 %12, 1
br label %34
27: ; preds = %19
%28 = tail call i64 @setpriority(i32 %1, i32 %15, i32 %0)
%29 = icmp eq i64 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = load i8*, i8** %13
%32 = tail call i32 @_renice_error(i8* %31, i32 1)
%33 = or i32 %32, %12
br label %34
34: ; preds = %27, %30, %23
%35 = phi i32 [ %26, %23 ], [ %33, %30 ], [ %12, %27 ]
%36 = add nuw nsw i64 %11, 1
%37 = icmp eq i64 %36, %9
br i1 %37, label %38, label %10
38: ; preds = %34, %4
%39 = phi i32 [ 0, %4 ], [ %35, %34 ]
ret i32 %39
}