#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*/ calibrate_cpu();
int /*<<< orphan*/ generate_load(unsigned int);
scalar_t__ parse_args(int, char const **, unsigned int *);
int /*<<< orphan*/ printf(char *, ...);
char *strrchr(char const *, char);
int main(int argc, const char *argv[]) {
  const char *name;
  unsigned int load = 0;
  printf("\nCPU load generator, build %s %s.\n", "Mar 15 2022", "21:25:05");
  printf("Copyright (C) 2006,2008 Nokia Corporation.\n");
  if (parse_args(argc, argv, &load)) {
    calibrate_cpu();
    generate_load(load);
    return 0;
  }
  name = strrchr(argv[0], '/');
  if (name)
    name++;
  else
    name = argv[0];
  printf("\nUsage: %s [-s <id>] <highest CPU load>\n"
         "\nExample: %s -s h 50\n\n",
         name, name);
  printf(
      "CPU load of 0 means random load, anything else is percentage (1-100).\n"
      "\nThe value given to '-s' can be used to set the scheduling "
      "priority/policy:\n"
      "\tl -- lowest nice() priority\n"
      "\th -- highest nice() priority\n"
      "\tb -- use SCHED_BATCH scheduler\n"
      "\tf -- use SCHED_FIFO scheduler (real time)\n"
      "\tr -- use SCHED_RR scheduler (real time)\n"
      "\to -- use SCHED_OTHER (default) scheduler\n"
      "\nSee \"man sched_setscheduler\" and \"man 2 nice\".\n");
  return 1;
}


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   $0x0,-0x1c(%rbp)
lea    0xe8c(%rip),%rdi
lea    0xea8(%rip),%rsi
lea    0xead(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <parse_args@plt>
cmp    $0x0,%rax
je     11cc <main+0x7c>
mov    $0x0,%al
call   1060 <calibrate_cpu@plt>
mov    -0x1c(%rbp),%edi
call   1070 <generate_load@plt>
movl   $0x0,-0x4(%rbp)
jmp    1233 <main+0xe3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11fd <main+0xad>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1208 <main+0xb8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0xc(%rsp)
lea    0xe84(%rip),%rdi
lea    0xea0(%rip),%rsi
lea    0xea5(%rip),%rdx
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <parse_args@plt>
test   %rax,%rax
je     11c6 <main+0x66>
xor    %eax,%eax
call   1070 <calibrate_cpu@plt>
mov    0xc(%rsp),%edi
call   1080 <generate_load@plt>
jmp    1204 <main+0xa4>
mov    (%rbx),%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
lea    0x1(%rax),%rdx
test   %rax,%rax
cmove  %rbx,%rdx
lea    0xe50(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0ACPU load generator, build %s %s.\0A\00"
@.str.1 = [12 x i8] c"Mar 15 2022\00"
@.str.2 = [9 x i8] c"21:25:05\00"
@.str.3 = [44 x i8] c"Copyright (C) 2006,2008 Nokia Corporation.\0A\00"
@.str.4 = [63 x i8] c"\0AUsage: %s [-s <id>] <highest CPU load>\0A\0AExample: %s -s h 50\0A\0A\00"
@.str.5 = [412 x i8] c"CPU load of 0 means random load, anything else is percentage (1-100).\0A\0AThe value given to '-s' can be used to set the scheduling priority/policy:\0A\09l -- lowest nice() priority\0A\09h -- highest nice() priority\0A\09b -- use SCHED_BATCH scheduler\0A\09f -- use SCHED_FIFO scheduler (real time)\0A\09r -- use SCHED_RR scheduler (real time)\0A\09o -- use SCHED_OTHER (default) scheduler\0A\0ASee \22man sched_setscheduler\22 and \22man 2 nice\22.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i64 @parse_args(i32 %10, i8** %11, i32* %7)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = call i32 (...) @calibrate_cpu()
%16 = load i32, i32* %7
%17 = call i32 @generate_load(i32 %16)
store i32 0, i32* %3
br label %37
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i8* @strrchr(i8* %21, i8 signext 47)
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %18
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %6
br label %32
28: ; preds = %18
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
store i8* %31, i8** %6
br label %32
32: ; preds = %28, %25
%33 = load i8*, i8** %6
%34 = load i8*, i8** %6
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0), i8* %33, i8* %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([412 x i8], [412 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %37
37: ; preds = %32, %14
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str = [35 x i8] c"\0ACPU load generator, build %s %s.\0A\00"
@.str.1 = [12 x i8] c"Mar 15 2022\00"
@.str.2 = [9 x i8] c"21:25:05\00"
@.str.4 = [63 x i8] c"\0AUsage: %s [-s <id>] <highest CPU load>\0A\0AExample: %s -s h 50\0A\0A\00"
@str = [43 x i8] c"Copyright (C) 2006,2008 Nokia Corporation.\00"
@str.6 = [411 x i8] c"CPU load of 0 means random load, anything else is percentage (1-100).\0A\0AThe value given to '-s' can be used to set the scheduling priority/policy:\0A\09l -- lowest nice() priority\0A\09h -- highest nice() priority\0A\09b -- use SCHED_BATCH scheduler\0A\09f -- use SCHED_FIFO scheduler (real time)\0A\09r -- use SCHED_RR scheduler (real time)\0A\09o -- use SCHED_OTHER (default) scheduler\0A\0ASee \22man sched_setscheduler\22 and \22man 2 nice\22.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%7 = call i64 @parse_args(i32 %0, i8** %1, i32* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = call i32 (...) @calibrate_cpu()
%11 = load i32, i32* %3
%12 = call i32 @generate_load(i32 %11)
br label %21
13: ; preds = %2
%14 = load i8*, i8** %1
%15 = call i8* @strrchr(i8* dereferenceable(1) %14, i8 signext 47)
%16 = icmp eq i8* %15, null
%17 = getelementptr inbounds i8, i8* %15, i64 1
%18 = select i1 %16, i8* %14, i8* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0), i8* %18, i8* %18)
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([411 x i8], [411 x i8]* @str.6, i64 0, i64 0))
br label %21
21: ; preds = %13, %9
%22 = phi i32 [ 0, %9 ], [ 1, %13 ]
ret i32 %22
}