#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 */
struct sched_param {
  int sched_priority;
};

/* Variables and functions */
int EINVAL;
int EPERM;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ child_proc();
int errno;
int fork();
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int sched_get_priority_max(int);
int sched_get_priority_min(int);
scalar_t__ sched_getparam(int, struct sched_param *);
int sched_getscheduler(int /*<<< orphan*/);
int sched_setparam(int, struct sched_param *);
int main(void) {
  int result, child_pid, tmp_errno, policy;
  int min_priority, new_priority, old_priority;
  struct sched_param param;
  child_pid = fork();
  if (child_pid == -1) {
    perror("An error occurs when calling fork()");
    return 2;
  } else if (child_pid == 0) {
    child_proc();
  }
  if (sched_getparam(child_pid, &param) != 0) {
    perror("An error occurs when calling sched_getparam()");
    kill(child_pid, SIGUSR1);
    return 2;
  }
  old_priority = param.sched_priority;
  policy = sched_getscheduler(0);
  if (policy == -1) {
    perror("An error occurs when calling sched_getscheduler()");
    return 2;
  }
  min_priority = sched_get_priority_min(policy);
  new_priority = param.sched_priority == min_priority
                     ? (param.sched_priority = sched_get_priority_max(policy))
                     : (param.sched_priority = min_priority);
  result = sched_setparam(child_pid, &param);
  tmp_errno = errno;
  if (sched_getparam(child_pid, &param) != 0) {
    perror("An error occurs when calling sched_getparam()");
    kill(child_pid, SIGUSR1);
    return 2;
  }
  if (result == 0 && param.sched_priority == new_priority) {
    printf("Test PASSED\n");
    kill(child_pid, SIGUSR1);
    return 0;
  } else if (result == 0 && param.sched_priority == old_priority) {
    printf("The param does not change.\n");
    kill(child_pid, SIGUSR1);
    return 1;
  } else if (result == -1 && tmp_errno == EPERM) {
    printf(
        "The process have not permission to change the param of its child.\n");
    kill(child_pid, SIGUSR1);
    return 2;
  } else if (result == -1 && tmp_errno == EINVAL) {
    param.sched_priority = (new_priority -= 2);
    result = sched_setparam(child_pid, &param);
    if (result == 0 && param.sched_priority == new_priority) {
      printf("Test PASSED");
      kill(child_pid, SIGUSR1);
      return 0;
    }
  }
  perror("Unknow error");
  kill(child_pid, SIGUSR1);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10c0 <fork@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11db <main+0x3b>
lea    0xe36(%rip),%rdi
call   1090 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    1466 <main+0x2c6>
cmpl   $0x0,-0xc(%rbp)
jne    11ec <main+0x4c>
mov    $0x0,%al
call   1080 <child_proc@plt>
jmp    11f1 <main+0x51>
mov    -0xc(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1050 <sched_getparam@plt>
cmp    $0x0,%rax
je     1230 <main+0x90>
lea    0xe16(%rip),%rdi
call   1090 <perror@plt>
mov    -0xc(%rbp),%edi
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
movl   $0x2,-0x4(%rbp)
jmp    1466 <main+0x2c6>
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
xor    %edi,%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1262 <main+0xc2>
lea    0xe01(%rip),%rdi
call   1090 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    1466 <main+0x2c6>
mov    -0x14(%rbp),%edi
call   1070 <sched_get_priority_min@plt>
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    128c <main+0xec>
mov    -0x14(%rbp),%edi
call   10b0 <sched_get_priority_max@plt>
mov    %eax,-0x28(%rbp)
mov    %eax,-0x2c(%rbp)
jmp    1295 <main+0xf5>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   10a0 <sched_setparam@plt>
mov    %eax,-0x8(%rbp)
mov    0x2d27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1050 <sched_getparam@plt>
cmp    $0x0,%rax
je     12f5 <main+0x155>
lea    0xd51(%rip),%rdi
call   1090 <perror@plt>
mov    -0xc(%rbp),%edi
mov    0x2d06(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
movl   $0x2,-0x4(%rbp)
jmp    1466 <main+0x2c6>
cmpl   $0x0,-0x8(%rbp)
jne    1334 <main+0x194>
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1334 <main+0x194>
lea    0xd72(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
mov    0x2cc7(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
movl   $0x0,-0x4(%rbp)
jmp    1466 <main+0x2c6>
cmpl   $0x0,-0x8(%rbp)
jne    1373 <main+0x1d3>
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1373 <main+0x1d3>
lea    0xd40(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
mov    0x2c88(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
movl   $0x1,-0x4(%rbp)
jmp    1466 <main+0x2c6>
cmpl   $0xffffffff,-0x8(%rbp)
jne    13b8 <main+0x218>
mov    -0x10(%rbp),%eax
mov    0x2c39(%rip),%rcx
cmp    (%rcx),%eax
jne    13b8 <main+0x218>
lea    0xd17(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
mov    0x2c43(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
movl   $0x2,-0x4(%rbp)
jmp    1466 <main+0x2c6>
cmpl   $0xffffffff,-0x8(%rbp)
jne    1433 <main+0x293>
mov    -0x10(%rbp),%eax
mov    0x2c04(%rip),%rcx
cmp    (%rcx),%eax
jne    1433 <main+0x293>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   10a0 <sched_setparam@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    142e <main+0x28e>
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    142e <main+0x28e>
lea    0xce4(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
mov    0x2bcd(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
movl   $0x0,-0x4(%rbp)
jmp    1466 <main+0x2c6>
jmp    1433 <main+0x293>
jmp    1438 <main+0x298>
jmp    143d <main+0x29d>
jmp    1442 <main+0x2a2>
lea    0xcb3(%rip),%rdi
call   1090 <perror@plt>
mov    -0xc(%rbp),%edi
mov    0x2b90(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   10d0 <fork@plt>
mov    %eax,%r14d
test   %eax,%eax
je     11db <main+0x2b>
cmp    $0xffffffff,%r14d
jne    11e2 <main+0x32>
lea    0xe2a(%rip),%rdi
jmp    1330 <main+0x180>
xor    %eax,%eax
call   1090 <child_proc@plt>
mov    %rsp,%rsi
mov    %r14d,%edi
call   1060 <sched_getparam@plt>
test   %rax,%rax
jne    12ce <main+0x11e>
mov    (%rsp),%r12d
xor    %edi,%edi
call   1030 <sched_getscheduler@plt>
cmp    $0xffffffff,%eax
je     1329 <main+0x179>
mov    %eax,%ebx
mov    %eax,%edi
call   1080 <sched_get_priority_min@plt>
mov    %eax,%ebp
cmp    %eax,(%rsp)
jne    1223 <main+0x73>
mov    %ebx,%edi
call   10c0 <sched_get_priority_max@plt>
mov    %eax,%ebp
mov    %ebp,(%rsp)
mov    %rsp,%r15
mov    %r14d,%edi
mov    %r15,%rsi
call   10b0 <sched_setparam@plt>
mov    %eax,%ebx
mov    0x2d9b(%rip),%rax
mov    (%rax),%r13d
mov    %r14d,%edi
mov    %r15,%rsi
call   1060 <sched_getparam@plt>
test   %rax,%rax
jne    12ce <main+0x11e>
mov    (%rsp),%eax
test   %ebx,%ebx
jne    127f <main+0xcf>
cmp    %ebp,%eax
jne    127f <main+0xcf>
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
call   1070 <kill@plt>
xor    %eax,%eax
jmp    133a <main+0x18a>
test   %ebx,%ebx
jne    12af <main+0xff>
cmp    %r12d,%eax
jne    12af <main+0xff>
lea    0xe44(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
call   1070 <kill@plt>
mov    $0x1,%eax
jmp    133a <main+0x18a>
cmp    $0xffffffff,%ebx
jne    12ed <main+0x13d>
mov    0x2d05(%rip),%rax
cmp    (%rax),%r13d
jne    12ed <main+0x13d>
lea    0xdca(%rip),%rdi
call   1040 <puts@plt>
jmp    12da <main+0x12a>
lea    0xd4f(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2d07(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
call   1070 <kill@plt>
jmp    1335 <main+0x185>
cmp    $0xffffffff,%ebx
jne    1349 <main+0x199>
mov    0x2cd7(%rip),%rax
cmp    (%rax),%r13d
jne    1349 <main+0x199>
add    $0xfffffffe,%ebp
mov    %ebp,(%rsp)
mov    %rsp,%rsi
mov    %r14d,%edi
call   10b0 <sched_setparam@plt>
test   %eax,%eax
jne    1349 <main+0x199>
cmp    %ebp,(%rsp)
jne    1349 <main+0x199>
lea    0xdcf(%rip),%rdi
call   1050 <printf@plt>
jmp    1267 <main+0xb7>
lea    0xd22(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x2,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd34(%rip),%rdi
call   10a0 <perror@plt>
jmp    1294 <main+0xe4>

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@.str = [36 x i8] c"An error occurs when calling fork()\00"
@.str.1 = [46 x i8] c"An error occurs when calling sched_getparam()\00"
@SIGUSR1 = global i32 0
@.str.2 = [50 x i8] c"An error occurs when calling sched_getscheduler()\00"
@errno = global i32 0
@.str.3 = [13 x i8] c"Test PASSED\0A\00"
@.str.4 = [28 x i8] c"The param does not change.\0A\00"
@EPERM = global i32 0
@.str.5 = [67 x i8] c"The process have not permission to change the param of its child.\0A\00"
@EINVAL = global i32 0
@.str.6 = [12 x i8] c"Test PASSED\00"
@.str.7 = [13 x i8] c"Unknow error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sched_param
store i32 0, i32* %1
%10 = call i32 (...) @fork()
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %1
br label %137
15: ; preds = %0
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (...) @child_proc()
br label %20
20: ; preds = %18, %15
br label %21
21: ; preds = %20
%22 = load i32, i32* %3
%23 = call i64 @sched_getparam(i32 %22, %struct.sched_param* %9)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* %3
%28 = load i32, i32* @SIGUSR1
%29 = call i32 @kill(i32 %27, i32 %28)
store i32 2, i32* %1
br label %137
30: ; preds = %21
%31 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %9, i32 0, i32 0
%32 = load i32, i32* %31
store i32 %32, i32* %8
%33 = call i32 @sched_getscheduler(i32 0)
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = call i32 @perror(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %1
br label %137
38: ; preds = %30
%39 = load i32, i32* %5
%40 = call i32 @sched_get_priority_min(i32 %39)
store i32 %40, i32* %6
%41 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %9, i32 0, i32 0
%42 = load i32, i32* %41
%43 = load i32, i32* %6
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %49
45: ; preds = %38
%46 = load i32, i32* %5
%47 = call i32 @sched_get_priority_max(i32 %46)
%48 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %9, i32 0, i32 0
store i32 %47, i32* %48
br label %52
49: ; preds = %38
%50 = load i32, i32* %6
%51 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %9, i32 0, i32 0
store i32 %50, i32* %51
br label %52
52: ; preds = %49, %45
%53 = phi i32 [ %47, %45 ], [ %50, %49 ]
store i32 %53, i32* %7
%54 = load i32, i32* %3
%55 = call i32 @sched_setparam(i32 %54, %struct.sched_param* %9)
store i32 %55, i32* %2
%56 = load i32, i32* @errno
store i32 %56, i32* %4
%57 = load i32, i32* %3
%58 = call i64 @sched_getparam(i32 %57, %struct.sched_param* %9)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %52
%61 = call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%62 = load i32, i32* %3
%63 = load i32, i32* @SIGUSR1
%64 = call i32 @kill(i32 %62, i32 %63)
store i32 2, i32* %1
br label %137
65: ; preds = %52
%66 = load i32, i32* %2
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %78
68: ; preds = %65
%69 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %9, i32 0, i32 0
%70 = load i32, i32* %69
%71 = load i32, i32* %7
%72 = icmp eq i32 %70, %71
br i1 %72, label %73, label %78
73: ; preds = %68
%74 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%75 = load i32, i32* %3
%76 = load i32, i32* @SIGUSR1
%77 = call i32 @kill(i32 %75, i32 %76)
store i32 0, i32* %1
br label %137
78: ; preds = %68, %65
%79 = load i32, i32* %2
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %91
81: ; preds = %78
%82 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %9, i32 0, i32 0
%83 = load i32, i32* %82
%84 = load i32, i32* %8
%85 = icmp eq i32 %83, %84
br i1 %85, label %86, label %91
86: ; preds = %81
%87 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%88 = load i32, i32* %3
%89 = load i32, i32* @SIGUSR1
%90 = call i32 @kill(i32 %88, i32 %89)
store i32 1, i32* %1
br label %137
91: ; preds = %81, %78
%92 = load i32, i32* %2
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %103
94: ; preds = %91
%95 = load i32, i32* %4
%96 = load i32, i32* @EPERM
%97 = icmp eq i32 %95, %96
br i1 %97, label %98, label %103
98: ; preds = %94
%99 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.5, i64 0, i64 0))
%100 = load i32, i32* %3
%101 = load i32, i32* @SIGUSR1
%102 = call i32 @kill(i32 %100, i32 %101)
store i32 2, i32* %1
br label %137
103: ; preds = %94, %91
%104 = load i32, i32* %2
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %129
106: ; preds = %103
%107 = load i32, i32* %4
%108 = load i32, i32* @EINVAL
%109 = icmp eq i32 %107, %108
br i1 %109, label %110, label %129
110: ; preds = %106
%111 = load i32, i32* %7
%112 = sub nsw i32 %111, 2
store i32 %112, i32* %7
%113 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %9, i32 0, i32 0
store i32 %112, i32* %113
%114 = load i32, i32* %3
%115 = call i32 @sched_setparam(i32 %114, %struct.sched_param* %9)
store i32 %115, i32* %2
%116 = load i32, i32* %2
%117 = icmp eq i32 %116, 0
br i1 %117, label %118, label %128
118: ; preds = %110
%119 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %9, i32 0, i32 0
%120 = load i32, i32* %119
%121 = load i32, i32* %7
%122 = icmp eq i32 %120, %121
br i1 %122, label %123, label %128
123: ; preds = %118
%124 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%125 = load i32, i32* %3
%126 = load i32, i32* @SIGUSR1
%127 = call i32 @kill(i32 %125, i32 %126)
store i32 0, i32* %1
br label %137
128: ; preds = %118, %110
br label %129
129: ; preds = %128, %106, %103
br label %130
130: ; preds = %129
br label %131
131: ; preds = %130
br label %132
132: ; preds = %131
%133 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%134 = load i32, i32* %3
%135 = load i32, i32* @SIGUSR1
%136 = call i32 @kill(i32 %134, i32 %135)
store i32 1, i32* %1
br label %137
137: ; preds = %132, %123, %98, %86, %73, %60, %36, %25, %13
%138 = load i32, i32* %1
ret i32 %138
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@.str = [36 x i8] c"An error occurs when calling fork()\00"
@.str.1 = [46 x i8] c"An error occurs when calling sched_getparam()\00"
@SIGUSR1 = global i32 0
@.str.2 = [50 x i8] c"An error occurs when calling sched_getscheduler()\00"
@errno = global i32 0
@EPERM = global i32 0
@EINVAL = global i32 0
@.str.7 = [13 x i8] c"Unknow error\00"
@str = [66 x i8] c"The process have not permission to change the param of its child.\00"
@str.8 = [27 x i8] c"The param does not change.\00"
@str.9 = [12 x i8] c"Test PASSED\00"
define i32 @main() {
%1 = alloca %struct.sched_param
%2 = bitcast %struct.sched_param* %1 to i8*
%3 = tail call i32 (...) @fork()
switch i32 %3, label %8 [
i32 -1, label %4
i32 0, label %6
]
4: ; preds = %0
%5 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %82
6: ; preds = %0
%7 = tail call i32 (...) @child_proc()
br label %8
8: ; preds = %0, %6
%9 = call i64 @sched_getparam(i32 %3, %struct.sched_param* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @SIGUSR1
%14 = call i32 @kill(i32 %3, i32 %13)
br label %82
15: ; preds = %8
%16 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %1, i64 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @sched_getscheduler(i32 0)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 @perror(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
br label %82
22: ; preds = %15
%23 = call i32 @sched_get_priority_min(i32 %18)
%24 = load i32, i32* %16
%25 = icmp eq i32 %24, %23
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @sched_get_priority_max(i32 %18)
br label %28
28: ; preds = %22, %26
%29 = phi i32 [ %27, %26 ], [ %23, %22 ]
store i32 %29, i32* %16
%30 = call i32 @sched_setparam(i32 %3, %struct.sched_param* %1)
%31 = load i32, i32* @errno
%32 = call i64 @sched_getparam(i32 %3, %struct.sched_param* %1)
%33 = icmp eq i64 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %28
%35 = call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* @SIGUSR1
%37 = call i32 @kill(i32 %3, i32 %36)
br label %82
38: ; preds = %28
%39 = icmp eq i32 %30, 0
%40 = load i32, i32* %16
%41 = icmp eq i32 %40, %29
%42 = select i1 %39, i1 %41, i1 false
br i1 %42, label %43, label %47
43: ; preds = %38
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.9, i64 0, i64 0))
%45 = load i32, i32* @SIGUSR1
%46 = call i32 @kill(i32 %3, i32 %45)
br label %82
47: ; preds = %38
%48 = icmp eq i32 %40, %17
%49 = select i1 %39, i1 %48, i1 false
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0))
%52 = load i32, i32* @SIGUSR1
%53 = call i32 @kill(i32 %3, i32 %52)
br label %82
54: ; preds = %47
%55 = icmp eq i32 %30, -1
%56 = load i32, i32* @EPERM
%57 = icmp eq i32 %31, %56
%58 = select i1 %55, i1 %57, i1 false
br i1 %58, label %59, label %63
59: ; preds = %54
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
%61 = load i32, i32* @SIGUSR1
%62 = call i32 @kill(i32 %3, i32 %61)
br label %82
63: ; preds = %54
%64 = load i32, i32* @EINVAL
%65 = icmp eq i32 %31, %64
%66 = select i1 %55, i1 %65, i1 false
br i1 %66, label %67, label %78
67: ; preds = %63
%68 = add nsw i32 %29, -2
store i32 %68, i32* %16
%69 = call i32 @sched_setparam(i32 %3, %struct.sched_param* %1)
%70 = icmp eq i32 %69, 0
%71 = load i32, i32* %16
%72 = icmp eq i32 %71, %68
%73 = select i1 %70, i1 %72, i1 false
br i1 %73, label %74, label %78
74: ; preds = %67
%75 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.9, i64 0, i64 0))
%76 = load i32, i32* @SIGUSR1
%77 = call i32 @kill(i32 %3, i32 %76)
br label %82
78: ; preds = %63, %67
%79 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%80 = load i32, i32* @SIGUSR1
%81 = call i32 @kill(i32 %3, i32 %80)
br label %82
82: ; preds = %78, %74, %59, %50, %43, %34, %20, %11, %4
%83 = phi i32 [ 2, %4 ], [ 2, %11 ], [ 2, %20 ], [ 2, %34 ], [ 0, %43 ], [ 1, %50 ], [ 2, %59 ], [ 0, %74 ], [ 1, %78 ]
ret i32 %83
}