#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 string {
  int dummy;
};
struct list_item {
  int dummy;
};
struct graph_node {
  int dummy;
};
struct graph {
  int dummy;
};
struct dict {
  int dummy;
};
typedef int pid_t;

/* Variables and functions */
scalar_t__ EINTR;
scalar_t__ WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
int /*<<< orphan*/ assert(int);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ graph_node_get_commands(struct graph_node *);
struct string *graph_node_get_name(struct graph_node *);
int /*<<< orphan*/ graph_node_mark_resolved(struct graph *,
                                            struct graph_node *);
struct string *list_get_data(struct list_item *);
struct list_item *list_head(int /*<<< orphan*/);
struct list_item *list_next(struct list_item *);
struct graph_node *next_node_needing_update(struct graph *);
int /*<<< orphan*/ printf(char *);
int start_job(struct graph_node *, struct string *, struct dict *, int *);
int /*<<< orphan*/ stderr;
char *string_get_cstr(struct string const *);
int wait(int *);
int /*<<< orphan*/ wait_for_jobs();
void *xcalloc(size_t, int);
int run_jobs(struct graph *graph, struct dict *macros, size_t max_jobs) {
  size_t running_jobs = 0;
  struct graph_node *node;
  pid_t *pids;
  struct graph_node **nodes;
  struct list_item **commands;
  int *ignore_errors;
  int any_job_launchable = 0;
  int error = 0;
  assert(max_jobs > 0);
  pids = xcalloc(max_jobs, sizeof(*pids));
  nodes = xcalloc(max_jobs, sizeof(*nodes));
  commands = xcalloc(max_jobs, sizeof(*commands));
  ignore_errors = xcalloc(max_jobs, sizeof(*ignore_errors));
  node = next_node_needing_update(graph);
  if (node == NULL) {
    printf("All specified targets are up to date\n");
  }
  while (running_jobs > 0 || node != NULL) {
    size_t i;
    while (node != NULL && running_jobs < max_jobs) {
      i = running_jobs;
      pids[i] = 0;
      nodes[i] = node;
      commands[i] = list_head(graph_node_get_commands(node));
      ignore_errors[i] = 0;
      assert(commands[i] != NULL);
      any_job_launchable = 1;
      ++running_jobs;
      node = next_node_needing_update(graph);
    }
    if (any_job_launchable) {
      for (i = 0; i < running_jobs; ++i) {
        struct string *command;
        if (pids[i] != 0) {
          continue;
        }
        command = list_get_data(commands[i]);
        pids[i] = start_job(nodes[i], command, macros, &ignore_errors[i]);
        if (pids[i] < 0) {
          error = 1;
          break;
        }
      }
      any_job_launchable = 0;
    }
    if (error) {
      wait_for_jobs();
      break;
    }
    assert(running_jobs > 0);
    {
      int stat;
      pid_t pid = -1;
      int terminated;
      while (pid == -1) {
        pid = wait(&stat);
        if (pid == -1) {
          assert(errno == EINTR);
        }
      }
      for (i = 0; i < running_jobs; ++i) {
        if (pids[i] == pid) {
          break;
        }
      }
      assert(i != running_jobs);
      terminated = 0;
      if (WIFEXITED(stat)) {
        terminated = 1;
        if (!ignore_errors[i]) {
          error = (WEXITSTATUS(stat) != 0);
        }
      }
      if (WIFSIGNALED(stat)) {
        terminated = 1;
        if (!ignore_errors[i]) {
          error = 1;
        }
      }
      if (error) {
        const struct string *name;
        name = graph_node_get_name(nodes[i]);
        fprintf(stderr, "Building \"%s\" has failed\n", string_get_cstr(name));
        wait_for_jobs();
        break;
      }
      if (!terminated) {
        continue;
      }
    }
    pids[i] = 0;
    commands[i] = list_next(commands[i]);
    ignore_errors[i] = 0;
    if (commands[i] == NULL) {
      graph_node_mark_resolved(graph, nodes[i]);
      --running_jobs;
      pids[i] = pids[running_jobs];
      nodes[i] = nodes[running_jobs];
      commands[i] = commands[running_jobs];
      ignore_errors[i] = ignore_errors[running_jobs];
      if (node == NULL) {
        node = next_node_needing_update(graph);
      }
    } else {
      any_job_launchable = 1;
    }
  }
  free(pids);
  free(nodes);
  free(commands);
  free(ignore_errors);
  return (error ? 2 : 0);
}


