#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 */
typedef int /*<<< orphan*/ regmatch_t;
typedef int /*<<< orphan*/ regex_t;
typedef int /*<<< orphan*/ cpuset;
typedef int /*<<< orphan*/ cpu_set_t;

/* Variables and functions */
int /*<<< orphan*/ CPU_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ CPU_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ PRIO_PROCESS;
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
scalar_t__ regcomp(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/);
scalar_t__ regexec(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ *,
                   int /*<<< orphan*/);
scalar_t__ sched_setaffinity(int /*<<< orphan*/, int, int /*<<< orphan*/ *);
scalar_t__ setpriority(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  regex_t reg;
  const char *regex = "cpu[0-9].*";
  char **aargv = NULL;
  regmatch_t m[1];
  cpu_set_t cpuset;
  int i;
  if (argc == 1) {
    fprintf(stderr, "%s <cpuN> [cpuM] ... \n", argv[0]);
    return 1;
  }
  aargv = &argv[1];
  if (regcomp(&reg, regex, 0)) {
    fprintf(stderr, "failed to compile the regex\n");
    return 1;
  }
  CPU_ZERO(&cpuset);
  for (i = 0; i < (argc - 1); i++) {
    char *aux;
    int cpu;
    if (regexec(&reg, aargv[i], 1, m, 0)) {
      fprintf(stderr,
              "'%s' parameter not recognized, "
              "should be cpu[0-9]\n",
              aargv[i]);
      return 1;
    }
    aux = aargv[i] + 3;
    cpu = atoi(aux);
    CPU_SET(cpu, &cpuset);
  }
  if (sched_setaffinity(0, sizeof(cpuset), &cpuset)) {
    perror("sched_setaffinity");
    return 1;
  }
  if (setpriority(PRIO_PROCESS, 0, -20) < 0) {
    perror("setpriority");
    return 1;
  }
  for (;;)
    ;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe53(%rip),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11ed <main+0x5d>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    135d <main+0x1cd>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rsi
lea    -0x14(%rbp),%rdi
xor    %edx,%edx
call   1050 <regcomp@plt>
cmp    $0x0,%rax
je     1235 <main+0xa5>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    135d <main+0x1cd>
lea    -0x30(%rbp),%rdi
call   1080 <CPU_ZERO@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12ea <main+0x15a>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    -0x2c(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1070 <regexec@plt>
cmp    $0x0,%rax
je     12b0 <main+0x120>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xda2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    135d <main+0x1cd>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    $0x3,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   10b0 <CPU_SET@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1245 <main+0xb5>
xor    %edi,%edi
mov    $0x4,%esi
lea    -0x30(%rbp),%rdx
call   1040 <sched_setaffinity@plt>
cmp    $0x0,%rax
je     131c <main+0x18c>
lea    0xd67(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    135d <main+0x1cd>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0xffffffec,%edx
call   1030 <setpriority@plt>
cmp    $0x0,%rax
jge    1353 <main+0x1c3>
lea    0xd42(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    135d <main+0x1cd>
jmp    1358 <main+0x1c8>
jmp    1358 <main+0x1c8>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jne    11c2 <main+0x32>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe52(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11f4 <main+0x64>
mov    %edi,%r14d
lea    0xe34(%rip),%rsi
lea    0x10(%rsp),%rdi
xor    %edx,%edx
call   1050 <regcomp@plt>
test   %rax,%rax
je     1208 <main+0x78>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xe35(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc(%rsp),%rdi
call   1080 <CPU_ZERO@plt>
cmp    $0x2,%r14d
jl     126e <main+0xde>
add    $0xffffffff,%r14d
xor    %ebp,%ebp
lea    0x10(%rsp),%r15
lea    0x14(%rsp),%r12
lea    0xc(%rsp),%r13
nopl   (%rax)
mov    0x8(%rbx,%rbp,8),%rsi
mov    %r15,%rdi
mov    $0x1,%edx
mov    %r12,%rcx
xor    %r8d,%r8d
call   1070 <regexec@plt>
test   %rax,%rax
jne    12a2 <main+0x112>
mov    0x8(%rbx,%rbp,8),%rdi
add    $0x3,%rdi
call   10a0 <atoi@plt>
mov    %eax,%edi
mov    %r13,%rsi
call   10b0 <CPU_SET@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1230 <main+0xa0>
lea    0xc(%rsp),%rdx
xor    %edi,%edi
mov    $0x4,%esi
call   1040 <sched_setaffinity@plt>
test   %rax,%rax
jne    12bc <main+0x12c>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0xffffffec,%edx
call   1030 <setpriority@plt>
test   %rax,%rax
js     12c5 <main+0x135>
xchg   %ax,%ax
jmp    12a0 <main+0x110>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx,%rbp,8),%rdx
lea    0xd88(%rip),%rsi
jmp    11b9 <main+0x29>
lea    0xdaf(%rip),%rdi
jmp    12cc <main+0x13c>
lea    0xdb8(%rip),%rdi
call   1090 <perror@plt>
jmp    11f4 <main+0x64>

LLVM IR (-O0):
@.str = [11 x i8] c"cpu[0-9].*\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"%s <cpuN> [cpuM] ... \0A\00"
@.str.2 = [29 x i8] c"failed to compile the regex\0A\00"
@.str.3 = [51 x i8] c"'%s' parameter not recognized, should be cpu[0-9]\0A\00"
@.str.4 = [18 x i8] c"sched_setaffinity\00"
@PRIO_PROCESS = global i32 0
@.str.5 = [12 x i8] c"setpriority\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca [1 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %7
store i8** null, i8*** %8
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %20)
store i32 1, i32* %3
br label %82
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
store i8** %24, i8*** %8
%25 = load i8*, i8** %7
%26 = call i64 @regcomp(i32* %6, i8* %25, i32 0)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %82
31: ; preds = %22
%32 = call i32 @CPU_ZERO(i32* %10)
store i32 0, i32* %11
br label %33
33: ; preds = %66, %31
%34 = load i32, i32* %11
%35 = load i32, i32* %4
%36 = sub nsw i32 %35, 1
%37 = icmp slt i32 %34, %36
br i1 %37, label %38, label %69
38: ; preds = %33
%39 = load i8**, i8*** %8
%40 = load i32, i32* %11
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = getelementptr inbounds [1 x i32], [1 x i32]* %9, i64 0, i64 0
%45 = call i64 @regexec(i32* %6, i8* %43, i32 1, i32* %44, i32 0)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %55
47: ; preds = %38
%48 = load i32, i32* @stderr
%49 = load i8**, i8*** %8
%50 = load i32, i32* %11
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %53)
store i32 1, i32* %3
br label %82
55: ; preds = %38
%56 = load i8**, i8*** %8
%57 = load i32, i32* %11
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = getelementptr inbounds i8, i8* %60, i64 3
store i8* %61, i8** %12
%62 = load i8*, i8** %12
%63 = call i32 @atoi(i8* %62)
store i32 %63, i32* %13
%64 = load i32, i32* %13
%65 = call i32 @CPU_SET(i32 %64, i32* %10)
br label %66
66: ; preds = %55
%67 = load i32, i32* %11
%68 = add nsw i32 %67, 1
store i32 %68, i32* %11
br label %33
69: ; preds = %33
%70 = call i64 @sched_setaffinity(i32 0, i32 4, i32* %10)
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %69
%73 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %82
74: ; preds = %69
%75 = load i32, i32* @PRIO_PROCESS
%76 = call i64 @setpriority(i32 %75, i32 0, i32 -20)
%77 = icmp slt i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %74
%79 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %82
80: ; preds = %74
br label %81
81: ; preds = %81, %80
br label %81
82: ; preds = %78, %72, %47, %28, %16
%83 = load i32, i32* %3
ret i32 %83
}

LLVM IR (-O2):
@.str = [11 x i8] c"cpu[0-9].*\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"%s <cpuN> [cpuM] ... \0A\00"
@.str.2 = [29 x i8] c"failed to compile the regex\0A\00"
@.str.3 = [51 x i8] c"'%s' parameter not recognized, should be cpu[0-9]\0A\00"
@.str.4 = [18 x i8] c"sched_setaffinity\00"
@PRIO_PROCESS = global i32 0
@.str.5 = [12 x i8] c"setpriority\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [1 x i32]
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast [1 x i32]* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = icmp eq i32 %0, 1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %57
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = call i64 @regcomp(i32* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 0)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %57
21: ; preds = %14
%22 = call i32 @CPU_ZERO(i32* %5)
%23 = icmp sgt i32 %0, 1
br i1 %23, label %24, label %45
24: ; preds = %21
%25 = add nsw i32 %0, -1
%26 = getelementptr inbounds [1 x i32], [1 x i32]* %4, i64 0, i64 0
%27 = zext i32 %25 to i64
br label %28
28: ; preds = %24, %38
%29 = phi i64 [ 0, %24 ], [ %43, %38 ]
%30 = getelementptr inbounds i8*, i8** %15, i64 %29
%31 = load i8*, i8** %30
%32 = call i64 @regexec(i32* %3, i8* %31, i32 1, i32* %26, i32 0)
%33 = icmp eq i64 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %28
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %30
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %36)
br label %57
38: ; preds = %28
%39 = load i8*, i8** %30
%40 = getelementptr inbounds i8, i8* %39, i64 3
%41 = call i32 @atoi(i8* %40)
%42 = call i32 @CPU_SET(i32 %41, i32* %5)
%43 = add nuw nsw i64 %29, 1
%44 = icmp eq i64 %43, %27
br i1 %44, label %45, label %28
45: ; preds = %38, %21
%46 = call i64 @sched_setaffinity(i32 0, i32 4, i32* %5)
%47 = icmp eq i64 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %45
%49 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %57
50: ; preds = %45
%51 = load i32, i32* @PRIO_PROCESS
%52 = call i64 @setpriority(i32 %51, i32 0, i32 -20)
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %57
56: ; preds = %50, %56
br label %56
57: ; preds = %34, %54, %48, %18, %10
ret i32 1
}