#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*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int get_numCPUs();
char *malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strncmp(char *, char *, int);
int main(int argn, char **argv) {
  int cpuid;
  int freq;
  int numCPUs = 0;
  char *gov;
  char *gpath = malloc(100);
  char *fpath = malloc(100);
  if (argn < 3 || argn > 4) {
    fprintf(stderr, "Usage: %s <processorID> <frequency> [<governor>] \n",
            argv[0]);
    exit(EXIT_FAILURE);
  }
  cpuid = atoi(argv[1]);
  numCPUs = get_numCPUs();
  if (cpuid < 0 || cpuid > numCPUs) {
    fprintf(stderr, "CPU %d not a valid CPU ID. Range from 0 to %d.\n", cpuid,
            numCPUs);
    exit(EXIT_FAILURE);
  }
  freq = atoi(argv[2]);
  if (freq <= 0) {
    fprintf(stderr, "Frequency must be greater than 0.\n");
    exit(EXIT_FAILURE);
  }
  if (argn == 4) {
    gov = argv[3];
    if ((strncmp(gov, "ondemand", 8)) && (strncmp(gov, "performance", 11))) {
      fprintf(stderr, "Invalid governor %s!\n", gov);
      return (EXIT_FAILURE);
    }
    snprintf(gpath, 60,
             "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", cpuid);
    FILE *f = fopen(gpath, "w");
    if (f == NULL) {
      fprintf(stderr, "Unable to open path for writing\n");
      return (EXIT_FAILURE);
    }
    fprintf(f, "%s", gov);
    fclose(f);
    return (EXIT_SUCCESS);
  }
  snprintf(gpath, 60, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor",
           cpuid);
  snprintf(fpath, 60, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_setspeed",
           cpuid);
  FILE *f = fopen(gpath, "w");
  if (f == NULL) {
    fprintf(stderr, "Unable to open path for writing\n");
    return (EXIT_FAILURE);
  }
  fprintf(f, "userspace");
  fclose(f);
  f = fopen(fpath, "w");
  if (f == NULL) {
    fprintf(stderr, "Unable to open path for writing\n");
    return (EXIT_FAILURE);
  }
  fprintf(f, "%d", freq);
  fclose(f);
  return (EXIT_SUCCESS);
}


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)
movl   $0x0,-0x1c(%rbp)
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     11dd <main+0x4d>
cmpl   $0x4,-0x8(%rbp)
jle    120a <main+0x7a>
mov    0x2dfc(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   10a0 <get_numCPUs@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     123a <main+0xaa>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1266 <main+0xd6>
mov    0x2d9f(%rip),%rax
movslq (%rax),%rdi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xde2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     12a6 <main+0x116>
mov    0x2d59(%rip),%rax
movslq (%rax),%rdi
lea    0xdd2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jne    13b7 <main+0x227>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdbf(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1327 <main+0x197>
mov    -0x28(%rbp),%rdi
lea    0xda9(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1327 <main+0x197>
mov    0x2cdf(%rip),%rax
movslq (%rax),%rdi
mov    -0x28(%rbp),%rdx
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cbb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14bc <main+0x32c>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x3c,%esi
lea    0xd77(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xd9e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1387 <main+0x1f7>
mov    0x2c7b(%rip),%rax
movslq (%rax),%rdi
lea    0xd7b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14bc <main+0x32c>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xd75(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2c23(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14bc <main+0x32c>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x3c,%esi
lea    0xce7(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x3c,%esi
lea    0xd2c(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xcf6(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    142f <main+0x29f>
mov    0x2bd3(%rip),%rax
movslq (%rax),%rdi
lea    0xcd3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2bb3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14bc <main+0x32c>
mov    -0x48(%rbp),%rdi
lea    0xd0b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x38(%rbp),%rdi
lea    0xc93(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1492 <main+0x302>
mov    0x2b70(%rip),%rax
movslq (%rax),%rdi
lea    0xc70(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2b50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14bc <main+0x32c>
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xcaf(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2b19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
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
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
lea    -0x5(%rbp),%eax
cmp    $0xfffffffd,%eax
jbe    139e <main+0x1ee>
mov    0x8(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   10b0 <get_numCPUs@plt>
test   %r13d,%r13d
js     13bb <main+0x20b>
cmp    %eax,%r13d
jg     13bb <main+0x20b>
mov    0x10(%rbx),%rdi
call   10a0 <atoi@plt>
test   %eax,%eax
jle    13da <main+0x22a>
cmp    $0x4,%ebp
jne    127f <main+0xcf>
mov    0x18(%rbx),%rbx
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     131c <main+0x16c>
lea    0xe46(%rip),%rsi
mov    %rbx,%rdi
mov    $0xb,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     131c <main+0x16c>
mov    0x2d7a(%rip),%rax
movslq (%rax),%rdi
lea    0xe2b(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1386 <main+0x1d6>
mov    %eax,%r12d
lea    0xe28(%rip),%rdx
mov    %r15,%rdi
mov    $0x3c,%esi
mov    %r13d,%ecx
call   1050 <snprintf@plt>
lea    0xe6b(%rip),%rdx
mov    %r14,%rdi
mov    $0x3c,%esi
mov    %r13d,%ecx
call   1050 <snprintf@plt>
lea    0xe31(%rip),%rsi
mov    %r15,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1366 <main+0x1b6>
mov    %rax,%rbx
lea    0xe70(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10d0 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xdf5(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1366 <main+0x1b6>
mov    %rax,%rbx
lea    0xe42(%rip),%rsi
mov    %rax,%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %rbx,%rdi
jmp    1358 <main+0x1a8>
lea    0xd8e(%rip),%rdx
mov    %r15,%rdi
mov    $0x3c,%esi
mov    %r13d,%ecx
call   1050 <snprintf@plt>
lea    0xdae(%rip),%rsi
mov    %r15,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1366 <main+0x1b6>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <fputs@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    0x2c6c(%rip),%rax
jmp    138d <main+0x1dd>
mov    0x2c73(%rip),%rax
movslq (%rax),%rcx
lea    0xd73(%rip),%rdi
mov    $0x20,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
mov    0x2c4b(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c3b(%rip),%rax
movslq (%rax),%rdi
mov    (%rbx),%rdx
lea    0xc4e(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    13fa <main+0x24a>
mov    0x2c1e(%rip),%rcx
movslq (%rcx),%rdi
lea    0xc67(%rip),%rsi
mov    %r13d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    13fa <main+0x24a>
mov    0x2bff(%rip),%rax
movslq (%rax),%rcx
lea    0xc78(%rip),%rdi
mov    $0x22,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
mov    0x2bd7(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [51 x i8] c"Usage: %s <processorID> <frequency> [<governor>] \0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [48 x i8] c"CPU %d not a valid CPU ID. Range from 0 to %d.\0A\00"
@.str.2 = [35 x i8] c"Frequency must be greater than 0.\0A\00"
@.str.3 = [9 x i8] c"ondemand\00"
@.str.4 = [12 x i8] c"performance\00"
@.str.5 = [22 x i8] c"Invalid governor %s!\0A\00"
@.str.6 = [55 x i8] c"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [33 x i8] c"Unable to open path for writing\0A\00"
@.str.9 = [3 x i8] c"%s\00"
@EXIT_SUCCESS = global i32 0
@.str.10 = [55 x i8] c"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_setspeed\00"
@.str.11 = [10 x i8] c"userspace\00"
@.str.12 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%14 = call i8* @malloc(i32 100)
store i8* %14, i8** %10
%15 = call i8* @malloc(i32 100)
store i8* %15, i8** %11
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %21, label %18
18: ; preds = %2
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 4
br i1 %20, label %21, label %31
21: ; preds = %18, %2
%22 = load i32, i32* @stderr
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to i32*
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %18
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
store i32 %35, i32* %6
%36 = call i32 (...) @get_numCPUs()
store i32 %36, i32* %8
%37 = load i32, i32* %6
%38 = icmp slt i32 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %31
%40 = load i32, i32* %6
%41 = load i32, i32* %8
%42 = icmp sgt i32 %40, %41
br i1 %42, label %43, label %52
43: ; preds = %39, %31
%44 = load i32, i32* @stderr
%45 = sext i32 %44 to i64
%46 = inttoptr i64 %45 to i32*
%47 = load i32, i32* %6
%48 = load i32, i32* %8
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %46, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %47, i32 %48)
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %39
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = call i32 @atoi(i8* %55)
store i32 %56, i32* %7
%57 = load i32, i32* %7
%58 = icmp sle i32 %57, 0
br i1 %58, label %59, label %66
59: ; preds = %52
%60 = load i32, i32* @stderr
%61 = sext i32 %60 to i64
%62 = inttoptr i64 %61 to i32*
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %52
%67 = load i32, i32* %4
%68 = icmp eq i32 %67, 4
br i1 %68, label %69, label %108
69: ; preds = %66
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 3
%72 = load i8*, i8** %71
store i8* %72, i8** %9
%73 = load i8*, i8** %9
%74 = call i64 @strncmp(i8* %73, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %87
76: ; preds = %69
%77 = load i8*, i8** %9
%78 = call i64 @strncmp(i8* %77, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 11)
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %87
80: ; preds = %76
%81 = load i32, i32* @stderr
%82 = sext i32 %81 to i64
%83 = inttoptr i64 %82 to i32*
%84 = load i8*, i8** %9
%85 = call i32 (i32*, i8*, ...) @fprintf(i32* %83, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %84)
%86 = load i32, i32* @EXIT_FAILURE
store i32 %86, i32* %3
br label %147
87: ; preds = %76, %69
%88 = load i8*, i8** %10
%89 = load i32, i32* %6
%90 = call i32 @snprintf(i8* %88, i32 60, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i32 %89)
%91 = load i8*, i8** %10
%92 = call i32* @fopen(i8* %91, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %92, i32** %12
%93 = load i32*, i32** %12
%94 = icmp eq i32* %93, null
br i1 %94, label %95, label %101
95: ; preds = %87
%96 = load i32, i32* @stderr
%97 = sext i32 %96 to i64
%98 = inttoptr i64 %97 to i32*
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %98, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%100 = load i32, i32* @EXIT_FAILURE
store i32 %100, i32* %3
br label %147
101: ; preds = %87
%102 = load i32*, i32** %12
%103 = load i8*, i8** %9
%104 = call i32 (i32*, i8*, ...) @fprintf(i32* %102, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %103)
%105 = load i32*, i32** %12
%106 = call i32 @fclose(i32* %105)
%107 = load i32, i32* @EXIT_SUCCESS
store i32 %107, i32* %3
br label %147
108: ; preds = %66
%109 = load i8*, i8** %10
%110 = load i32, i32* %6
%111 = call i32 @snprintf(i8* %109, i32 60, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i32 %110)
%112 = load i8*, i8** %11
%113 = load i32, i32* %6
%114 = call i32 @snprintf(i8* %112, i32 60, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.10, i64 0, i64 0), i32 %113)
%115 = load i8*, i8** %10
%116 = call i32* @fopen(i8* %115, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %116, i32** %13
%117 = load i32*, i32** %13
%118 = icmp eq i32* %117, null
br i1 %118, label %119, label %125
119: ; preds = %108
%120 = load i32, i32* @stderr
%121 = sext i32 %120 to i64
%122 = inttoptr i64 %121 to i32*
%123 = call i32 (i32*, i8*, ...) @fprintf(i32* %122, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%124 = load i32, i32* @EXIT_FAILURE
store i32 %124, i32* %3
br label %147
125: ; preds = %108
%126 = load i32*, i32** %13
%127 = call i32 (i32*, i8*, ...) @fprintf(i32* %126, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%128 = load i32*, i32** %13
%129 = call i32 @fclose(i32* %128)
%130 = load i8*, i8** %11
%131 = call i32* @fopen(i8* %130, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %131, i32** %13
%132 = load i32*, i32** %13
%133 = icmp eq i32* %132, null
br i1 %133, label %134, label %140
134: ; preds = %125
%135 = load i32, i32* @stderr
%136 = sext i32 %135 to i64
%137 = inttoptr i64 %136 to i32*
%138 = call i32 (i32*, i8*, ...) @fprintf(i32* %137, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%139 = load i32, i32* @EXIT_FAILURE
store i32 %139, i32* %3
br label %147
140: ; preds = %125
%141 = load i32*, i32** %13
%142 = load i32, i32* %7
%143 = call i32 (i32*, i8*, ...) @fprintf(i32* %141, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32 %142)
%144 = load i32*, i32** %13
%145 = call i32 @fclose(i32* %144)
%146 = load i32, i32* @EXIT_SUCCESS
store i32 %146, i32* %3
br label %147
147: ; preds = %140, %134, %119, %101, %95, %80
%148 = load i32, i32* %3
ret i32 %148
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [51 x i8] c"Usage: %s <processorID> <frequency> [<governor>] \0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [48 x i8] c"CPU %d not a valid CPU ID. Range from 0 to %d.\0A\00"
@.str.2 = [35 x i8] c"Frequency must be greater than 0.\0A\00"
@.str.3 = [9 x i8] c"ondemand\00"
@.str.4 = [12 x i8] c"performance\00"
@.str.5 = [22 x i8] c"Invalid governor %s!\0A\00"
@.str.6 = [55 x i8] c"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [33 x i8] c"Unable to open path for writing\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.10 = [55 x i8] c"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_setspeed\00"
@.str.11 = [10 x i8] c"userspace\00"
@.str.12 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%4 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%5 = add i32 %0, -5
%6 = icmp ult i32 %5, -2
br i1 %6, label %7, label %15
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i32*
%11 = load i8*, i8** %1
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = tail call i32 (...) @get_numCPUs()
%20 = icmp slt i32 %18, 0
%21 = icmp sgt i32 %18, %19
%22 = select i1 %20, i1 true, i1 %21
br i1 %22, label %23, label %30
23: ; preds = %15
%24 = load i32, i32* @stderr
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i32*
%27 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19)
%28 = load i32, i32* @EXIT_FAILURE
%29 = tail call i32 @exit(i32 %28)
unreachable
30: ; preds = %15
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i8*, i8** %31
%33 = tail call i32 @atoi(i8* %32)
%34 = icmp slt i32 %33, 1
br i1 %34, label %35, label %42
35: ; preds = %30
%36 = load i32, i32* @stderr
%37 = sext i32 %36 to i64
%38 = inttoptr i64 %37 to i32*
%39 = tail call i64 @fwrite(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i64 34, i64 1, i32* %38)
%40 = load i32, i32* @EXIT_FAILURE
%41 = tail call i32 @exit(i32 %40)
unreachable
42: ; preds = %30
%43 = icmp eq i32 %0, 4
br i1 %43, label %44, label %69
44: ; preds = %42
%45 = getelementptr inbounds i8*, i8** %1, i64 3
%46 = load i8*, i8** %45
%47 = tail call i64 @strncmp(i8* %46, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
%48 = icmp eq i64 %47, 0
br i1 %48, label %57, label %49
49: ; preds = %44
%50 = tail call i64 @strncmp(i8* %46, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 11)
%51 = icmp eq i64 %50, 0
br i1 %51, label %57, label %52
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = sext i32 %53 to i64
%55 = inttoptr i64 %54 to i32*
%56 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %46)
br label %92
57: ; preds = %49, %44
%58 = tail call i32 @snprintf(i8* %3, i32 60, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i32 %18)
%59 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%60 = icmp eq i32* %59, null
br i1 %60, label %61, label %66
61: ; preds = %57
%62 = load i32, i32* @stderr
%63 = sext i32 %62 to i64
%64 = inttoptr i64 %63 to i32*
%65 = tail call i64 @fwrite(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i64 32, i64 1, i32* %64)
br label %92
66: ; preds = %57
%67 = tail call i32 @fputs(i8* %46, i32* %59)
%68 = tail call i32 @fclose(i32* %59)
br label %92
69: ; preds = %42
%70 = tail call i32 @snprintf(i8* %3, i32 60, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i32 %18)
%71 = tail call i32 @snprintf(i8* %4, i32 60, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.10, i64 0, i64 0), i32 %18)
%72 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%73 = icmp eq i32* %72, null
br i1 %73, label %74, label %79
74: ; preds = %69
%75 = load i32, i32* @stderr
%76 = sext i32 %75 to i64
%77 = inttoptr i64 %76 to i32*
%78 = tail call i64 @fwrite(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i64 32, i64 1, i32* %77)
br label %92
79: ; preds = %69
%80 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i64 9, i64 1, i32* %72)
%81 = tail call i32 @fclose(i32* %72)
%82 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%83 = icmp eq i32* %82, null
br i1 %83, label %84, label %89
84: ; preds = %79
%85 = load i32, i32* @stderr
%86 = sext i32 %85 to i64
%87 = inttoptr i64 %86 to i32*
%88 = tail call i64 @fwrite(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i64 32, i64 1, i32* %87)
br label %92
89: ; preds = %79
%90 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32 %33)
%91 = tail call i32 @fclose(i32* %82)
br label %92
92: ; preds = %74, %84, %89, %61, %66, %52
%93 = phi i32* [ @EXIT_FAILURE, %52 ], [ @EXIT_FAILURE, %61 ], [ @EXIT_SUCCESS, %66 ], [ @EXIT_FAILURE, %74 ], [ @EXIT_FAILURE, %84 ], [ @EXIT_SUCCESS, %89 ]
%94 = load i32, i32* %93
ret i32 %94
}