#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int get_cpu_cores();
int /*<<< orphan*/ stdout;
void usage(void) {
  int ncpus = get_cpu_cores();
  fprintf(stdout, "CPULeash: Keeps a given running process leashed under a "
                  "certain cpu utilization threshold\n");
  fprintf(stdout, "Usage:\ncpuleash (-l scaled_percent | -L absolute_percent) "
                  "-p pid [-s sample_time] [-v] [-h]\n");
  fprintf(stdout,
          "-l: Comma seperated scaled percent value for each of the process "
          "specified in -p. Range [0, 100]. Target cpu value divided by the "
          "number of cpu \n    in the system. Current system: %d\n",
          ncpus);
  fprintf(stdout,
          "-L: Comma seperated absolute percent value for each of the process "
          "specified in -p. Range [0, %d]. Target cpu value is absolute.\n",
          100 * ncpus);
  fprintf(stdout,
          "-j: Scaled percent value for the process group list specified in -g "
          "or for the entire process tree with the root specified in -t. Range "
          "[0, 100]. Target cpu value divided by the number of cpu \n    in "
          "the system. Current system: %d\n",
          ncpus);
  fprintf(stdout,
          "-J: Scaled percent value for the process group list specified in -g "
          "or for the entire process tree with the root specified in -t. Range "
          "[0, %d]. Target cpu value is absolute.\n",
          100 * ncpus);
  fprintf(stdout, "-p: Comma seperated PIDs to leash\n");
  fprintf(stdout, "-g: Comma seperated PIDs to be leashed as one group\n");
  fprintf(stdout, "-t: PID of the parent process, whole entire children tree "
                  "is to be leashed as a group\n");
  fprintf(stdout, "-s: Sample time in seconds. Default 1.0s (optional)\n");
  fprintf(stdout, "-v: Verbose\n");
  fprintf(stdout, "-h: Shows this help\n");
  fprintf(stdout, "\nOption -p is mandatory. \n-l and -L are mutually "
                  "exclusive and mandatory.\n");
  fprintf(
      stdout,
      "\nExample: The invocation `cpuleash -L 33,55,66,77 -p 123,456,789,345' "
      "will leash the PIDs to the corresponding percentages\n");
  fprintf(stdout,
          "\nExample: The invocation `cpuleash -J 50 -g 123,456,789,345' will "
          "leash the PIDs as a group to be within 50%% absolute threshold\n");
  fprintf(stdout, "\nExample: The invocation `cpuleash -J 50 -t 123' will "
                  "leash the given PID and auto-populated children of it as a "
                  "group to be within 50%% absolute threshold\n");
  fprintf(stdout,
          "\nCPULeash version %s\nAuthor: Arjun Pakrashi (phoxis [at] gmail "
          "[dot] com)\n",
          "1.9.1");
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <get_cpu_cores@plt>
mov    %eax,-0x4(%rbp)
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
lea    0xebe(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
lea    0xf02(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xf45(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
imul   $0x64,-0x4(%rbp),%edx
lea    0xfe2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0x104a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
imul   $0x64,-0x4(%rbp),%edx
lea    0x1117(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0x11b0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
lea    0x11bc(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
lea    0x11da(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0x121a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
lea    0x1238(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0x122e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    0x122c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0x1260(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0x12c5(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
lea    0x1330(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
lea    0x13b6(%rip),%rsi
lea    0x13fa(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <get_cpu_cores@plt>
mov    %eax,%ebx
mov    0x2eac(%rip),%r14
mov    (%r14),%edi
lea    0xec2(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xf0c(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xf58(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
imul   $0x64,%ebx,%ebp
lea    0xffa(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x1069(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x113e(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x11db(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x11ed(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x1211(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x1257(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x127b(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x1277(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x127b(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x12b5(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x1320(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x1391(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0x141d(%rip),%rsi
lea    0x1461(%rip),%rdx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [91 x i8] c"CPULeash: Keeps a given running process leashed under a certain cpu utilization threshold\0A\00"
@.str.1 = [93 x i8] c"Usage:\0Acpuleash (-l scaled_percent | -L absolute_percent) -p pid [-s sample_time] [-v] [-h]\0A\00"
@.str.2 = [184 x i8] c"-l: Comma seperated scaled percent value for each of the process specified in -p. Range [0, 100]. Target cpu value divided by the number of cpu \0A in the system. Current system: %d\0A\00"
@.str.3 = [130 x i8] c"-L: Comma seperated absolute percent value for each of the process specified in -p. Range [0, %d]. Target cpu value is absolute.\0A\00"
@.str.4 = [232 x i8] c"-j: Scaled percent value for the process group list specified in -g or for the entire process tree with the root specified in -t. Range [0, 100]. Target cpu value divided by the number of cpu \0A in the system. Current system: %d\0A\00"
@.str.5 = [176 x i8] c"-J: Scaled percent value for the process group list specified in -g or for the entire process tree with the root specified in -t. Range [0, %d]. Target cpu value is absolute.\0A\00"
@.str.6 = [35 x i8] c"-p: Comma seperated PIDs to leash\0A\00"
@.str.7 = [53 x i8] c"-g: Comma seperated PIDs to be leashed as one group\0A\00"
@.str.8 = [87 x i8] c"-t: PID of the parent process, whole entire children tree is to be leashed as a group\0A\00"
@.str.9 = [53 x i8] c"-s: Sample time in seconds. Default 1.0s (optional)\0A\00"
@.str.10 = [13 x i8] c"-v: Verbose\0A\00"
@.str.11 = [21 x i8] c"-h: Shows this help\0A\00"
@.str.12 = [75 x i8] c"\0AOption -p is mandatory. \0A-l and -L are mutually exclusive and mandatory.\0A\00"
@.str.13 = [124 x i8] c"\0AExample: The invocation `cpuleash -L 33,55,66,77 -p 123,456,789,345' will leash the PIDs to the corresponding percentages\0A\00"
@.str.14 = [130 x i8] c"\0AExample: The invocation `cpuleash -J 50 -g 123,456,789,345' will leash the PIDs as a group to be within 50%% absolute threshold\0A\00"
@.str.15 = [157 x i8] c"\0AExample: The invocation `cpuleash -J 50 -t 123' will leash the given PID and auto-populated children of it as a group to be within 50%% absolute threshold\0A\00"
@.str.16 = [75 x i8] c"\0ACPULeash version %s\0AAuthor: Arjun Pakrashi (phoxis [at] gmail [dot] com)\0A\00"
@.str.17 = [6 x i8] c"1.9.1\00"
define void @usage() {
%1 = alloca i32
%2 = call i32 (...) @get_cpu_cores()
store i32 %2, i32* %1
%3 = load i32, i32* @stdout
%4 = call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdout
%6 = call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @stdout
%8 = load i32, i32* %1
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([184 x i8], [184 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @stdout
%11 = load i32, i32* %1
%12 = mul nsw i32 100, %11
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stdout
%15 = load i32, i32* %1
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([232 x i8], [232 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = load i32, i32* @stdout
%18 = load i32, i32* %1
%19 = mul nsw i32 100, %18
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @stdout
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%23 = load i32, i32* @stdout
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0))
%25 = load i32, i32* @stdout
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.8, i64 0, i64 0))
%27 = load i32, i32* @stdout
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0))
%29 = load i32, i32* @stdout
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%31 = load i32, i32* @stdout
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%33 = load i32, i32* @stdout
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.12, i64 0, i64 0))
%35 = load i32, i32* @stdout
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str.13, i64 0, i64 0))
%37 = load i32, i32* @stdout
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.14, i64 0, i64 0))
%39 = load i32, i32* @stdout
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str.15, i64 0, i64 0))
%41 = load i32, i32* @stdout
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [91 x i8] c"CPULeash: Keeps a given running process leashed under a certain cpu utilization threshold\0A\00"
@.str.1 = [93 x i8] c"Usage:\0Acpuleash (-l scaled_percent | -L absolute_percent) -p pid [-s sample_time] [-v] [-h]\0A\00"
@.str.2 = [184 x i8] c"-l: Comma seperated scaled percent value for each of the process specified in -p. Range [0, 100]. Target cpu value divided by the number of cpu \0A in the system. Current system: %d\0A\00"
@.str.3 = [130 x i8] c"-L: Comma seperated absolute percent value for each of the process specified in -p. Range [0, %d]. Target cpu value is absolute.\0A\00"
@.str.4 = [232 x i8] c"-j: Scaled percent value for the process group list specified in -g or for the entire process tree with the root specified in -t. Range [0, 100]. Target cpu value divided by the number of cpu \0A in the system. Current system: %d\0A\00"
@.str.5 = [176 x i8] c"-J: Scaled percent value for the process group list specified in -g or for the entire process tree with the root specified in -t. Range [0, %d]. Target cpu value is absolute.\0A\00"
@.str.6 = [35 x i8] c"-p: Comma seperated PIDs to leash\0A\00"
@.str.7 = [53 x i8] c"-g: Comma seperated PIDs to be leashed as one group\0A\00"
@.str.8 = [87 x i8] c"-t: PID of the parent process, whole entire children tree is to be leashed as a group\0A\00"
@.str.9 = [53 x i8] c"-s: Sample time in seconds. Default 1.0s (optional)\0A\00"
@.str.10 = [13 x i8] c"-v: Verbose\0A\00"
@.str.11 = [21 x i8] c"-h: Shows this help\0A\00"
@.str.12 = [75 x i8] c"\0AOption -p is mandatory. \0A-l and -L are mutually exclusive and mandatory.\0A\00"
@.str.13 = [124 x i8] c"\0AExample: The invocation `cpuleash -L 33,55,66,77 -p 123,456,789,345' will leash the PIDs to the corresponding percentages\0A\00"
@.str.14 = [130 x i8] c"\0AExample: The invocation `cpuleash -J 50 -g 123,456,789,345' will leash the PIDs as a group to be within 50%% absolute threshold\0A\00"
@.str.15 = [157 x i8] c"\0AExample: The invocation `cpuleash -J 50 -t 123' will leash the given PID and auto-populated children of it as a group to be within 50%% absolute threshold\0A\00"
@.str.16 = [75 x i8] c"\0ACPULeash version %s\0AAuthor: Arjun Pakrashi (phoxis [at] gmail [dot] com)\0A\00"
@.str.17 = [6 x i8] c"1.9.1\00"
define void @usage() {
%1 = tail call i32 (...) @get_cpu_cores()
%2 = load i32, i32* @stdout
%3 = tail call i32 (i32, i8*, ...) @fprintf(i32 %2, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdout
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @stdout
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([184 x i8], [184 x i8]* @.str.2, i64 0, i64 0), i32 %1)
%8 = load i32, i32* @stdout
%9 = mul nsw i32 %1, 100
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @stdout
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([232 x i8], [232 x i8]* @.str.4, i64 0, i64 0), i32 %1)
%13 = load i32, i32* @stdout
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str.5, i64 0, i64 0), i32 %9)
%15 = load i32, i32* @stdout
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%17 = load i32, i32* @stdout
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0))
%19 = load i32, i32* @stdout
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.8, i64 0, i64 0))
%21 = load i32, i32* @stdout
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0))
%23 = load i32, i32* @stdout
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%25 = load i32, i32* @stdout
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%27 = load i32, i32* @stdout
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.12, i64 0, i64 0))
%29 = load i32, i32* @stdout
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str.13, i64 0, i64 0))
%31 = load i32, i32* @stdout
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.14, i64 0, i64 0))
%33 = load i32, i32* @stdout
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str.15, i64 0, i64 0))
%35 = load i32, i32* @stdout
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
ret void
}