#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 */
scalar_t__ ENOENT;
int /*<<< orphan*/ PRIO_PROCESS;
int atoi(char *);
int /*<<< orphan*/ err(int, char *, ...);
scalar_t__ errno;
int /*<<< orphan*/ execvp(char *, char **);
int getopt(int, char **, char *);
scalar_t__ getpriority(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ isdigit(unsigned char);
char *optarg;
scalar_t__ optind;
int setpriority(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ warn(char *);
int main(int argc, char *argv[]) {
  int niceness = 10;
  int c;
  if (argc > 1 && argv[1][0] == '-' && isdigit((unsigned char)argv[1][1])) {
    niceness = atoi(argv[1] + 1);
    argc--;
    argv++;
  }
  while ((c = getopt(argc, argv, "n:")) != -1) {
    switch (c) {
    case 'n':
      niceness = atoi(optarg);
      break;
    case '?':
    default:
      usage();
      break;
    }
  }
  argc -= optind;
  argv += optind;
  if (argc == 0)
    usage();
  errno = 0;
  niceness += getpriority(PRIO_PROCESS, 0);
  if (errno) {
    err(1, "getpriority");
  }
  if (setpriority(PRIO_PROCESS, 0, niceness) == -1) {
    warn("setpriority");
  }
  execvp(argv[0], &argv[1]);
  err((errno == ENOENT) ? 127 : 126, "%s", argv[0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xa,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    120f <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    120f <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movzbl 0x1(%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     120f <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
add    $0x1,%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1214 <main+0x84>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdde(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     1280 <main+0xf0>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x3f,%eax
je     126f <main+0xdf>
jmp    1247 <main+0xb7>
mov    -0x1c(%rbp),%eax
sub    $0x6e,%eax
jne    1274 <main+0xe4>
jmp    1258 <main+0xc8>
mov    0x2d99(%rip),%rax
mov    (%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    127b <main+0xeb>
jmp    1274 <main+0xe4>
mov    $0x0,%al
call   1080 <usage@plt>
jmp    1214 <main+0x84>
mov    0x2d59(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d45(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    12bb <main+0x12b>
mov    $0x0,%al
call   1080 <usage@plt>
mov    0x2d06(%rip),%rax
movq   $0x0,(%rax)
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1030 <getpriority@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    0x2cdb(%rip),%rax
cmpq   $0x0,(%rax)
je     130a <main+0x17a>
mov    $0x1,%edi
lea    0xd00(%rip),%rsi
mov    $0x0,%al
call   1070 <err@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1060 <setpriority@plt>
cmp    $0xffffffff,%eax
jne    1332 <main+0x1a2>
lea    0xce2(%rip),%rdi
call   1050 <warn@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   10a0 <execvp@plt>
mov    0x2c7b(%rip),%rax
mov    (%rax),%rcx
mov    0x2c61(%rip),%rax
mov    (%rax),%rdx
mov    $0x7e,%edi
mov    $0x7f,%eax
cmp    %rdx,%rcx
cmove  %eax,%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xca3(%rip),%rsi
mov    $0x0,%al
call   1070 <err@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %edi,%ebp
mov    $0xa,%r14d
cmp    $0x2,%edi
jl     11d5 <main+0x45>
mov    0x8(%r15),%rax
cmpb   $0x2d,(%rax)
jne    11d5 <main+0x45>
movzbl 0x1(%rax),%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     11d5 <main+0x45>
add    $0x8,%r15
mov    (%r15),%rdi
add    $0x1,%rdi
call   10b0 <atoi@plt>
mov    %eax,%r14d
add    $0xffffffff,%ebp
lea    0xe24(%rip),%rbx
mov    0x2e15(%rip),%r12
jmp    11f7 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1080 <usage@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1090 <getopt@plt>
cmp    $0xffffffff,%eax
je     121c <main+0x8c>
cmp    $0x6e,%eax
jne    11f0 <main+0x60>
mov    (%r12),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r14d
jmp    11f7 <main+0x67>
mov    0x2dbd(%rip),%rax
mov    (%rax),%rbx
cmp    %ebx,%ebp
jne    1231 <main+0xa1>
xor    %eax,%eax
call   1080 <usage@plt>
mov    0x2d90(%rip),%r12
movq   $0x0,(%r12)
mov    0x2d89(%rip),%rbp
mov    0x0(%rbp),%edi
xor    %esi,%esi
call   1030 <getpriority@plt>
add    %eax,%r14d
cmpq   $0x0,(%r12)
je     126e <main+0xde>
lea    0xda1(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1070 <err@plt>
lea    (%r15,%rbx,8),%rbx
mov    0x0(%rbp),%edi
xor    %esi,%esi
mov    %r14d,%edx
call   1060 <setpriority@plt>
cmp    $0xffffffff,%eax
jne    1290 <main+0x100>
lea    0xd84(%rip),%rdi
call   1050 <warn@plt>
mov    (%rbx),%rdi
lea    0x8(%rbx),%rsi
call   10a0 <execvp@plt>
mov    (%r12),%rax
mov    0x2d11(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
or     $0x7e,%edi
mov    (%rbx),%rdx
lea    0xd5e(%rip),%rsi
xor    %eax,%eax
call   1070 <err@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"n:\00"
@optarg = global i8* null
@optind = global i64 0
@errno = global i64 0
@PRIO_PROCESS = global i32 0
@.str.1 = [12 x i8] c"getpriority\00"
@.str.2 = [12 x i8] c"setpriority\00"
@ENOENT = global i64 0
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 10, i32* %6
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %36
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 45
br i1 %17, label %18, label %36
18: ; preds = %10
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = call i64 @isdigit(i8 zeroext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %36
26: ; preds = %18
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %6
%32 = load i32, i32* %4
%33 = add nsw i32 %32, -1
store i32 %33, i32* %4
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i32 1
store i8** %35, i8*** %5
br label %36
36: ; preds = %26, %18, %10, %2
br label %37
37: ; preds = %50, %36
%38 = load i32, i32* %4
%39 = load i8**, i8*** %5
%40 = call i32 @getopt(i32 %38, i8** %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %40, i32* %7
%41 = icmp ne i32 %40, -1
br i1 %41, label %42, label %51
42: ; preds = %37
%43 = load i32, i32* %7
switch i32 %43, label %48 [
i32 110, label %44
i32 63, label %47
]
44: ; preds = %42
%45 = load i8*, i8** @optarg
%46 = call i32 @atoi(i8* %45)
store i32 %46, i32* %6
br label %50
47: ; preds = %42
br label %48
48: ; preds = %42, %47
%49 = call i32 (...) @usage()
br label %50
50: ; preds = %48, %44
br label %37
51: ; preds = %37
%52 = load i64, i64* @optind
%53 = load i32, i32* %4
%54 = sext i32 %53 to i64
%55 = sub nsw i64 %54, %52
%56 = trunc i64 %55 to i32
store i32 %56, i32* %4
%57 = load i64, i64* @optind
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 %57
store i8** %59, i8*** %5
%60 = load i32, i32* %4
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %51
%63 = call i32 (...) @usage()
br label %64
64: ; preds = %62, %51
store i64 0, i64* @errno
%65 = load i32, i32* @PRIO_PROCESS
%66 = call i64 @getpriority(i32 %65, i32 0)
%67 = load i32, i32* %6
%68 = sext i32 %67 to i64
%69 = add nsw i64 %68, %66
%70 = trunc i64 %69 to i32
store i32 %70, i32* %6
%71 = load i64, i64* @errno
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %64
%74 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %75
75: ; preds = %73, %64
%76 = load i32, i32* @PRIO_PROCESS
%77 = load i32, i32* %6
%78 = call i32 @setpriority(i32 %76, i32 0, i32 %77)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %82
80: ; preds = %75
%81 = call i32 @warn(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %82
82: ; preds = %80, %75
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 0
%85 = load i8*, i8** %84
%86 = load i8**, i8*** %5
%87 = getelementptr inbounds i8*, i8** %86, i64 1
%88 = call i32 @execvp(i8* %85, i8** %87)
%89 = load i64, i64* @errno
%90 = load i64, i64* @ENOENT
%91 = icmp eq i64 %89, %90
%92 = zext i1 %91 to i64
%93 = select i1 %91, i32 127, i32 126
%94 = load i8**, i8*** %5
%95 = getelementptr inbounds i8*, i8** %94, i64 0
%96 = load i8*, i8** %95
%97 = call i32 (i32, i8*, ...) @err(i32 %93, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %96)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"n:\00"
@optarg = global i8* null
@optind = global i64 0
@errno = global i64 0
@PRIO_PROCESS = global i32 0
@.str.1 = [12 x i8] c"getpriority\00"
@.str.2 = [12 x i8] c"setpriority\00"
@ENOENT = global i64 0
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %19
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 45
br i1 %8, label %9, label %19
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
%12 = tail call i64 @isdigit(i8 zeroext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = tail call i32 @atoi(i8* %16)
%18 = add nsw i32 %0, -1
br label %19
19: ; preds = %14, %9, %4, %2
%20 = phi i8** [ %5, %14 ], [ %1, %9 ], [ %1, %4 ], [ %1, %2 ]
%21 = phi i32 [ %17, %14 ], [ 10, %9 ], [ 10, %4 ], [ 10, %2 ]
%22 = phi i32 [ %18, %14 ], [ %0, %9 ], [ %0, %4 ], [ %0, %2 ]
br label %23
23: ; preds = %27, %19
%24 = phi i32 [ %29, %27 ], [ %21, %19 ]
br label %25
25: ; preds = %23, %30
%26 = tail call i32 @getopt(i32 %22, i8** %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %26, label %30 [
i32 -1, label %32
i32 110, label %27
]
27: ; preds = %25
%28 = load i8*, i8** @optarg
%29 = tail call i32 @atoi(i8* %28)
br label %23
30: ; preds = %25
%31 = tail call i32 (...) @usage()
br label %25
32: ; preds = %25
%33 = load i64, i64* @optind
%34 = trunc i64 %33 to i32
%35 = getelementptr inbounds i8*, i8** %20, i64 %33
%36 = icmp eq i32 %22, %34
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = tail call i32 (...) @usage()
br label %39
39: ; preds = %37, %32
store i64 0, i64* @errno
%40 = load i32, i32* @PRIO_PROCESS
%41 = tail call i64 @getpriority(i32 %40, i32 0)
%42 = trunc i64 %41 to i32
%43 = add i32 %24, %42
%44 = load i64, i64* @errno
%45 = icmp eq i64 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %39
%47 = tail call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %46, %39
%49 = load i32, i32* @PRIO_PROCESS
%50 = tail call i32 @setpriority(i32 %49, i32 0, i32 %43)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = tail call i32 @warn(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %54
54: ; preds = %52, %48
%55 = load i8*, i8** %35
%56 = getelementptr inbounds i8*, i8** %35, i64 1
%57 = tail call i32 @execvp(i8* %55, i8** %56)
%58 = load i64, i64* @errno
%59 = load i64, i64* @ENOENT
%60 = icmp eq i64 %58, %59
%61 = select i1 %60, i32 127, i32 126
%62 = load i8*, i8** %35
%63 = tail call i32 (i32, i8*, ...) @err(i32 %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %62)
ret i32 0
}