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

/* Variables and functions */
int /*<<< orphan*/ SIGINT;
scalar_t__ bind_to_cpu(int);
int /*<<< orphan*/ cycles_child();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ kill(scalar_t__, int /*<<< orphan*/);
int pick_online_cpu();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int wait_for_child(scalar_t__);
int multi_ebb_procs(void) {
  pid_t pids[4];
  int cpu, rc, i;
  cpu = pick_online_cpu();
  do {
    if ((cpu < 0)) {
      fprintf(stderr, "[FAIL] Test FAILED on line %d\n", 83);
      return 1;
    }
  } while (0);
  do {
    if ((bind_to_cpu(cpu))) {
      fprintf(stderr, "[FAIL] Test FAILED on line %d\n", 84);
      return 1;
    }
  } while (0);
  for (i = 0; i < 4; i++) {
    pids[i] = fork();
    if (pids[i] == 0)
      exit(cycles_child());
  }
  sleep(10);
  rc = 0;
  for (i = 0; i < 4; i++) {
    kill(pids[i], SIGINT);
    rc |= wait_for_child(pids[i]);
  }
  return rc;
}


x86 assembly (clang, -O0):
<multi_ebb_procs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x0,%al
call   1070 <pick_online_cpu@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    11d2 <multi_ebb_procs+0x42>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
mov    $0x53,%edx
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12cf <multi_ebb_procs+0x13f>
jmp    11d7 <multi_ebb_procs+0x47>
jmp    11dc <multi_ebb_procs+0x4c>
mov    -0x34(%rbp),%edi
call   1040 <bind_to_cpu@plt>
cmp    $0x0,%rax
je     1214 <multi_ebb_procs+0x84>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    0xe02(%rip),%rsi
mov    $0x54,%edx
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12cf <multi_ebb_procs+0x13f>
jmp    1219 <multi_ebb_procs+0x89>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    126e <multi_ebb_procs+0xde>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %rax,%rcx
movslq -0x3c(%rbp),%rax
mov    %rcx,-0x30(%rbp,%rax,8)
movslq -0x3c(%rbp),%rax
cmpq   $0x0,-0x30(%rbp,%rax,8)
jne    125b <multi_ebb_procs+0xcb>
mov    $0x0,%al
call   1030 <cycles_child@plt>
mov    %eax,%edi
call   1080 <exit@plt>
jmp    1260 <multi_ebb_procs+0xd0>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1220 <multi_ebb_procs+0x90>
mov    $0xa,%edi
call   10a0 <sleep@plt>
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    12c9 <multi_ebb_procs+0x139>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdi
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdi
call   1090 <wait_for_child@plt>
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1286 <multi_ebb_procs+0xf6>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multi_ebb_procs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <pick_online_cpu@plt>
test   %eax,%eax
js     11c9 <multi_ebb_procs+0x39>
mov    %eax,%edi
call   1040 <bind_to_cpu@plt>
test   %rax,%rax
je     11ed <multi_ebb_procs+0x5d>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
mov    $0x54,%edx
jmp    11de <multi_ebb_procs+0x4e>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
mov    $0x53,%edx
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    12a2 <multi_ebb_procs+0x112>
xor    %eax,%eax
call   10b0 <fork@plt>
test   %rax,%rax
je     12b1 <multi_ebb_procs+0x121>
mov    %rax,%rbx
xor    %eax,%eax
call   10b0 <fork@plt>
test   %rax,%rax
je     12b1 <multi_ebb_procs+0x121>
mov    %rax,%r12
xor    %eax,%eax
call   10b0 <fork@plt>
test   %rax,%rax
je     12b1 <multi_ebb_procs+0x121>
mov    %rax,%r15
xor    %eax,%eax
call   10b0 <fork@plt>
test   %rax,%rax
je     12b1 <multi_ebb_procs+0x121>
mov    %rax,%r14
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2da2(%rip),%r13
mov    0x0(%r13),%esi
mov    %rbx,%rdi
call   1060 <kill@plt>
mov    %rbx,%rdi
call   1090 <wait_for_child@plt>
mov    %eax,%ebx
mov    0x0(%r13),%esi
mov    %r12,%rdi
call   1060 <kill@plt>
mov    %r12,%rdi
call   1090 <wait_for_child@plt>
mov    %eax,%ebp
or     %ebx,%ebp
mov    0x0(%r13),%esi
mov    %r15,%rdi
call   1060 <kill@plt>
mov    %r15,%rdi
call   1090 <wait_for_child@plt>
mov    %eax,%ebx
mov    0x0(%r13),%esi
mov    %r14,%rdi
call   1060 <kill@plt>
mov    %r14,%rdi
call   1090 <wait_for_child@plt>
or     %ebx,%eax
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <cycles_child@plt>
mov    %eax,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"[FAIL] Test FAILED on line %d\0A\00"
@SIGINT = global i32 0
define i32 @multi_ebb_procs() {
%1 = alloca i32
%2 = alloca [4 x i64]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (...) @pick_online_cpu()
store i32 %6, i32* %3
br label %7
7: ; preds = %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 83)
store i32 1, i32* %1
br label %68
13: ; preds = %7
br label %14
14: ; preds = %13
br label %15
15: ; preds = %14
%16 = load i32, i32* %3
%17 = call i64 @bind_to_cpu(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 84)
store i32 1, i32* %1
br label %68
22: ; preds = %15
br label %23
23: ; preds = %22
store i32 0, i32* %5
br label %24
24: ; preds = %41, %23
%25 = load i32, i32* %5
%26 = icmp slt i32 %25, 4
br i1 %26, label %27, label %44
27: ; preds = %24
%28 = call i64 (...) @fork()
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [4 x i64], [4 x i64]* %2, i64 0, i64 %30
store i64 %28, i64* %31
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [4 x i64], [4 x i64]* %2, i64 0, i64 %33
%35 = load i64, i64* %34
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %27
%38 = call i32 (...) @cycles_child()
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %27
br label %41
41: ; preds = %40
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %24
44: ; preds = %24
%45 = call i32 @sleep(i32 10)
store i32 0, i32* %4
store i32 0, i32* %5
br label %46
46: ; preds = %63, %44
%47 = load i32, i32* %5
%48 = icmp slt i32 %47, 4
br i1 %48, label %49, label %66
49: ; preds = %46
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [4 x i64], [4 x i64]* %2, i64 0, i64 %51
%53 = load i64, i64* %52
%54 = load i32, i32* @SIGINT
%55 = call i32 @kill(i64 %53, i32 %54)
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [4 x i64], [4 x i64]* %2, i64 0, i64 %57
%59 = load i64, i64* %58
%60 = call i32 @wait_for_child(i64 %59)
%61 = load i32, i32* %4
%62 = or i32 %61, %60
store i32 %62, i32* %4
br label %63
63: ; preds = %49
%64 = load i32, i32* %5
%65 = add nsw i32 %64, 1
store i32 %65, i32* %5
br label %46
66: ; preds = %46
%67 = load i32, i32* %4
store i32 %67, i32* %1
br label %68
68: ; preds = %66, %19, %10
%69 = load i32, i32* %1
ret i32 %69
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"[FAIL] Test FAILED on line %d\0A\00"
@SIGINT = global i32 0
define i32 @multi_ebb_procs() {
%1 = tail call i32 (...) @pick_online_cpu()
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 83)
br label %44
6: ; preds = %0
%7 = tail call i64 @bind_to_cpu(i32 %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i64 (...) @fork()
%11 = icmp eq i64 %10, 0
br i1 %11, label %41, label %15
12: ; preds = %6
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 84)
br label %44
15: ; preds = %9
%16 = tail call i64 (...) @fork()
%17 = icmp eq i64 %16, 0
br i1 %17, label %41, label %18
18: ; preds = %15
%19 = tail call i64 (...) @fork()
%20 = icmp eq i64 %19, 0
br i1 %20, label %41, label %21
21: ; preds = %18
%22 = tail call i64 (...) @fork()
%23 = icmp eq i64 %22, 0
br i1 %23, label %41, label %24
24: ; preds = %21
%25 = tail call i32 @sleep(i32 10)
%26 = load i32, i32* @SIGINT
%27 = tail call i32 @kill(i64 %10, i32 %26)
%28 = tail call i32 @wait_for_child(i64 %10)
%29 = load i32, i32* @SIGINT
%30 = tail call i32 @kill(i64 %16, i32 %29)
%31 = tail call i32 @wait_for_child(i64 %16)
%32 = or i32 %31, %28
%33 = load i32, i32* @SIGINT
%34 = tail call i32 @kill(i64 %19, i32 %33)
%35 = tail call i32 @wait_for_child(i64 %19)
%36 = or i32 %35, %32
%37 = load i32, i32* @SIGINT
%38 = tail call i32 @kill(i64 %22, i32 %37)
%39 = tail call i32 @wait_for_child(i64 %22)
%40 = or i32 %39, %36
br label %44
41: ; preds = %21, %18, %15, %9
%42 = tail call i32 (...) @cycles_child()
%43 = tail call i32 @exit(i32 %42)
unreachable
44: ; preds = %24, %12, %3
%45 = phi i32 [ 1, %3 ], [ 1, %12 ], [ %40, %24 ]
ret i32 %45
}