x86 assembly (clang, -O0):
<run_jobs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
cmpq   $0x0,-0x18(%rbp)
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1140 <xcalloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x8,%esi
call   1140 <xcalloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x8,%esi
call   1140 <xcalloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1140 <xcalloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
call   1120 <next_node_needing_update@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12db <run_jobs+0xab>
lea    0xd2a(%rip),%rdi
call   1060 <printf@plt>
jmp    12e0 <run_jobs+0xb0>
mov    $0x1,%al
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x79(%rbp)
ja     12fb <run_jobs+0xcb>
cmpq   $0x0,-0x28(%rbp)
setne  %al
mov    %al,-0x79(%rbp)
mov    -0x79(%rbp),%al
test   $0x1,%al
jne    130b <run_jobs+0xdb>
jmp    173a <run_jobs+0x50a>
jmp    1310 <run_jobs+0xe0>
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x7a(%rbp)
je     132e <run_jobs+0xfe>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
setb   %al
mov    %al,-0x7a(%rbp)
mov    -0x7a(%rbp),%al
test   $0x1,%al
jne    133e <run_jobs+0x10e>
jmp    13d2 <run_jobs+0x1a2>
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x58(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x28(%rbp),%rdx
mov    -0x38(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rdi
call   1040 <graph_node_get_commands@plt>
mov    %eax,%edi
call   10c0 <list_head@plt>
mov    %rax,%rdx
mov    -0x40(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x40(%rbp),%rax
mov    -0x58(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
movl   $0x1,-0x4c(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1120 <next_node_needing_update@plt>
mov    %rax,-0x28(%rbp)
jmp    1310 <run_jobs+0xe0>
cmpl   $0x0,-0x4c(%rbp)
je     148e <run_jobs+0x25e>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1487 <run_jobs+0x257>
mov    -0x30(%rbp),%rax
mov    -0x58(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1409 <run_jobs+0x1d9>
jmp    1476 <run_jobs+0x246>
mov    -0x40(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <list_get_data@plt>
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x58(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rcx
call   1150 <start_job@plt>
mov    %eax,%edx
mov    -0x30(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
mov    -0x58(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jge    1471 <run_jobs+0x241>
movl   $0x1,-0x50(%rbp)
jmp    1487 <run_jobs+0x257>
jmp    1476 <run_jobs+0x246>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    13e4 <run_jobs+0x1b4>
movl   $0x0,-0x4c(%rbp)
cmpl   $0x0,-0x50(%rbp)
je     14a4 <run_jobs+0x274>
mov    $0x0,%al
call   10d0 <wait_for_jobs@plt>
jmp    173a <run_jobs+0x50a>
cmpq   $0x0,-0x20(%rbp)
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
movl   $0xffffffff,-0x68(%rbp)
cmpl   $0xffffffff,-0x68(%rbp)
jne    1503 <run_jobs+0x2d3>
lea    -0x64(%rbp),%rdi
call   1130 <wait@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0xffffffff,-0x68(%rbp)
jne    14fe <run_jobs+0x2ce>
mov    0x2af4(%rip),%rax
mov    (%rax),%rax
mov    0x2ae2(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
jmp    14bd <run_jobs+0x28d>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1548 <run_jobs+0x318>
mov    -0x30(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x68(%rbp),%eax
jne    1532 <run_jobs+0x302>
jmp    1548 <run_jobs+0x318>
jmp    1537 <run_jobs+0x307>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    150b <run_jobs+0x2db>
mov    -0x58(%rbp),%rax
cmp    -0x20(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
movl   $0x0,-0x6c(%rbp)
mov    -0x64(%rbp),%edi
call   1100 <WIFEXITED@plt>
cmp    $0x0,%rax
je     15ab <run_jobs+0x37b>
movl   $0x1,-0x6c(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    15a6 <run_jobs+0x376>
mov    -0x64(%rbp),%edi
call   10f0 <WEXITSTATUS@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x50(%rbp)
jmp    15ab <run_jobs+0x37b>
mov    -0x64(%rbp),%edi
call   1080 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     15e2 <run_jobs+0x3b2>
movl   $0x1,-0x6c(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    15dd <run_jobs+0x3ad>
movl   $0x1,-0x50(%rbp)
jmp    15e2 <run_jobs+0x3b2>
cmpl   $0x0,-0x50(%rbp)
je     1634 <run_jobs+0x404>
mov    -0x38(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10b0 <graph_node_get_name@plt>
mov    %rax,-0x78(%rbp)
mov    0x29d8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
mov    -0x78(%rbp),%rdi
call   1110 <string_get_cstr@plt>
mov    -0x80(%rbp),%edi
mov    %rax,%rdx
lea    0xa03(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   10d0 <wait_for_jobs@plt>
jmp    173a <run_jobs+0x50a>
cmpl   $0x0,-0x6c(%rbp)
jne    1643 <run_jobs+0x413>
jmp    12e0 <run_jobs+0xb0>
mov    -0x30(%rbp),%rax
mov    -0x58(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x40(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <list_next@plt>
mov    %rax,%rdx
mov    -0x40(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x40(%rbp),%rax
mov    -0x58(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    172e <run_jobs+0x4fe>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   10e0 <graph_node_mark_resolved@plt>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x30(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x38(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x40(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x48(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
cmpq   $0x0,-0x28(%rbp)
jne    1729 <run_jobs+0x4f9>
mov    -0x8(%rbp),%rdi
call   1120 <next_node_needing_update@plt>
mov    %rax,-0x28(%rbp)
jmp    1735 <run_jobs+0x505>
movl   $0x1,-0x4c(%rbp)
jmp    12e0 <run_jobs+0xb0>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%edx
xor    %eax,%eax
mov    $0x2,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_jobs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%rbp
mov    %rsi,0x30(%rsp)
mov    %rdi,%r13
xor    %edi,%edi
test   %rdx,%rdx
setne  %dil
call   1090 <assert@plt>
mov    %rbp,%rdi
mov    $0x4,%esi
call   1140 <xcalloc@plt>
mov    %rax,%r14
mov    %rbp,%rdi
mov    $0x8,%esi
call   1140 <xcalloc@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    $0x8,%esi
call   1140 <xcalloc@plt>
mov    %rax,%r12
mov    %rbp,0x28(%rsp)
mov    %rbp,%rdi
mov    $0x4,%esi
call   1140 <xcalloc@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   1120 <next_node_needing_update@plt>
test   %rax,%rax
je     158f <run_jobs+0x35f>
mov    %rax,%r15
mov    %r13,0x20(%rsp)
mov    %rbp,(%rsp)
xor    %r13d,%r13d
xor    %ebp,%ebp
mov    %rbx,0x8(%rsp)
mov    %r12,0x10(%rsp)
jmp    12d9 <run_jobs+0xa9>
nopw   0x0(%rax,%rax,1)
test   %r15,%r15
je     15d0 <run_jobs+0x3a0>
test   %r15,%r15
je     133b <run_jobs+0x10b>
xchg   %ax,%ax
cmp    0x28(%rsp),%r13
jae    133b <run_jobs+0x10b>
movl   $0x0,(%r14,%r13,4)
mov    %r15,(%rbx,%r13,8)
mov    %r15,%rdi
call   1050 <graph_node_get_commands@plt>
mov    %eax,%edi
call   10c0 <list_head@plt>
mov    %rax,(%r12,%r13,8)
mov    (%rsp),%rcx
movl   $0x0,(%rcx,%r13,4)
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1090 <assert@plt>
add    $0x1,%r13
mov    0x20(%rsp),%rdi
call   1120 <next_node_needing_update@plt>
mov    %rax,%r15
mov    $0x1,%ebp
test   %rax,%rax
jne    12e0 <run_jobs+0xb0>
test   %ebp,%ebp
mov    0x30(%rsp),%rbp
je     13b0 <run_jobs+0x180>
test   %r13,%r13
je     13b0 <run_jobs+0x180>
mov    (%rsp),%r12
xor    %ebx,%ebx
jmp    136d <run_jobs+0x13d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
add    $0x4,%r12
cmp    %rbx,%r13
je     13b0 <run_jobs+0x180>
cmpl   $0x0,(%r14,%rbx,4)
jne    1360 <run_jobs+0x130>
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,8),%rdi
call   1060 <list_get_data@plt>
mov    0x8(%rsp),%rcx
mov    (%rcx,%rbx,8),%rdi
mov    %rax,%rsi
mov    %rbp,%rdx
mov    %r12,%rcx
call   1150 <start_job@plt>
mov    %eax,(%r14,%rbx,4)
test   %eax,%eax
jns    1360 <run_jobs+0x130>
jmp    1572 <run_jobs+0x342>
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
test   %r13,%r13
setne  %dil
call   1090 <assert@plt>
lea    0x1c(%rsp),%r12
mov    %r12,%rdi
call   1130 <wait@plt>
cmp    $0xffffffff,%eax
mov    0x2c03(%rip),%rbp
mov    0x2bf4(%rip),%rbx
jne    13ff <run_jobs+0x1cf>
xchg   %ax,%ax
mov    0x0(%rbp),%rax
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   1090 <assert@plt>
mov    %r12,%rdi
call   1130 <wait@plt>
cmp    $0xffffffff,%eax
je     13e0 <run_jobs+0x1b0>
xor    %ebx,%ebx
test   %r13,%r13
je     1422 <run_jobs+0x1f2>
cs nopw 0x0(%rax,%rax,1)
cmp    %eax,(%r14,%rbx,4)
je     1422 <run_jobs+0x1f2>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1410 <run_jobs+0x1e0>
mov    %r13,%rbx
xor    %edi,%edi
cmp    %r13,%rbx
setne  %dil
call   1090 <assert@plt>
mov    0x1c(%rsp),%edi
call   1100 <WIFEXITED@plt>
test   %rax,%rax
je     1470 <run_jobs+0x240>
xor    %ebp,%ebp
mov    (%rsp),%rax
cmpl   $0x0,(%rax,%rbx,4)
mov    $0x0,%r12d
jne    1475 <run_jobs+0x245>
mov    0x1c(%rsp),%edi
call   10f0 <WEXITSTATUS@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
xor    %r12d,%r12d
jmp    1475 <run_jobs+0x245>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%r12b
xor    %ebp,%ebp
mov    0x1c(%rsp),%edi
call   1080 <WIFSIGNALED@plt>
test   %rax,%rax
je     14a0 <run_jobs+0x270>
mov    (%rsp),%rax
cmpl   $0x0,(%rax,%rbx,4)
je     15d5 <run_jobs+0x3a5>
test   %ebp,%ebp
je     14b3 <run_jobs+0x283>
jmp    15d5 <run_jobs+0x3a5>
nopw   0x0(%rax,%rax,1)
test   %ebp,%ebp
jne    15d5 <run_jobs+0x3a5>
xor    %ebp,%ebp
test   %r12b,%r12b
jne    155a <run_jobs+0x32a>
movl   $0x0,(%r14,%rbx,4)
mov    0x10(%rsp),%r12
mov    (%r12,%rbx,8),%rdi
call   1070 <list_next@plt>
mov    %rax,(%r12,%rbx,8)
mov    (%rsp),%rcx
movl   $0x0,(%rcx,%rbx,4)
mov    $0x1,%ebp
test   %rax,%rax
je     1500 <run_jobs+0x2d0>
mov    0x8(%rsp),%rbx
test   %r13,%r13
je     12d0 <run_jobs+0xa0>
jmp    12d9 <run_jobs+0xa9>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rsp),%rbp
mov    0x0(%rbp,%rbx,8),%rsi
mov    0x20(%rsp),%rdi
call   10e0 <graph_node_mark_resolved@plt>
mov    %r12,%rcx
lea    -0x1(%r13),%r12
mov    -0x4(%r14,%r13,4),%eax
mov    %eax,(%r14,%rbx,4)
mov    -0x8(%rbp,%r13,8),%rax
mov    %rax,0x0(%rbp,%rbx,8)
mov    -0x8(%rcx,%r13,8),%rax
mov    %rax,(%rcx,%rbx,8)
mov    (%rsp),%rcx
mov    -0x4(%rcx,%r13,4),%eax
mov    %eax,(%rcx,%rbx,4)
xor    %ebp,%ebp
test   %r15,%r15
jne    1557 <run_jobs+0x327>
mov    0x20(%rsp),%rdi
call   1120 <next_node_needing_update@plt>
mov    %rax,%r15
mov    %r12,%r13
mov    0x8(%rsp),%rbx
mov    0x10(%rsp),%r12
test   %r13,%r13
je     12d0 <run_jobs+0xa0>
jmp    12d9 <run_jobs+0xa9>
xor    %eax,%eax
call   10d0 <wait_for_jobs@plt>
mov    $0x2,%r15d
mov    0x8(%rsp),%rbx
mov    0x10(%rsp),%r12
mov    (%rsp),%rbp
jmp    159e <run_jobs+0x36e>
lea    0xa84(%rip),%rdi
call   1040 <puts@plt>
xor    %r15d,%r15d
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r15d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r15d,%r15d
jmp    1589 <run_jobs+0x359>
mov    0x8(%rsp),%rax
mov    (%rax,%rbx,8),%rdi
mov    %rax,%rbx
call   10b0 <graph_node_get_name@plt>
mov    0x29f3(%rip),%rcx
mov    (%rcx),%ebp
mov    %rax,%rdi
call   1110 <string_get_cstr@plt>
lea    0xa02(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   10d0 <wait_for_jobs@plt>
mov    $0x2,%r15d
jmp    1584 <run_jobs+0x354>

LLVM IR (-O0):
%struct.graph = type { i32 }
%struct.dict = type { i32 }
%struct.graph_node = type { i32 }
%struct.list_item = type { i32 }
%struct.string = type { i32 }
@.str = [38 x i8] c"All specified targets are up to date\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@stderr = global i32 0
@.str.1 = [26 x i8] c"Building \22%s\22 has failed\0A\00"
define i32 @run_jobs(%struct.graph* %0, %struct.dict* %1, i64 %2) {
%4 = alloca %struct.graph*
%5 = alloca %struct.dict*
%6 = alloca i64
%7 = alloca i64
%8 = alloca %struct.graph_node*
%9 = alloca i32*
%10 = alloca %struct.graph_node**
%11 = alloca %struct.list_item**
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i64
%16 = alloca %struct.string*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca %struct.string*
store %struct.graph* %0, %struct.graph** %4
store %struct.dict* %1, %struct.dict** %5
store i64 %2, i64* %6
store i64 0, i64* %7
store i32 0, i32* %13
store i32 0, i32* %14
%21 = load i64, i64* %6
%22 = icmp ugt i64 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i64, i64* %6
%26 = call i8* @xcalloc(i64 %25, i32 4)
%27 = bitcast i8* %26 to i32*
store i32* %27, i32** %9
%28 = load i64, i64* %6
%29 = call i8* @xcalloc(i64 %28, i32 8)
%30 = bitcast i8* %29 to %struct.graph_node**
store %struct.graph_node** %30, %struct.graph_node*** %10
%31 = load i64, i64* %6
%32 = call i8* @xcalloc(i64 %31, i32 8)
%33 = bitcast i8* %32 to %struct.list_item**
store %struct.list_item** %33, %struct.list_item*** %11
%34 = load i64, i64* %6
%35 = call i8* @xcalloc(i64 %34, i32 4)
%36 = bitcast i8* %35 to i32*
store i32* %36, i32** %12
%37 = load %struct.graph*, %struct.graph** %4
%38 = call %struct.graph_node* @next_node_needing_update(%struct.graph* %37)
store %struct.graph_node* %38, %struct.graph_node** %8
%39 = load %struct.graph_node*, %struct.graph_node** %8
%40 = icmp eq %struct.graph_node* %39, null
br i1 %40, label %41, label %43
41: ; preds = %3
%42 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %41, %3
br label %44
44: ; preds = %292, %227, %43
%45 = load i64, i64* %7
%46 = icmp ugt i64 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = load %struct.graph_node*, %struct.graph_node** %8
%49 = icmp ne %struct.graph_node* %48, null
br label %50
50: ; preds = %47, %44
%51 = phi i1 [ true, %44 ], [ %49, %47 ]
br i1 %51, label %52, label %293
52: ; preds = %50
br label %53
53: ; preds = %62, %52
%54 = load %struct.graph_node*, %struct.graph_node** %8
%55 = icmp ne %struct.graph_node* %54, null
br i1 %55, label %56, label %60
56: ; preds = %53
%57 = load i64, i64* %7
%58 = load i64, i64* %6
%59 = icmp ult i64 %57, %58
br label %60
60: ; preds = %56, %53
%61 = phi i1 [ false, %53 ], [ %59, %56 ]
br i1 %61, label %62, label %91
62: ; preds = %60
%63 = load i64, i64* %7
store i64 %63, i64* %15
%64 = load i32*, i32** %9
%65 = load i64, i64* %15
%66 = getelementptr inbounds i32, i32* %64, i64 %65
store i32 0, i32* %66
%67 = load %struct.graph_node*, %struct.graph_node** %8
%68 = load %struct.graph_node**, %struct.graph_node*** %10
%69 = load i64, i64* %15
%70 = getelementptr inbounds %struct.graph_node*, %struct.graph_node** %68, i64 %69
store %struct.graph_node* %67, %struct.graph_node** %70
%71 = load %struct.graph_node*, %struct.graph_node** %8
%72 = call i32 @graph_node_get_commands(%struct.graph_node* %71)
%73 = call %struct.list_item* @list_head(i32 %72)
%74 = load %struct.list_item**, %struct.list_item*** %11
%75 = load i64, i64* %15
%76 = getelementptr inbounds %struct.list_item*, %struct.list_item** %74, i64 %75
store %struct.list_item* %73, %struct.list_item** %76
%77 = load i32*, i32** %12
%78 = load i64, i64* %15
%79 = getelementptr inbounds i32, i32* %77, i64 %78
store i32 0, i32* %79
%80 = load %struct.list_item**, %struct.list_item*** %11
%81 = load i64, i64* %15
%82 = getelementptr inbounds %struct.list_item*, %struct.list_item** %80, i64 %81
%83 = load %struct.list_item*, %struct.list_item** %82
%84 = icmp ne %struct.list_item* %83, null
%85 = zext i1 %84 to i32
%86 = call i32 @assert(i32 %85)
store i32 1, i32* %13
%87 = load i64, i64* %7
%88 = add i64 %87, 1
store i64 %88, i64* %7
%89 = load %struct.graph*, %struct.graph** %4
%90 = call %struct.graph_node* @next_node_needing_update(%struct.graph* %89)
store %struct.graph_node* %90, %struct.graph_node** %8
br label %53
91: ; preds = %60
%92 = load i32, i32* %13
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %136
94: ; preds = %91
store i64 0, i64* %15
br label %95
95: ; preds = %132, %94
%96 = load i64, i64* %15
%97 = load i64, i64* %7
%98 = icmp ult i64 %96, %97
br i1 %98, label %99, label %135
99: ; preds = %95
%100 = load i32*, i32** %9
%101 = load i64, i64* %15
%102 = getelementptr inbounds i32, i32* %100, i64 %101
%103 = load i32, i32* %102
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %106
105: ; preds = %99
br label %132
106: ; preds = %99
%107 = load %struct.list_item**, %struct.list_item*** %11
%108 = load i64, i64* %15
%109 = getelementptr inbounds %struct.list_item*, %struct.list_item** %107, i64 %108
%110 = load %struct.list_item*, %struct.list_item** %109
%111 = call %struct.string* @list_get_data(%struct.list_item* %110)
store %struct.string* %111, %struct.string** %16
%112 = load %struct.graph_node**, %struct.graph_node*** %10
%113 = load i64, i64* %15
%114 = getelementptr inbounds %struct.graph_node*, %struct.graph_node** %112, i64 %113
%115 = load %struct.graph_node*, %struct.graph_node** %114
%116 = load %struct.string*, %struct.string** %16
%117 = load %struct.dict*, %struct.dict** %5
%118 = load i32*, i32** %12
%119 = load i64, i64* %15
%120 = getelementptr inbounds i32, i32* %118, i64 %119
%121 = call i32 @start_job(%struct.graph_node* %115, %struct.string* %116, %struct.dict* %117, i32* %120)
%122 = load i32*, i32** %9
%123 = load i64, i64* %15
%124 = getelementptr inbounds i32, i32* %122, i64 %123
store i32 %121, i32* %124
%125 = load i32*, i32** %9
%126 = load i64, i64* %15
%127 = getelementptr inbounds i32, i32* %125, i64 %126
%128 = load i32, i32* %127
%129 = icmp slt i32 %128, 0
br i1 %129, label %130, label %131
130: ; preds = %106
store i32 1, i32* %14
br label %135
131: ; preds = %106
br label %132
132: ; preds = %131, %105
%133 = load i64, i64* %15
%134 = add i64 %133, 1
store i64 %134, i64* %15
br label %95
135: ; preds = %130, %95
store i32 0, i32* %13
br label %136
136: ; preds = %135, %91
%137 = load i32, i32* %14
%138 = icmp ne i32 %137, 0
br i1 %138, label %139, label %141
139: ; preds = %136
%140 = call i32 (...) @wait_for_jobs()
br label %293
141: ; preds = %136
%142 = load i64, i64* %7
%143 = icmp ugt i64 %142, 0
%144 = zext i1 %143 to i32
%145 = call i32 @assert(i32 %144)
store i32 -1, i32* %18
br label %146
146: ; preds = %159, %141
%147 = load i32, i32* %18
%148 = icmp eq i32 %147, -1
br i1 %148, label %149, label %160
149: ; preds = %146
%150 = call i32 @wait(i32* %17)
store i32 %150, i32* %18
%151 = load i32, i32* %18
%152 = icmp eq i32 %151, -1
br i1 %152, label %153, label %159
153: ; preds = %149
%154 = load i64, i64* @errno
%155 = load i64, i64* @EINTR
%156 = icmp eq i64 %154, %155
%157 = zext i1 %156 to i32
%158 = call i32 @assert(i32 %157)
br label %159
159: ; preds = %153, %149
br label %146
160: ; preds = %146
store i64 0, i64* %15
br label %161
161: ; preds = %174, %160
%162 = load i64, i64* %15
%163 = load i64, i64* %7
%164 = icmp ult i64 %162, %163
br i1 %164, label %165, label %177
165: ; preds = %161
%166 = load i32*, i32** %9
%167 = load i64, i64* %15
%168 = getelementptr inbounds i32, i32* %166, i64 %167
%169 = load i32, i32* %168
%170 = load i32, i32* %18
%171 = icmp eq i32 %169, %170
br i1 %171, label %172, label %173
172: ; preds = %165
br label %177
173: ; preds = %165
br label %174
174: ; preds = %173
%175 = load i64, i64* %15
%176 = add i64 %175, 1
store i64 %176, i64* %15
br label %161
177: ; preds = %172, %161
%178 = load i64, i64* %15
%179 = load i64, i64* %7
%180 = icmp ne i64 %178, %179
%181 = zext i1 %180 to i32
%182 = call i32 @assert(i32 %181)
store i32 0, i32* %19
%183 = load i32, i32* %17
%184 = call i64 @WIFEXITED(i32 %183)
%185 = icmp ne i64 %184, 0
br i1 %185, label %186, label %198
186: ; preds = %177
store i32 1, i32* %19
%187 = load i32*, i32** %12
%188 = load i64, i64* %15
%189 = getelementptr inbounds i32, i32* %187, i64 %188
%190 = load i32, i32* %189
%191 = icmp ne i32 %190, 0
br i1 %191, label %197, label %192
192: ; preds = %186
%193 = load i32, i32* %17
%194 = call i64 @WEXITSTATUS(i32 %193)
%195 = icmp ne i64 %194, 0
%196 = zext i1 %195 to i32
store i32 %196, i32* %14
br label %197
197: ; preds = %192, %186
br label %198
198: ; preds = %197, %177
%199 = load i32, i32* %17
%200 = call i64 @WIFSIGNALED(i32 %199)
%201 = icmp ne i64 %200, 0
br i1 %201, label %202, label %210
202: ; preds = %198
store i32 1, i32* %19
%203 = load i32*, i32** %12
%204 = load i64, i64* %15
%205 = getelementptr inbounds i32, i32* %203, i64 %204
%206 = load i32, i32* %205
%207 = icmp ne i32 %206, 0
br i1 %207, label %209, label %208
208: ; preds = %202
store i32 1, i32* %14
br label %209
209: ; preds = %208, %202
br label %210
210: ; preds = %209, %198
%211 = load i32, i32* %14
%212 = icmp ne i32 %211, 0
br i1 %212, label %213, label %224
213: ; preds = %210
%214 = load %struct.graph_node**, %struct.graph_node*** %10
%215 = load i64, i64* %15
%216 = getelementptr inbounds %struct.graph_node*, %struct.graph_node** %214, i64 %215
%217 = load %struct.graph_node*, %struct.graph_node** %216
%218 = call %struct.string* @graph_node_get_name(%struct.graph_node* %217)
store %struct.string* %218, %struct.string** %20
%219 = load i32, i32* @stderr
%220 = load %struct.string*, %struct.string** %20
%221 = call i8* @string_get_cstr(%struct.string* %220)
%222 = call i32 @fprintf(i32 %219, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %221)
%223 = call i32 (...) @wait_for_jobs()
br label %293
224: ; preds = %210
%225 = load i32, i32* %19
%226 = icmp ne i32 %225, 0
br i1 %226, label %228, label %227
227: ; preds = %224
br label %44
228: ; preds = %224
%229 = load i32*, i32** %9
%230 = load i64, i64* %15
%231 = getelementptr inbounds i32, i32* %229, i64 %230
store i32 0, i32* %231
%232 = load %struct.list_item**, %struct.list_item*** %11
%233 = load i64, i64* %15
%234 = getelementptr inbounds %struct.list_item*, %struct.list_item** %232, i64 %233
%235 = load %struct.list_item*, %struct.list_item** %234
%236 = call %struct.list_item* @list_next(%struct.list_item* %235)
%237 = load %struct.list_item**, %struct.list_item*** %11
%238 = load i64, i64* %15
%239 = getelementptr inbounds %struct.list_item*, %struct.list_item** %237, i64 %238
store %struct.list_item* %236, %struct.list_item** %239
%240 = load i32*, i32** %12
%241 = load i64, i64* %15
%242 = getelementptr inbounds i32, i32* %240, i64 %241
store i32 0, i32* %242
%243 = load %struct.list_item**, %struct.list_item*** %11
%244 = load i64, i64* %15
%245 = getelementptr inbounds %struct.list_item*, %struct.list_item** %243, i64 %244
%246 = load %struct.list_item*, %struct.list_item** %245
%247 = icmp eq %struct.list_item* %246, null
br i1 %247, label %248, label %291
248: ; preds = %228
%249 = load %struct.graph*, %struct.graph** %4
%250 = load %struct.graph_node**, %struct.graph_node*** %10
%251 = load i64, i64* %15
%252 = getelementptr inbounds %struct.graph_node*, %struct.graph_node** %250, i64 %251
%253 = load %struct.graph_node*, %struct.graph_node** %252
%254 = call i32 @graph_node_mark_resolved(%struct.graph* %249, %struct.graph_node* %253)
%255 = load i64, i64* %7
%256 = add i64 %255, -1
store i64 %256, i64* %7
%257 = load i32*, i32** %9
%258 = load i64, i64* %7
%259 = getelementptr inbounds i32, i32* %257, i64 %258
%260 = load i32, i32* %259
%261 = load i32*, i32** %9
%262 = load i64, i64* %15
%263 = getelementptr inbounds i32, i32* %261, i64 %262
store i32 %260, i32* %263
%264 = load %struct.graph_node**, %struct.graph_node*** %10
%265 = load i64, i64* %7
%266 = getelementptr inbounds %struct.graph_node*, %struct.graph_node** %264, i64 %265
%267 = load %struct.graph_node*, %struct.graph_node** %266
%268 = load %struct.graph_node**, %struct.graph_node*** %10
%269 = load i64, i64* %15
%270 = getelementptr inbounds %struct.graph_node*, %struct.graph_node** %268, i64 %269
store %struct.graph_node* %267, %struct.graph_node** %270
%271 = load %struct.list_item**, %struct.list_item*** %11
%272 = load i64, i64* %7
%273 = getelementptr inbounds %struct.list_item*, %struct.list_item** %271, i64 %272
%274 = load %struct.list_item*, %struct.list_item** %273
%275 = load %struct.list_item**, %struct.list_item*** %11
%276 = load i64, i64* %15
%277 = getelementptr inbounds %struct.list_item*, %struct.list_item** %275, i64 %276
store %struct.list_item* %274, %struct.list_item** %277
%278 = load i32*, i32** %12
%279 = load i64, i64* %7
%280 = getelementptr inbounds i32, i32* %278, i64 %279
%281 = load i32, i32* %280
%282 = load i32*, i32** %12
%283 = load i64, i64* %15
%284 = getelementptr inbounds i32, i32* %282, i64 %283
store i32 %281, i32* %284
%285 = load %struct.graph_node*, %struct.graph_node** %8
%286 = icmp eq %struct.graph_node* %285, null
br i1 %286, label %287, label %290
287: ; preds = %248
%288 = load %struct.graph*, %struct.graph** %4
%289 = call %struct.graph_node* @next_node_needing_update(%struct.graph* %288)
store %struct.graph_node* %289, %struct.graph_node** %8
br label %290
290: ; preds = %287, %248
br label %292
291: ; preds = %228
store i32 1, i32* %13
br label %292
292: ; preds = %291, %290
br label %44
293: ; preds = %213, %139, %50
%294 = load i32*, i32** %9
%295 = call i32 @free(i32* %294)
%296 = load %struct.graph_node**, %struct.graph_node*** %10
%297 = bitcast %struct.graph_node** %296 to i32*
%298 = call i32 @free(i32* %297)
%299 = load %struct.list_item**, %struct.list_item*** %11
%300 = bitcast %struct.list_item** %299 to i32*
%301 = call i32 @free(i32* %300)
%302 = load i32*, i32** %12
%303 = call i32 @free(i32* %302)
%304 = load i32, i32* %14
%305 = icmp ne i32 %304, 0
%306 = zext i1 %305 to i64
%307 = select i1 %305, i32 2, i32 0
ret i32 %307
}

LLVM IR (-O2):
%struct.graph = type { i32 }
%struct.dict = type { i32 }
%struct.graph_node = type { i32 }
%struct.list_item = type { i32 }
%struct.string = type { i32 }
@errno = global i64 0
@EINTR = global i64 0
@stderr = global i32 0
@.str.1 = [26 x i8] c"Building \22%s\22 has failed\0A\00"
@str = [37 x i8] c"All specified targets are up to date\00"
define i32 @run_jobs(%struct.graph* %0, %struct.dict* %1, i64 %2) {
%4 = alloca i32
%5 = icmp ne i64 %2, 0
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i8* @xcalloc(i64 %2, i32 4)
%9 = bitcast i8* %8 to i32*
%10 = tail call i8* @xcalloc(i64 %2, i32 8)
%11 = bitcast i8* %10 to %struct.graph_node**
%12 = tail call i8* @xcalloc(i64 %2, i32 8)
%13 = bitcast i8* %12 to %struct.list_item**
%14 = tail call i8* @xcalloc(i64 %2, i32 4)
%15 = bitcast i8* %14 to i32*
%16 = tail call %struct.graph_node* @next_node_needing_update(%struct.graph* %0)
%17 = icmp eq %struct.graph_node* %16, null
br i1 %17, label %18, label %20
18: ; preds = %3
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %167
20: ; preds = %3
%21 = bitcast i32* %4 to i8*
br label %22
22: ; preds = %20, %160
%23 = phi i64 [ 0, %20 ], [ %163, %160 ]
%24 = phi %struct.graph_node* [ %16, %20 ], [ %162, %160 ]
%25 = phi i32 [ 0, %20 ], [ %161, %160 ]
%26 = icmp ne %struct.graph_node* %24, null
%27 = icmp ult i64 %23, %2
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %29, label %46
29: ; preds = %22, %29
%30 = phi i64 [ %41, %29 ], [ %23, %22 ]
%31 = phi %struct.graph_node* [ %42, %29 ], [ %24, %22 ]
%32 = getelementptr inbounds i32, i32* %9, i64 %30
store i32 0, i32* %32
%33 = getelementptr inbounds %struct.graph_node*, %struct.graph_node** %11, i64 %30
store %struct.graph_node* %31, %struct.graph_node** %33
%34 = call i32 @graph_node_get_commands(%struct.graph_node* %31)
%35 = call %struct.list_item* @list_head(i32 %34)
%36 = getelementptr inbounds %struct.list_item*, %struct.list_item** %13, i64 %30
store %struct.list_item* %35, %struct.list_item** %36
%37 = getelementptr inbounds i32, i32* %15, i64 %30
store i32 0, i32* %37
%38 = icmp ne %struct.list_item* %35, null
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = add nuw i64 %30, 1
%42 = call %struct.graph_node* @next_node_needing_update(%struct.graph* %0)
%43 = icmp ne %struct.graph_node* %42, null
%44 = icmp ult i64 %41, %2
%45 = select i1 %43, i1 %44, i1 false
br i1 %45, label %29, label %46
46: ; preds = %29, %22
%47 = phi i32 [ %25, %22 ], [ 1, %29 ]
%48 = phi %struct.graph_node* [ %24, %22 ], [ %42, %29 ]
%49 = phi i64 [ %23, %22 ], [ %41, %29 ]
%50 = icmp ne i32 %47, 0
%51 = icmp ne i64 %49, 0
%52 = select i1 %50, i1 %51, i1 false
br i1 %52, label %53, label %72
53: ; preds = %46, %67
%54 = phi i64 [ %68, %67 ], [ 0, %46 ]
%55 = getelementptr inbounds i32, i32* %9, i64 %54
%56 = load i32, i32* %55
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %67
58: ; preds = %53
%59 = getelementptr inbounds %struct.list_item*, %struct.list_item** %13, i64 %54
%60 = load %struct.list_item*, %struct.list_item** %59
%61 = call %struct.string* @list_get_data(%struct.list_item* %60)
%62 = getelementptr inbounds %struct.graph_node*, %struct.graph_node** %11, i64 %54
%63 = load %struct.graph_node*, %struct.graph_node** %62
%64 = getelementptr inbounds i32, i32* %15, i64 %54
%65 = call i32 @start_job(%struct.graph_node* %63, %struct.string* %61, %struct.dict* %1, i32* %64)
store i32 %65, i32* %55
%66 = icmp slt i32 %65, 0
br i1 %66, label %70, label %67
67: ; preds = %53, %58
%68 = add nuw i64 %54, 1
%69 = icmp eq i64 %68, %49
br i1 %69, label %72, label %53
70: ; preds = %58
%71 = call i32 (...) @wait_for_jobs()
br label %167
72: ; preds = %67, %46
%73 = zext i1 %51 to i32
%74 = call i32 @assert(i32 %73)
%75 = call i32 @wait(i32* %4)
%76 = icmp eq i32 %75, -1
br i1 %76, label %80, label %77
77: ; preds = %80, %72
%78 = phi i32 [ %75, %72 ], [ %86, %80 ]
%79 = icmp eq i64 %49, 0
br i1 %79, label %96, label %88
80: ; preds = %72, %80
%81 = load i64, i64* @errno
%82 = load i64, i64* @EINTR
%83 = icmp eq i64 %81, %82
%84 = zext i1 %83 to i32
%85 = call i32 @assert(i32 %84)
%86 = call i32 @wait(i32* %4)
%87 = icmp eq i32 %86, -1
br i1 %87, label %80, label %77
88: ; preds = %77, %93
%89 = phi i64 [ %94, %93 ], [ 0, %77 ]
%90 = getelementptr inbounds i32, i32* %9, i64 %89
%91 = load i32, i32* %90
%92 = icmp eq i32 %91, %78
br i1 %92, label %96, label %93
93: ; preds = %88
%94 = add nuw i64 %89, 1
%95 = icmp eq i64 %94, %49
br i1 %95, label %96, label %88
96: ; preds = %93, %88, %77
%97 = phi i64 [ 0, %77 ], [ %89, %88 ], [ %49, %93 ]
%98 = icmp ne i64 %97, %49
%99 = zext i1 %98 to i32
%100 = call i32 @assert(i32 %99)
%101 = load i32, i32* %4
%102 = call i64 @WIFEXITED(i32 %101)
%103 = icmp eq i64 %102, 0
br i1 %103, label %113, label %104
104: ; preds = %96
%105 = getelementptr inbounds i32, i32* %15, i64 %97
%106 = load i32, i32* %105
%107 = icmp eq i32 %106, 0
br i1 %107, label %108, label %113
108: ; preds = %104
%109 = load i32, i32* %4
%110 = call i64 @WEXITSTATUS(i32 %109)
%111 = icmp ne i64 %110, 0
%112 = zext i1 %111 to i32
br label %113
113: ; preds = %104, %108, %96
%114 = phi i32 [ 0, %104 ], [ %112, %108 ], [ 0, %96 ]
%115 = phi i1 [ false, %104 ], [ false, %108 ], [ true, %96 ]
%116 = load i32, i32* %4
%117 = call i64 @WIFSIGNALED(i32 %116)
%118 = icmp eq i64 %117, 0
br i1 %118, label %125, label %119
119: ; preds = %113
%120 = getelementptr inbounds i32, i32* %15, i64 %97
%121 = load i32, i32* %120
%122 = icmp ne i32 %121, 0
%123 = icmp eq i32 %114, 0
%124 = select i1 %122, i1 %123, i1 false
br i1 %124, label %127, label %128
125: ; preds = %113
%126 = icmp eq i32 %114, 0
br i1 %126, label %136, label %128
127: ; preds = %119
br label %137
128: ; preds = %125, %119
%129 = getelementptr inbounds %struct.graph_node*, %struct.graph_node** %11, i64 %97
%130 = load %struct.graph_node*, %struct.graph_node** %129
%131 = call %struct.string* @graph_node_get_name(%struct.graph_node* %130)
%132 = load i32, i32* @stderr
%133 = call i8* @string_get_cstr(%struct.string* %131)
%134 = call i32 @fprintf(i32 %132, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %133)
%135 = call i32 (...) @wait_for_jobs()
br label %167
136: ; preds = %125
br i1 %115, label %160, label %137
137: ; preds = %127, %136
%138 = getelementptr inbounds i32, i32* %9, i64 %97
store i32 0, i32* %138
%139 = getelementptr inbounds %struct.list_item*, %struct.list_item** %13, i64 %97
%140 = load %struct.list_item*, %struct.list_item** %139
%141 = call %struct.list_item* @list_next(%struct.list_item* %140)
store %struct.list_item* %141, %struct.list_item** %139
%142 = getelementptr inbounds i32, i32* %15, i64 %97
store i32 0, i32* %142
%143 = icmp eq %struct.list_item* %141, null
br i1 %143, label %144, label %160
144: ; preds = %137
%145 = getelementptr inbounds %struct.graph_node*, %struct.graph_node** %11, i64 %97
%146 = load %struct.graph_node*, %struct.graph_node** %145
%147 = call i32 @graph_node_mark_resolved(%struct.graph* %0, %struct.graph_node* %146)
%148 = add i64 %49, -1
%149 = getelementptr inbounds i32, i32* %9, i64 %148
%150 = load i32, i32* %149
store i32 %150, i32* %138
%151 = getelementptr inbounds %struct.graph_node*, %struct.graph_node** %11, i64 %148
%152 = load %struct.graph_node*, %struct.graph_node** %151
store %struct.graph_node* %152, %struct.graph_node** %145
%153 = getelementptr inbounds %struct.list_item*, %struct.list_item** %13, i64 %148
%154 = load %struct.list_item*, %struct.list_item** %153
store %struct.list_item* %154, %struct.list_item** %139
%155 = getelementptr inbounds i32, i32* %15, i64 %148
%156 = load i32, i32* %155
store i32 %156, i32* %142
%157 = icmp eq %struct.graph_node* %48, null
br i1 %157, label %158, label %160
158: ; preds = %144
%159 = call %struct.graph_node* @next_node_needing_update(%struct.graph* %0)
br label %160
160: ; preds = %158, %144, %137, %136
%161 = phi i32 [ 0, %136 ], [ 0, %158 ], [ 0, %144 ], [ 1, %137 ]
%162 = phi %struct.graph_node* [ %48, %136 ], [ %159, %158 ], [ %48, %144 ], [ %48, %137 ]
%163 = phi i64 [ %49, %136 ], [ %148, %158 ], [ %148, %144 ], [ %49, %137 ]
%164 = icmp ne i64 %163, 0
%165 = icmp ne %struct.graph_node* %162, null
%166 = select i1 %164, i1 true, i1 %165
br i1 %166, label %22, label %167
167: ; preds = %160, %18, %128, %70
%168 = phi i32 [ 2, %128 ], [ 2, %70 ], [ 0, %18 ], [ 0, %160 ]
%169 = call i32 @free(i32* %9)
%170 = bitcast i8* %10 to i32*
%171 = call i32 @free(i32* %170)
%172 = bitcast i8* %12 to i32*
%173 = call i32 @free(i32* %172)
%174 = call i32 @free(i32* %15)
ret i32 %168
}