#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 /*<<< orphan*/ sched_priority;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ SCHED_FIFO;
int SIGTERM;
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
int WTERMSIG(int);
int /*<<< orphan*/ child_busy(int);
int /*<<< orphan*/ errno;
int fork();
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ kill(int, int);
int pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ sched_get_priority_min(int /*<<< orphan*/);
int sched_setscheduler(int /*<<< orphan*/, int /*<<< orphan*/,
                       struct sched_param *);
int set_affinity_single();
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int main(void) {
  int pid;
  int rc;
  int pfd[2];
  int status = 2;
  int s;
  struct sched_param sp;
  char buf[8];
  rc = pipe(pfd);
  if (rc) {
    printf("Failed: %s rc: %d errno: %s\n", "pipe", rc, strerror(errno));
    return status;
  }
  sp.sched_priority = sched_get_priority_min(SCHED_FIFO);
  rc = sched_setscheduler(getpid(), SCHED_FIFO, &sp);
  if (rc) {
    printf("Failed: %s rc: %d errno: %s\n", "sched_setscheduler", rc,
           strerror(errno));
    return status;
  }
  rc = set_affinity_single();
  if (rc) {
    printf("Failed: %s rc: %d errno: %s\n", "set_affinity_single", rc,
           strerror(errno));
    return status;
  }
  pid = fork();
  if (pid == 0)
    child_busy(pfd[1]);
  if (pid < 0) {
    printf("Failed: %s rc: %d errno: %s\n", "fork", rc, strerror(errno));
    return status;
  }
  rc = read(pfd[0], buf, sizeof(buf));
  if (rc != 2) {
    kill(pid, SIGTERM);
    waitpid(pid, NULL, 0);
    printf("Failed: %s rc: %d errno: %s\n", "read", rc, strerror(errno));
    return status;
  }
  kill(pid, SIGTERM);
  waitpid(pid, &s, 0);
  status = 0;
  if (WIFSIGNALED(s)) {
    s = WTERMSIG(s);
    if (s != SIGTERM) {
      printf("Failed: kill signal: %d, should be: %d\n", s, SIGTERM);
      status = 1;
    }
  } else if (WIFEXITED(s)) {
    printf("Failed: child prematurely exited with: %d\n", WEXITSTATUS(s));
    status = 1;
  }
  if (status == 0)
    printf("Test PASSED\n");
  return status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x18(%rbp)
lea    -0x14(%rbp),%rdi
call   1060 <pipe@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1266 <main+0x66>
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x2c(%rbp),%edx
mov    %rax,%rcx
lea    0xdb3(%rip),%rdi
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14cd <main+0x2cd>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
call   10b0 <sched_get_priority_min@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
mov    0x2d59(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1050 <sched_setscheduler@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     12d9 <main+0xd9>
mov    -0xc(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x30(%rbp),%edx
mov    %rax,%rcx
lea    0xd40(%rip),%rdi
lea    0xd5b(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14cd <main+0x2cd>
mov    $0x0,%al
call   1090 <set_affinity_single@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1327 <main+0x127>
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x34(%rbp),%edx
mov    %rax,%rcx
lea    0xcf2(%rip),%rdi
lea    0xd20(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14cd <main+0x2cd>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1343 <main+0x143>
mov    -0x10(%rbp),%edi
call   10d0 <child_busy@plt>
cmpl   $0x0,-0x8(%rbp)
jge    1387 <main+0x187>
mov    -0xc(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c76(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x38(%rbp),%edx
mov    %rax,%rcx
lea    0xc92(%rip),%rdi
lea    0xcd4(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14cd <main+0x2cd>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x8,%edx
call   1070 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
je     13fe <main+0x1fe>
mov    -0x8(%rbp),%edi
mov    0x2c39(%rip),%rax
mov    (%rax),%esi
call   10a0 <kill@plt>
mov    -0x8(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10f0 <waitpid@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2bff(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x3c(%rbp),%edx
mov    %rax,%rcx
lea    0xc1b(%rip),%rdi
lea    0xc62(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14cd <main+0x2cd>
mov    -0x8(%rbp),%edi
mov    0x2be0(%rip),%rax
mov    (%rax),%esi
call   10a0 <kill@plt>
mov    -0x8(%rbp),%edi
lea    -0x1c(%rbp),%rsi
xor    %edx,%edx
call   10f0 <waitpid@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x1c(%rbp),%edi
call   1080 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     1479 <main+0x279>
mov    -0x1c(%rbp),%edi
call   10c0 <WTERMSIG@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2b9d(%rip),%rcx
cmp    (%rcx),%eax
je     1474 <main+0x274>
mov    -0x1c(%rbp),%esi
mov    0x2b8b(%rip),%rax
mov    (%rax),%edx
lea    0xbed(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    14af <main+0x2af>
mov    -0x1c(%rbp),%edi
call   1100 <WIFEXITED@plt>
cmp    $0x0,%rax
je     14aa <main+0x2aa>
mov    -0x1c(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xbdf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    14af <main+0x2af>
cmpl   $0x0,-0x18(%rbp)
jne    14c7 <main+0x2c7>
lea    0xbe6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0x10(%rsp),%rdi
call   1070 <pipe@plt>
test   %eax,%eax
je     1246 <main+0x36>
mov    %eax,%ebx
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xdc3(%rip),%rdi
lea    0xdd9(%rip),%rsi
jmp    12ba <main+0xaa>
mov    0x2d93(%rip),%rbx
mov    (%rbx),%edi
call   10c0 <sched_get_priority_min@plt>
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1040 <getpid@plt>
mov    (%rbx),%esi
lea    0x8(%rsp),%rdx
mov    %eax,%edi
call   1060 <sched_setscheduler@plt>
test   %eax,%eax
je     1291 <main+0x81>
mov    %eax,%ebx
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xd78(%rip),%rdi
lea    0xd93(%rip),%rsi
jmp    12ba <main+0xaa>
xor    %eax,%eax
call   10a0 <set_affinity_single@plt>
test   %eax,%eax
je     12d4 <main+0xc4>
mov    %eax,%ebx
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xd4d(%rip),%rdi
lea    0xd7b(%rip),%rsi
mov    %ebx,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
call   1130 <fork@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1303 <main+0xf3>
jns    130c <main+0xfc>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xd08(%rip),%rdi
lea    0xd4a(%rip),%rsi
xor    %edx,%edx
jmp    12bc <main+0xac>
mov    0x14(%rsp),%edi
call   10e0 <child_busy@plt>
mov    0x10(%rsp),%edi
lea    0x18(%rsp),%rsi
mov    $0x8,%edx
call   1080 <read@plt>
mov    %eax,%ebp
mov    0x2cc0(%rip),%r14
mov    (%r14),%esi
mov    %ebx,%edi
call   10b0 <kill@plt>
cmp    $0x2,%ebp
jne    1381 <main+0x171>
lea    0x4(%rsp),%rsi
mov    %ebx,%edi
xor    %edx,%edx
call   1100 <waitpid@plt>
mov    0x4(%rsp),%edi
call   1090 <WIFSIGNALED@plt>
mov    0x4(%rsp),%edi
test   %rax,%rax
je     13af <main+0x19f>
call   10d0 <WTERMSIG@plt>
mov    %eax,0x4(%rsp)
mov    (%r14),%edx
cmp    %edx,%eax
je     13dc <main+0x1cc>
lea    0xce5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%eax
jmp    12cb <main+0xbb>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1100 <waitpid@plt>
mov    0x2c3d(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xc5f(%rip),%rdi
lea    0xca6(%rip),%rsi
mov    %ebp,%edx
jmp    12bc <main+0xac>
call   1110 <WIFEXITED@plt>
test   %rax,%rax
je     13dc <main+0x1cc>
mov    0x4(%rsp),%edi
call   10f0 <WEXITSTATUS@plt>
lea    0xcb2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%eax
jmp    12cb <main+0xbb>
lea    0xcc3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    12cb <main+0xbb>

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@.str = [29 x i8] c"Failed: %s rc: %d errno: %s\0A\00"
@.str.1 = [5 x i8] c"pipe\00"
@errno = global i32 0
@SCHED_FIFO = global i32 0
@.str.2 = [19 x i8] c"sched_setscheduler\00"
@.str.3 = [20 x i8] c"set_affinity_single\00"
@.str.4 = [5 x i8] c"fork\00"
@SIGTERM = global i32 0
@.str.5 = [5 x i8] c"read\00"
@.str.6 = [40 x i8] c"Failed: kill signal: %d, should be: %d\0A\00"
@.str.7 = [43 x i8] c"Failed: child prematurely exited with: %d\0A\00"
@.str.8 = [13 x i8] c"Test PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.sched_param
%8 = alloca [8 x i8]
store i32 0, i32* %1
store i32 2, i32* %5
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%10 = call i32 @pipe(i32* %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %0
%14 = load i32, i32* %3
%15 = load i32, i32* @errno
%16 = call i8* @strerror(i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* %16)
%18 = load i32, i32* %5
store i32 %18, i32* %1
br label %115
19: ; preds = %0
%20 = load i32, i32* @SCHED_FIFO
%21 = call i32 @sched_get_priority_min(i32 %20)
%22 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %7, i32 0, i32 0
store i32 %21, i32* %22
%23 = call i32 (...) @getpid()
%24 = load i32, i32* @SCHED_FIFO
%25 = call i32 @sched_setscheduler(i32 %23, i32 %24, %struct.sched_param* %7)
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %19
%29 = load i32, i32* %3
%30 = load i32, i32* @errno
%31 = call i8* @strerror(i32 %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %29, i8* %31)
%33 = load i32, i32* %5
store i32 %33, i32* %1
br label %115
34: ; preds = %19
%35 = call i32 (...) @set_affinity_single()
store i32 %35, i32* %3
%36 = load i32, i32* %3
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %34
%39 = load i32, i32* %3
%40 = load i32, i32* @errno
%41 = call i8* @strerror(i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %39, i8* %41)
%43 = load i32, i32* %5
store i32 %43, i32* %1
br label %115
44: ; preds = %34
%45 = call i32 (...) @fork()
store i32 %45, i32* %2
%46 = load i32, i32* %2
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%50 = load i32, i32* %49
%51 = call i32 @child_busy(i32 %50)
br label %52
52: ; preds = %48, %44
%53 = load i32, i32* %2
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %61
55: ; preds = %52
%56 = load i32, i32* %3
%57 = load i32, i32* @errno
%58 = call i8* @strerror(i32 %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %56, i8* %58)
%60 = load i32, i32* %5
store i32 %60, i32* %1
br label %115
61: ; preds = %52
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%63 = load i32, i32* %62
%64 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%65 = call i32 @read(i32 %63, i8* %64, i32 8)
store i32 %65, i32* %3
%66 = load i32, i32* %3
%67 = icmp ne i32 %66, 2
br i1 %67, label %68, label %79
68: ; preds = %61
%69 = load i32, i32* %2
%70 = load i32, i32* @SIGTERM
%71 = call i32 @kill(i32 %69, i32 %70)
%72 = load i32, i32* %2
%73 = call i32 @waitpid(i32 %72, i32* null, i32 0)
%74 = load i32, i32* %3
%75 = load i32, i32* @errno
%76 = call i8* @strerror(i32 %75)
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %74, i8* %76)
%78 = load i32, i32* %5
store i32 %78, i32* %1
br label %115
79: ; preds = %61
%80 = load i32, i32* %2
%81 = load i32, i32* @SIGTERM
%82 = call i32 @kill(i32 %80, i32 %81)
%83 = load i32, i32* %2
%84 = call i32 @waitpid(i32 %83, i32* %6, i32 0)
store i32 0, i32* %5
%85 = load i32, i32* %6
%86 = call i64 @WIFSIGNALED(i32 %85)
%87 = icmp ne i64 %86, 0
br i1 %87, label %88, label %99
88: ; preds = %79
%89 = load i32, i32* %6
%90 = call i32 @WTERMSIG(i32 %89)
store i32 %90, i32* %6
%91 = load i32, i32* %6
%92 = load i32, i32* @SIGTERM
%93 = icmp ne i32 %91, %92
br i1 %93, label %94, label %98
94: ; preds = %88
%95 = load i32, i32* %6
%96 = load i32, i32* @SIGTERM
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %95, i32 %96)
store i32 1, i32* %5
br label %98
98: ; preds = %94, %88
br label %108
99: ; preds = %79
%100 = load i32, i32* %6
%101 = call i64 @WIFEXITED(i32 %100)
%102 = icmp ne i64 %101, 0
br i1 %102, label %103, label %107
103: ; preds = %99
%104 = load i32, i32* %6
%105 = call i32 @WEXITSTATUS(i32 %104)
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i32 %105)
store i32 1, i32* %5
br label %107
107: ; preds = %103, %99
br label %108
108: ; preds = %107, %98
%109 = load i32, i32* %5
%110 = icmp eq i32 %109, 0
br i1 %110, label %111, label %113
111: ; preds = %108
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %113
113: ; preds = %111, %108
%114 = load i32, i32* %5
store i32 %114, i32* %1
br label %115
115: ; preds = %113, %68, %55, %38, %28, %13
%116 = load i32, i32* %1
ret i32 %116
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@.str = [29 x i8] c"Failed: %s rc: %d errno: %s\0A\00"
@.str.1 = [5 x i8] c"pipe\00"
@errno = global i32 0
@SCHED_FIFO = global i32 0
@.str.2 = [19 x i8] c"sched_setscheduler\00"
@.str.3 = [20 x i8] c"set_affinity_single\00"
@.str.4 = [5 x i8] c"fork\00"
@SIGTERM = global i32 0
@.str.5 = [5 x i8] c"read\00"
@.str.6 = [40 x i8] c"Failed: kill signal: %d, should be: %d\0A\00"
@.str.7 = [43 x i8] c"Failed: child prematurely exited with: %d\0A\00"
@str = [12 x i8] c"Test PASSED\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca i32
%3 = alloca %struct.sched_param
%4 = alloca [8 x i8]
%5 = bitcast [2 x i32]* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast %struct.sched_param* %3 to i8*
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%10 = call i32 @pipe(i32* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %0
%13 = load i32, i32* @errno
%14 = call i8* @strerror(i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %10, i8* %14)
br label %80
16: ; preds = %0
%17 = load i32, i32* @SCHED_FIFO
%18 = call i32 @sched_get_priority_min(i32 %17)
%19 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %3, i64 0, i32 0
store i32 %18, i32* %19
%20 = call i32 (...) @getpid()
%21 = load i32, i32* @SCHED_FIFO
%22 = call i32 @sched_setscheduler(i32 %20, i32 %21, %struct.sched_param* %3)
%23 = icmp eq i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %16
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %22, i8* %26)
br label %80
28: ; preds = %16
%29 = call i32 (...) @set_affinity_single()
%30 = icmp eq i32 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %28
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %29, i8* %33)
br label %80
35: ; preds = %28
%36 = call i32 (...) @fork()
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%40 = load i32, i32* %39
%41 = call i32 @child_busy(i32 %40)
br label %48
42: ; preds = %35
%43 = icmp slt i32 %36, 0
br i1 %43, label %44, label %48
44: ; preds = %42
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 0, i8* %46)
br label %80
48: ; preds = %38, %42
%49 = load i32, i32* %9
%50 = call i32 @read(i32 %49, i8* %8, i32 8)
%51 = icmp eq i32 %50, 2
%52 = load i32, i32* @SIGTERM
%53 = call i32 @kill(i32 %36, i32 %52)
br i1 %51, label %59, label %54
54: ; preds = %48
%55 = call i32 @waitpid(i32 %36, i32* null, i32 0)
%56 = load i32, i32* @errno
%57 = call i8* @strerror(i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %50, i8* %57)
br label %80
59: ; preds = %48
%60 = call i32 @waitpid(i32 %36, i32* %2, i32 0)
%61 = load i32, i32* %2
%62 = call i64 @WIFSIGNALED(i32 %61)
%63 = icmp eq i64 %62, 0
%64 = load i32, i32* %2
br i1 %63, label %71, label %65
65: ; preds = %59
%66 = call i32 @WTERMSIG(i32 %64)
store i32 %66, i32* %2
%67 = load i32, i32* @SIGTERM
%68 = icmp eq i32 %66, %67
br i1 %68, label %78, label %69
69: ; preds = %65
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %66, i32 %67)
br label %80
71: ; preds = %59
%72 = call i64 @WIFEXITED(i32 %64)
%73 = icmp eq i64 %72, 0
br i1 %73, label %78, label %74
74: ; preds = %71
%75 = load i32, i32* %2
%76 = call i32 @WEXITSTATUS(i32 %75)
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i32 %76)
br label %80
78: ; preds = %71, %65
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %80
80: ; preds = %69, %74, %78, %54, %44, %31, %24, %12
%81 = phi i32 [ 2, %12 ], [ 2, %24 ], [ 2, %31 ], [ 2, %44 ], [ 2, %54 ], [ 0, %78 ], [ 1, %74 ], [ 1, %69 ]
ret i32 %81
}