#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 pid_t;

/* Variables and functions */
int SCHED_FIFO;
int SCHED_OTHER;
int SCHED_RR;
int /*<<< orphan*/ abort();
int atol(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(char);
char *optarg;
scalar_t__ opterr;
int optind;
char optopt;
int /*<<< orphan*/ print_params(int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ set_policy(int, int, int);
int /*<<< orphan*/ set_priority(int, int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  int do_get = 0;
  int do_set = 0;
  char *pvalue = NULL;
  pid_t pid = 0;
  int priority = 0;
  int policy = -1;
  int index;
  int c;
  printf("sched_pp (V1.0) (c) M.Behr, 2013\n");
  opterr = 0;
  while ((c = getopt(argc, argv, "gs:p:P:")) != -1)
    switch (c) {
    case 'g':
      do_get = 1;
      break;
    case 's':
      do_set = 1;
      priority = atol(optarg);
      break;
    case 'p':
      pvalue = optarg;
      pid = atol(pvalue);
      break;
    case 'P':
      if (!strcmp(optarg, "SCHED_FIFO"))
        policy = SCHED_FIFO;
      else if (!strcmp(optarg, "SCHED_RR"))
        policy = SCHED_RR;
      else if (!strcmp(optarg, "SCHED_OTHER"))
        policy = SCHED_OTHER;
      else {
        fprintf(stderr, "Unknown policy <%s>.\n", optarg);
        return 2;
      }
      break;
    case '?':
      if (optopt == 'p' || optopt == 's' || optopt == 'P')
        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
      else if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      return 1;
    default:
      abort();
    }
  for (index = optind; index < argc; index++)
    printf("Non-option argument %s\n", argv[index]);
  if (!do_get && !do_set) {
    printf("Usage:\nsched_pp -p <pid> [-g] [-s <priority>] "
           "[-P<policy=SCHED_FIFO|SCHED_RR|SCHED_OTHER>]\n");
  }
  if (do_get) {
    print_params(pid, 0);
  }
  if (do_set) {
    int cur_policy;
    print_params(pid, &cur_policy);
    if (policy != -1) {
      printf("trying to change pid %d to policy %d and priority %d:\n", pid,
             policy, priority);
      if (policy != SCHED_OTHER)
        set_policy(pid, policy, priority);
      else {
        set_policy(pid, policy, 0);
        set_priority(pid, policy, priority);
      }
    } else {
      printf("trying to change pid %d to priority %d:\n Params now:\n", pid,
             priority);
      set_priority(pid, cur_policy, priority);
    }
    print_params(pid, 0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2dba(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe17(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     1464 <main+0x2c4>
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x3f,%eax
je     1389 <main+0x1e9>
jmp    1230 <main+0x90>
mov    -0x3c(%rbp),%eax
sub    $0x50,%eax
je     12bd <main+0x11d>
jmp    1241 <main+0xa1>
mov    -0x3c(%rbp),%eax
sub    $0x67,%eax
je     1274 <main+0xd4>
jmp    1252 <main+0xb2>
mov    -0x3c(%rbp),%eax
sub    $0x70,%eax
je     129e <main+0xfe>
jmp    1263 <main+0xc3>
mov    -0x3c(%rbp),%eax
sub    $0x73,%eax
je     1280 <main+0xe0>
jmp    1458 <main+0x2b8>
movl   $0x1,-0x14(%rbp)
jmp    145f <main+0x2bf>
movl   $0x1,-0x18(%rbp)
mov    0x2d6a(%rip),%rax
mov    (%rax),%rdi
call   10a0 <atol@plt>
mov    %eax,-0x28(%rbp)
jmp    145f <main+0x2bf>
mov    0x2d53(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   10a0 <atol@plt>
mov    %eax,-0x24(%rbp)
jmp    145f <main+0x2bf>
mov    0x2d34(%rip),%rax
mov    (%rax),%rdi
lea    0xd5c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    12ed <main+0x14d>
mov    0x2ced(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    1384 <main+0x1e4>
mov    0x2d04(%rip),%rax
mov    (%rax),%rdi
lea    0xd37(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    131d <main+0x17d>
mov    0x2c8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    137f <main+0x1df>
mov    0x2cd4(%rip),%rax
mov    (%rax),%rdi
lea    0xd10(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    134d <main+0x1ad>
mov    0x2c75(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    137a <main+0x1da>
mov    0x2c6c(%rip),%rax
mov    (%rax),%edi
mov    0x2c9b(%rip),%rax
mov    (%rax),%rdx
lea    0xce3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    158d <main+0x3ed>
jmp    137f <main+0x1df>
jmp    1384 <main+0x1e4>
jmp    145f <main+0x2bf>
mov    0x2c50(%rip),%rax
movsbl (%rax),%eax
cmp    $0x70,%eax
je     13c2 <main+0x222>
mov    0x2c3d(%rip),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
je     13c2 <main+0x222>
mov    0x2c2a(%rip),%rax
movsbl (%rax),%eax
cmp    $0x50,%eax
jne    13e8 <main+0x248>
mov    0x2bf7(%rip),%rax
mov    (%rax),%edi
mov    0x2c0e(%rip),%rax
movsbl (%rax),%edx
lea    0xc84(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    144c <main+0x2ac>
mov    0x2bf1(%rip),%rax
movsbl (%rax),%edi
call   1090 <isprint@plt>
cmp    $0x0,%eax
je     1426 <main+0x286>
mov    0x2bb9(%rip),%rax
mov    (%rax),%edi
mov    0x2bd0(%rip),%rax
movsbl (%rax),%edx
lea    0xc68(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1447 <main+0x2a7>
mov    0x2b93(%rip),%rax
mov    (%rax),%edi
mov    0x2baa(%rip),%rax
movsbl (%rax),%edx
lea    0xc59(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    144c <main+0x2ac>
movl   $0x1,-0x4(%rbp)
jmp    158d <main+0x3ed>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11fd <main+0x5d>
mov    0x2b6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14a4 <main+0x304>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xc2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1470 <main+0x2d0>
cmpl   $0x0,-0x14(%rbp)
jne    14c6 <main+0x326>
cmpl   $0x0,-0x18(%rbp)
jne    14c6 <main+0x326>
lea    0xc14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
je     14dc <main+0x33c>
mov    -0x24(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <print_params@plt>
cmpl   $0x0,-0x18(%rbp)
je     1586 <main+0x3e6>
mov    -0x24(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1080 <print_params@plt>
cmpl   $0xffffffff,-0x2c(%rbp)
je     1558 <main+0x3b8>
mov    -0x24(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xc23(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
mov    0x2a9b(%rip),%rcx
cmp    (%rcx),%eax
je     1538 <main+0x398>
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1040 <set_policy@plt>
jmp    1553 <main+0x3b3>
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
xor    %edx,%edx
call   1040 <set_policy@plt>
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
call   10c0 <set_priority@plt>
jmp    157a <main+0x3da>
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xc01(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    -0x28(%rbp),%edx
call   10c0 <set_priority@plt>
mov    -0x24(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <print_params@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%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,%r15
mov    %edi,%r13d
lea    0xf53(%rip),%rdi
call   1040 <puts@plt>
mov    0x2dd9(%rip),%rax
movq   $0x0,(%rax)
mov    $0xffffffff,%r12d
movl   $0x0,0x8(%rsp)
lea    0xe0d(%rip),%rbx
mov    0x2dfe(%rip),%r14
movl   $0x0,0x4(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
jmp    1223 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rcx),%r12d
mov    %r13d,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   10c0 <getopt@plt>
cmp    $0x50,%eax
jne    128c <main+0xdc>
mov    (%r14),%rbp
mov    %rbp,%rdi
lea    0xdc5(%rip),%rsi
call   1070 <strcmp@plt>
mov    0x2d81(%rip),%rcx
test   %eax,%eax
je     1220 <main+0x70>
mov    %rbp,%rdi
lea    0xdb6(%rip),%rsi
call   1070 <strcmp@plt>
mov    0x2d37(%rip),%rcx
test   %eax,%eax
je     1220 <main+0x70>
mov    %rbp,%rdi
lea    0xda5(%rip),%rsi
call   1070 <strcmp@plt>
mov    0x2d35(%rip),%rcx
test   %eax,%eax
je     1220 <main+0x70>
jmp    1405 <main+0x255>
cmp    $0x66,%eax
jle    12d9 <main+0x129>
cmp    $0x67,%eax
je     12bd <main+0x10d>
cmp    $0x70,%eax
je     12c8 <main+0x118>
cmp    $0x73,%eax
jne    14a7 <main+0x2f7>
mov    (%r14),%rdi
call   10b0 <atol@plt>
mov    %eax,0xc(%rsp)
movl   $0x1,0x4(%rsp)
jmp    1223 <main+0x73>
mov    $0x1,%al
mov    %eax,0x8(%rsp)
jmp    1223 <main+0x73>
mov    (%r14),%rdi
call   10b0 <atol@plt>
mov    %eax,0x10(%rsp)
jmp    1223 <main+0x73>
cmp    $0xffffffff,%eax
je     1334 <main+0x184>
cmp    $0x3f,%eax
jne    14a7 <main+0x2f7>
mov    0x2cf2(%rip),%rbx
movzbl (%rbx),%edx
lea    -0x50(%rdx),%eax
cmp    $0x23,%al
ja     142a <main+0x27a>
movzbl %al,%eax
movabs $0x900000001,%rcx
bt     %rax,%rcx
jae    142a <main+0x27a>
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
lea    0xd1b(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%ebx
jmp    148a <main+0x2da>
mov    0x2c9d(%rip),%rax
movslq (%rax),%rax
cmp    %r13d,%eax
jge    1378 <main+0x1c8>
lea    (%r15,%rax,8),%rbp
sub    %eax,%r13d
lea    0xd48(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%rbp,%rbx,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%r13d
jne    1360 <main+0x1b0>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
setne  %al
mov    0x8(%rsp),%ebx
or     %bl,%al
test   $0x1,%al
jne    1397 <main+0x1e7>
lea    0xdad(%rip),%rdi
call   1040 <puts@plt>
test   $0x1,%bl
mov    0x10(%rsp),%r14d
mov    0xc(%rsp),%ebx
je     13af <main+0x1ff>
mov    %r14d,%edi
xor    %esi,%esi
call   1090 <print_params@plt>
test   %ebp,%ebp
je     1426 <main+0x276>
lea    0x14(%rsp),%rsi
mov    %r14d,%edi
call   1090 <print_params@plt>
cmp    $0xffffffff,%r12d
je     144e <main+0x29e>
lea    0xce0(%rip),%rdi
mov    %r14d,%esi
mov    %r12d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2bd1(%rip),%rax
cmp    (%rax),%r12d
jne    1471 <main+0x2c1>
mov    %r14d,%edi
mov    %r12d,%esi
xor    %edx,%edx
call   1050 <set_policy@plt>
mov    %r14d,%edi
mov    %r12d,%esi
jmp    1468 <main+0x2b8>
mov    0x2bb4(%rip),%rax
mov    (%rax),%edi
lea    0xc13(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x2,%ebx
jmp    148a <main+0x2da>
xor    %ebx,%ebx
jmp    148a <main+0x2da>
movsbl %dl,%edi
call   10a0 <isprint@plt>
mov    0x2b87(%rip),%rcx
mov    (%rcx),%edi
movsbl (%rbx),%edx
test   %eax,%eax
je     149b <main+0x2eb>
lea    0xc17(%rip),%rsi
jmp    1323 <main+0x173>
lea    0xc93(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rsp),%esi
mov    %r14d,%edi
mov    %ebx,%edx
call   10d0 <set_priority@plt>
jmp    147e <main+0x2ce>
mov    %r14d,%edi
mov    %r12d,%esi
mov    %ebx,%edx
call   1050 <set_policy@plt>
xor    %ebx,%ebx
mov    %r14d,%edi
xor    %esi,%esi
call   1090 <print_params@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbd5(%rip),%rsi
jmp    1323 <main+0x173>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"sched_pp (V1.0) (c) M.Behr, 2013\0A\00"
@opterr = global i64 0
@.str.1 = [8 x i8] c"gs:p:P:\00"
@optarg = global i8* null
@.str.2 = [11 x i8] c"SCHED_FIFO\00"
@SCHED_FIFO = global i32 0
@.str.3 = [9 x i8] c"SCHED_RR\00"
@SCHED_RR = global i32 0
@.str.4 = [12 x i8] c"SCHED_OTHER\00"
@SCHED_OTHER = global i32 0
@stderr = global i32 0
@.str.5 = [22 x i8] c"Unknown policy <%s>.\0A\00"
@optopt = global i8 0
@.str.6 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.7 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.8 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@optind = global i32 0
@.str.9 = [24 x i8] c"Non-option argument %s\0A\00"
@.str.10 = [92 x i8] c"Usage:\0Asched_pp -p <pid> [-g] [-s <priority>] [-P<policy=SCHED_FIFO|SCHED_RR|SCHED_OTHER>]\0A\00"
@.str.11 = [55 x i8] c"trying to change pid %d to policy %d and priority %d:\0A\00"
@.str.12 = [54 x i8] c"trying to change pid %d to priority %d:\0A Params now:\0A\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 i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i8* null, i8** %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 -1, i32* %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* @opterr
br label %16
16: ; preds = %91, %2
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call i32 @getopt(i32 %17, i8** %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i32 %19, i32* %13
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %92
21: ; preds = %16
%22 = load i32, i32* %13
switch i32 %22, label %89 [
i32 103, label %23
i32 115, label %24
i32 112, label %27
i32 80, label %31
i32 63, label %56
]
23: ; preds = %21
store i32 1, i32* %6
br label %91
24: ; preds = %21
store i32 1, i32* %7
%25 = load i8*, i8** @optarg
%26 = call i32 @atol(i8* %25)
store i32 %26, i32* %10
br label %91
27: ; preds = %21
%28 = load i8*, i8** @optarg
store i8* %28, i8** %8
%29 = load i8*, i8** %8
%30 = call i32 @atol(i8* %29)
store i32 %30, i32* %9
br label %91
31: ; preds = %21
%32 = load i8*, i8** @optarg
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = load i32, i32* @SCHED_FIFO
store i32 %36, i32* %11
br label %55
37: ; preds = %31
%38 = load i8*, i8** @optarg
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %37
%42 = load i32, i32* @SCHED_RR
store i32 %42, i32* %11
br label %54
43: ; preds = %37
%44 = load i8*, i8** @optarg
%45 = call i32 @strcmp(i8* %44, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%46 = icmp ne i32 %45, 0
br i1 %46, label %49, label %47
47: ; preds = %43
%48 = load i32, i32* @SCHED_OTHER
store i32 %48, i32* %11
br label %53
49: ; preds = %43
%50 = load i32, i32* @stderr
%51 = load i8*, i8** @optarg
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %51)
store i32 2, i32* %3
br label %164
53: ; preds = %47
br label %54
54: ; preds = %53, %41
br label %55
55: ; preds = %54, %35
br label %91
56: ; preds = %21
%57 = load i8, i8* @optopt
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 112
br i1 %59, label %68, label %60
60: ; preds = %56
%61 = load i8, i8* @optopt
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 115
br i1 %63, label %68, label %64
64: ; preds = %60
%65 = load i8, i8* @optopt
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 80
br i1 %67, label %68, label %73
68: ; preds = %64, %60, %56
%69 = load i32, i32* @stderr
%70 = load i8, i8* @optopt
%71 = sext i8 %70 to i32
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 %71)
br label %88
73: ; preds = %64
%74 = load i8, i8* @optopt
%75 = call i32 @isprint(i8 signext %74)
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %82
77: ; preds = %73
%78 = load i32, i32* @stderr
%79 = load i8, i8* @optopt
%80 = sext i8 %79 to i32
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %80)
br label %87
82: ; preds = %73
%83 = load i32, i32* @stderr
%84 = load i8, i8* @optopt
%85 = sext i8 %84 to i32
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i32 %85)
br label %87
87: ; preds = %82, %77
br label %88
88: ; preds = %87, %68
store i32 1, i32* %3
br label %164
89: ; preds = %21
%90 = call i32 (...) @abort()
unreachable
91: ; preds = %55, %27, %24, %23
br label %16
92: ; preds = %16
%93 = load i32, i32* @optind
store i32 %93, i32* %12
br label %94
94: ; preds = %105, %92
%95 = load i32, i32* %12
%96 = load i32, i32* %4
%97 = icmp slt i32 %95, %96
br i1 %97, label %98, label %108
98: ; preds = %94
%99 = load i8**, i8*** %5
%100 = load i32, i32* %12
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8*, i8** %99, i64 %101
%103 = load i8*, i8** %102
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %103)
br label %105
105: ; preds = %98
%106 = load i32, i32* %12
%107 = add nsw i32 %106, 1
store i32 %107, i32* %12
br label %94
108: ; preds = %94
%109 = load i32, i32* %6
%110 = icmp ne i32 %109, 0
br i1 %110, label %116, label %111
111: ; preds = %108
%112 = load i32, i32* %7
%113 = icmp ne i32 %112, 0
br i1 %113, label %116, label %114
114: ; preds = %111
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.10, i64 0, i64 0))
br label %116
116: ; preds = %114, %111, %108
%117 = load i32, i32* %6
%118 = icmp ne i32 %117, 0
br i1 %118, label %119, label %122
119: ; preds = %116
%120 = load i32, i32* %9
%121 = call i32 @print_params(i32 %120, i32* null)
br label %122
122: ; preds = %119, %116
%123 = load i32, i32* %7
%124 = icmp ne i32 %123, 0
br i1 %124, label %125, label %163
125: ; preds = %122
%126 = load i32, i32* %9
%127 = call i32 @print_params(i32 %126, i32* %14)
%128 = load i32, i32* %11
%129 = icmp ne i32 %128, -1
br i1 %129, label %130, label %152
130: ; preds = %125
%131 = load i32, i32* %9
%132 = load i32, i32* %11
%133 = load i32, i32* %10
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.11, i64 0, i64 0), i32 %131, i32 %132, i32 %133)
%135 = load i32, i32* %11
%136 = load i32, i32* @SCHED_OTHER
%137 = icmp ne i32 %135, %136
br i1 %137, label %138, label %143
138: ; preds = %130
%139 = load i32, i32* %9
%140 = load i32, i32* %11
%141 = load i32, i32* %10
%142 = call i32 @set_policy(i32 %139, i32 %140, i32 %141)
br label %151
143: ; preds = %130
%144 = load i32, i32* %9
%145 = load i32, i32* %11
%146 = call i32 @set_policy(i32 %144, i32 %145, i32 0)
%147 = load i32, i32* %9
%148 = load i32, i32* %11
%149 = load i32, i32* %10
%150 = call i32 @set_priority(i32 %147, i32 %148, i32 %149)
br label %151
151: ; preds = %143, %138
br label %160
152: ; preds = %125
%153 = load i32, i32* %9
%154 = load i32, i32* %10
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.12, i64 0, i64 0), i32 %153, i32 %154)
%156 = load i32, i32* %9
%157 = load i32, i32* %14
%158 = load i32, i32* %10
%159 = call i32 @set_priority(i32 %156, i32 %157, i32 %158)
br label %160
160: ; preds = %152, %151
%161 = load i32, i32* %9
%162 = call i32 @print_params(i32 %161, i32* null)
br label %163
163: ; preds = %160, %122
store i32 0, i32* %3
br label %164
164: ; preds = %163, %88, %49
%165 = load i32, i32* %3
ret i32 %165
}

LLVM IR (-O2):
@opterr = global i64 0
@.str.1 = [8 x i8] c"gs:p:P:\00"
@optarg = global i8* null
@.str.2 = [11 x i8] c"SCHED_FIFO\00"
@SCHED_FIFO = global i32 0
@.str.3 = [9 x i8] c"SCHED_RR\00"
@SCHED_RR = global i32 0
@.str.4 = [12 x i8] c"SCHED_OTHER\00"
@SCHED_OTHER = global i32 0
@stderr = global i32 0
@.str.5 = [22 x i8] c"Unknown policy <%s>.\0A\00"
@optopt = global i8 0
@.str.6 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.7 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.8 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@optind = global i32 0
@.str.9 = [24 x i8] c"Non-option argument %s\0A\00"
@.str.11 = [55 x i8] c"trying to change pid %d to policy %d and priority %d:\0A\00"
@.str.12 = [54 x i8] c"trying to change pid %d to priority %d:\0A Params now:\0A\00"
@str = [33 x i8] c"sched_pp (V1.0) (c) M.Behr, 2013\00"
@str.13 = [91 x i8] c"Usage:\0Asched_pp -p <pid> [-g] [-s <priority>] [-P<policy=SCHED_FIFO|SCHED_RR|SCHED_OTHER>]\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
store i64 0, i64* @opterr
br label %5
5: ; preds = %19, %2
%6 = phi i1 [ false, %2 ], [ true, %19 ]
%7 = phi i32 [ 0, %2 ], [ %12, %19 ]
%8 = phi i32 [ 0, %2 ], [ %17, %19 ]
%9 = phi i32 [ 0, %2 ], [ %14, %19 ]
%10 = phi i32 [ -1, %2 ], [ %20, %19 ]
br label %11
11: ; preds = %5, %22
%12 = phi i32 [ %7, %5 ], [ 1, %22 ]
%13 = phi i32 [ %8, %5 ], [ %17, %22 ]
%14 = phi i32 [ %9, %5 ], [ %24, %22 ]
%15 = phi i32 [ %10, %5 ], [ %20, %22 ]
br label %16
16: ; preds = %11, %25
%17 = phi i32 [ %13, %11 ], [ %27, %25 ]
%18 = phi i32 [ %15, %11 ], [ %20, %25 ]
br label %19
19: ; preds = %32, %16
%20 = phi i32 [ %18, %16 ], [ %34, %32 ]
%21 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
switch i32 %21, label %60 [
i32 -1, label %62
i32 103, label %5
i32 115, label %22
i32 112, label %25
i32 80, label %28
i32 63, label %44
]
22: ; preds = %19
%23 = load i8*, i8** @optarg
%24 = tail call i32 @atol(i8* %23)
br label %11
25: ; preds = %19
%26 = load i8*, i8** @optarg
%27 = tail call i32 @atol(i8* %26)
br label %16
28: ; preds = %19
%29 = load i8*, i8** @optarg
%30 = tail call i32 @strcmp(i8* dereferenceable(1) %29, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %38, %35, %28
%33 = phi i32* [ @SCHED_FIFO, %28 ], [ @SCHED_RR, %35 ], [ @SCHED_OTHER, %38 ]
%34 = load i32, i32* %33
br label %19
35: ; preds = %28
%36 = tail call i32 @strcmp(i8* dereferenceable(1) %29, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp eq i32 %36, 0
br i1 %37, label %32, label %38
38: ; preds = %35
%39 = tail call i32 @strcmp(i8* dereferenceable(1) %29, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%40 = icmp eq i32 %39, 0
br i1 %40, label %32, label %41
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %29)
br label %103
44: ; preds = %19
%45 = load i8, i8* @optopt
switch i8 %45, label %50 [
i8 115, label %46
i8 112, label %46
i8 80, label %46
]
46: ; preds = %44, %44, %44
%47 = zext i8 %45 to i32
%48 = load i32, i32* @stderr
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 %47)
br label %103
50: ; preds = %44
%51 = tail call i32 @isprint(i8 signext %45)
%52 = icmp eq i32 %51, 0
%53 = load i32, i32* @stderr
%54 = load i8, i8* @optopt
%55 = sext i8 %54 to i32
br i1 %52, label %58, label %56
56: ; preds = %50
%57 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %55)
br label %103
58: ; preds = %50
%59 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i32 %55)
br label %103
60: ; preds = %19
%61 = tail call i32 (...) @abort()
unreachable
62: ; preds = %19
%63 = load i32, i32* @optind
%64 = icmp slt i32 %63, %0
br i1 %64, label %65, label %75
65: ; preds = %62
%66 = sext i32 %63 to i64
br label %67
67: ; preds = %65, %67
%68 = phi i64 [ %66, %65 ], [ %72, %67 ]
%69 = getelementptr inbounds i8*, i8** %1, i64 %68
%70 = load i8*, i8** %69
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %70)
%72 = add nsw i64 %68, 1
%73 = trunc i64 %72 to i32
%74 = icmp eq i32 %73, %0
br i1 %74, label %75, label %67
75: ; preds = %67, %62
%76 = icmp ne i32 %12, 0
%77 = select i1 %6, i1 true, i1 %76
br i1 %77, label %80, label %78
78: ; preds = %75
%79 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str.13, i64 0, i64 0))
br label %80
80: ; preds = %78, %75
br i1 %6, label %81, label %83
81: ; preds = %80
%82 = tail call i32 @print_params(i32 %17, i32* null)
br label %83
83: ; preds = %81, %80
br i1 %76, label %84, label %103
84: ; preds = %83
%85 = bitcast i32* %3 to i8*
%86 = call i32 @print_params(i32 %17, i32* %3)
%87 = icmp eq i32 %20, -1
br i1 %87, label %97, label %88
88: ; preds = %84
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.11, i64 0, i64 0), i32 %17, i32 %20, i32 %14)
%90 = load i32, i32* @SCHED_OTHER
%91 = icmp eq i32 %20, %90
br i1 %91, label %94, label %92
92: ; preds = %88
%93 = call i32 @set_policy(i32 %17, i32 %20, i32 %14)
br label %101
94: ; preds = %88
%95 = call i32 @set_policy(i32 %17, i32 %20, i32 0)
%96 = call i32 @set_priority(i32 %17, i32 %20, i32 %14)
br label %101
97: ; preds = %84
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.12, i64 0, i64 0), i32 %17, i32 %14)
%99 = load i32, i32* %3
%100 = call i32 @set_priority(i32 %17, i32 %99, i32 %14)
br label %101
101: ; preds = %92, %94, %97
%102 = call i32 @print_params(i32 %17, i32* null)
br label %103
103: ; preds = %83, %101, %46, %58, %56, %41
%104 = phi i32 [ 2, %41 ], [ 1, %56 ], [ 1, %58 ], [ 1, %46 ], [ 0, %101 ], [ 0, %83 ]
ret i32 %104
}