#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 list {
  int dummy;
};
struct graph_node {
  int dummy;
};
struct graph {
  int dummy;
};
struct dict {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ chdir(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dict_destroy(struct dict *);
struct dict *dict_init();
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ graph_destroy(struct graph *);
struct graph_node *graph_get_node_by_name(struct graph *, struct string *);
struct list *graph_get_nodes(struct graph *);
struct graph *graph_init();
int /*<<< orphan*/ graph_node_mark_target(struct graph_node *);
scalar_t__ graph_process(struct graph *);
struct graph_node *list_get_data(struct list_item *);
struct list_item *list_head(struct list *);
int open(char const *, int /*<<< orphan*/);
char *optarg;
int optind;
scalar_t__ parse_file(int, struct graph *, struct dict *);
int /*<<< orphan*/ populate_builtin_macros(struct dict *);
int /*<<< orphan*/ populate_environment_variables(struct dict *);
int /*<<< orphan*/ print_usage();
int run_jobs(struct graph *, struct dict *, size_t);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ string_destroy(struct string *);
struct string *string_init(char *);
long strtol(char *, char **, int);
scalar_t__ update_all_files_info(struct graph *);
int main(int argc, char **argv) {
  int c;
  const char *makefile = NULL;
  long jobs = 1;
  char *endptr;
  while ((c = getopt(argc, argv, "C:f:j:")) != -1) {
    switch (c) {
    case 'C':
      if (chdir(optarg)) {
        fprintf(stderr,
                "Could not change "
                "directory to %s\n",
                optarg);
        return (2);
      }
      break;
    case 'f':
      if (makefile != NULL) {
        fprintf(stderr, "Option -f specified "
                        "multiple times\n");
        return (2);
      }
      makefile = optarg;
      break;
    case 'j':
      errno = 0;
      jobs = strtol(optarg, &endptr, 10);
      if (errno != 0 || jobs < 1 || *endptr != '\0') {
        fprintf(stderr, "Invalid numeric value "
                        "for option -j\n");
        return (2);
      }
      break;
    default:
      print_usage();
      return (2);
    }
  }
  if (makefile == NULL) {
    makefile = "Makefile";
  }
  {
    struct graph *graph;
    struct dict *macros;
    int fd;
    fd = open(makefile, O_RDONLY);
    if (fd < 0) {
      fprintf(stderr, "Could not open the makefile\n");
      return (2);
    }
    graph = graph_init();
    macros = dict_init();
    populate_builtin_macros(macros);
    populate_environment_variables(macros);
    if (parse_file(fd, graph, macros)) {
      close(fd);
      graph_destroy(graph);
      dict_destroy(macros);
      return (2);
    }
    close(fd);
    if (optind == argc) {
      struct list *nodes;
      struct list_item *item;
      struct graph_node *node;
      nodes = graph_get_nodes(graph);
      item = list_head(nodes);
      if (item == NULL) {
        fprintf(stderr, "No target specified\n");
        graph_destroy(graph);
        dict_destroy(macros);
        return (2);
      }
      node = list_get_data(item);
      graph_node_mark_target(node);
    } else {
      int i;
      for (i = optind; i < argc; ++i) {
        struct string *node_name;
        struct graph_node *node;
        node_name = string_init(argv[i]);
        node = graph_get_node_by_name(graph, node_name);
        string_destroy(node_name);
        if (node == NULL) {
          fprintf(stderr,
                  "Unknown target "
                  "\"%s\"\n",
                  argv[i]);
          graph_destroy(graph);
          dict_destroy(macros);
          return (2);
        }
        graph_node_mark_target(node);
      }
    }
    if (update_all_files_info(graph)) {
      dict_destroy(macros);
      graph_destroy(graph);
      return (2);
    }
    if (graph_process(graph)) {
      dict_destroy(macros);
      graph_destroy(graph);
      return (2);
    }
    {
      int ret = run_jobs(graph, macros, (size_t)jobs);
      dict_destroy(macros);
      graph_destroy(graph);
      return (ret);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xd49(%rip),%rdx
call   1160 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     141d <main+0x19d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x80(%rbp)
sub    $0x43,%eax
je     12fe <main+0x7e>
jmp    12dc <main+0x5c>
mov    -0x80(%rbp),%eax
sub    $0x66,%eax
je     1348 <main+0xc8>
jmp    12ed <main+0x6d>
mov    -0x80(%rbp),%eax
sub    $0x6a,%eax
je     1389 <main+0x109>
jmp    1405 <main+0x185>
mov    0x2cf3(%rip),%rax
mov    (%rax),%rdi
call   1080 <chdir@plt>
cmp    $0x0,%eax
je     1343 <main+0xc3>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
mov    0x2cd2(%rip),%rax
mov    (%rax),%rdx
lea    0xcd7(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a9 <main+0x429>
jmp    1418 <main+0x198>
cmpq   $0x0,-0x20(%rbp)
je     1376 <main+0xf6>
mov    0x2c6e(%rip),%rax
mov    (%rax),%edi
lea    0xcc6(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a9 <main+0x429>
mov    0x2c7b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1418 <main+0x198>
mov    0x2c30(%rip),%rax
movl   $0x0,(%rax)
mov    0x2c5b(%rip),%rax
mov    (%rax),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   10d0 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    0x2c07(%rip),%rax
cmpl   $0x0,(%rax)
jne    13dd <main+0x15d>
cmpq   $0x1,-0x28(%rbp)
jl     13dd <main+0x15d>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1400 <main+0x180>
mov    0x2be4(%rip),%rax
mov    (%rax),%edi
lea    0xc60(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a9 <main+0x429>
jmp    1418 <main+0x198>
mov    $0x0,%al
call   1190 <print_usage@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a9 <main+0x429>
jmp    12a9 <main+0x29>
cmpq   $0x0,-0x20(%rbp)
jne    1433 <main+0x1b3>
lea    0xc43(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2ba2(%rip),%rax
mov    (%rax),%esi
call   1140 <open@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    1475 <main+0x1f5>
mov    0x2b6f(%rip),%rax
mov    (%rax),%edi
lea    0xc19(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a9 <main+0x429>
mov    $0x0,%al
call   1170 <graph_init@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1120 <dict_init@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   10e0 <populate_builtin_macros@plt>
mov    -0x40(%rbp),%rdi
call   1060 <populate_environment_variables@plt>
mov    -0x44(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1150 <parse_file@plt>
cmp    $0x0,%rax
je     14dd <main+0x25d>
mov    -0x44(%rbp),%edi
call   10a0 <close@plt>
mov    -0x38(%rbp),%rdi
call   1030 <graph_destroy@plt>
mov    -0x40(%rbp),%rdi
call   1110 <dict_destroy@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a9 <main+0x429>
mov    -0x44(%rbp),%edi
call   10a0 <close@plt>
mov    0x2aec(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    156c <main+0x2ec>
mov    -0x38(%rbp),%rdi
call   1130 <graph_get_nodes@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
call   10f0 <list_head@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1551 <main+0x2d1>
mov    0x2aa5(%rip),%rax
mov    (%rax),%edi
lea    0xb6c(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <graph_destroy@plt>
mov    -0x40(%rbp),%rdi
call   1110 <dict_destroy@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a9 <main+0x429>
mov    -0x58(%rbp),%rdi
call   1090 <list_get_data@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
call   10b0 <graph_node_mark_target@plt>
jmp    161b <main+0x39b>
mov    0x2a65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1616 <main+0x396>
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <string_init@plt>
mov    %rax,-0x70(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x70(%rbp),%rsi
call   1100 <graph_get_node_by_name@plt>
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rdi
call   1070 <string_destroy@plt>
cmpq   $0x0,-0x78(%rbp)
jne    15ff <main+0x37f>
mov    0x2a03(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xad3(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <graph_destroy@plt>
mov    -0x40(%rbp),%rdi
call   1110 <dict_destroy@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a9 <main+0x429>
mov    -0x78(%rbp),%rdi
call   10b0 <graph_node_mark_target@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1578 <main+0x2f8>
jmp    161b <main+0x39b>
mov    -0x38(%rbp),%rdi
call   1040 <update_all_files_info@plt>
cmp    $0x0,%rax
je     164c <main+0x3cc>
mov    -0x40(%rbp),%rdi
call   1110 <dict_destroy@plt>
mov    -0x38(%rbp),%rdi
call   1030 <graph_destroy@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a9 <main+0x429>
mov    -0x38(%rbp),%rdi
call   1180 <graph_process@plt>
cmp    $0x0,%rax
je     167d <main+0x3fd>
mov    -0x40(%rbp),%rdi
call   1110 <dict_destroy@plt>
mov    -0x38(%rbp),%rdi
call   1030 <graph_destroy@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a9 <main+0x429>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   11a0 <run_jobs@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x40(%rbp),%rdi
call   1110 <dict_destroy@plt>
mov    -0x38(%rbp),%rdi
call   1030 <graph_destroy@plt>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r13
mov    %edi,%ebp
mov    $0x1,%eax
mov    %rax,0x18(%rsp)
xor    %r12d,%r12d
lea    0xd59(%rip),%rbx
mov    0x2d4a(%rip),%r15
xchg   %ax,%ax
mov    %ebp,%edi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1160 <getopt@plt>
cmp    $0x43,%eax
jne    12d3 <main+0x53>
mov    (%r15),%rdi
call   1080 <chdir@plt>
test   %eax,%eax
je     12b0 <main+0x30>
jmp    13c8 <main+0x148>
cmp    $0xffffffff,%eax
je     1341 <main+0xc1>
cmp    $0x66,%eax
je     1330 <main+0xb0>
cmp    $0x6a,%eax
jne    13bc <main+0x13c>
mov    0x2cd3(%rip),%r14
movl   $0x0,(%r14)
mov    (%r15),%rdi
lea    0x20(%rsp),%rsi
mov    $0xa,%edx
call   10d0 <strtol@plt>
mov    %rax,0x18(%rsp)
cmpl   $0x0,(%r14)
jne    14b8 <main+0x238>
cmpq   $0x0,0x18(%rsp)
jle    14b8 <main+0x238>
mov    0x20(%rsp),%rax
cmpb   $0x0,(%rax)
je     12b0 <main+0x30>
jmp    14b8 <main+0x238>
test   %r12,%r12
jne    1523 <main+0x2a3>
mov    (%r15),%r12
jmp    12b0 <main+0x30>
test   %r12,%r12
lea    0xd27(%rip),%rdi
cmovne %r12,%rdi
mov    0x2c8a(%rip),%rax
mov    (%rax),%esi
call   1140 <open@plt>
test   %eax,%eax
js     13e7 <main+0x167>
mov    %eax,%ebx
xor    %eax,%eax
call   1170 <graph_init@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1120 <dict_init@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   10e0 <populate_builtin_macros@plt>
mov    %r12,%rdi
call   1060 <populate_environment_variables@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   1150 <parse_file@plt>
mov    %rax,%r15
mov    %ebx,%edi
call   10a0 <close@plt>
test   %r15,%r15
je     1403 <main+0x183>
mov    %r14,%rdi
call   1030 <graph_destroy@plt>
mov    %r12,%rdi
call   1110 <dict_destroy@plt>
jmp    14f3 <main+0x273>
xor    %eax,%eax
call   1190 <print_usage@plt>
jmp    14f3 <main+0x273>
mov    0x2bf9(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xc2c(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    14f3 <main+0x273>
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
lea    0xc84(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    14f3 <main+0x273>
mov    %r12,0x8(%rsp)
mov    0x2bc9(%rip),%rax
movslq (%rax),%r15
cmp    %ebp,%r15d
jne    1447 <main+0x1c7>
mov    %r14,%rdi
call   1130 <graph_get_nodes@plt>
mov    %rax,%rdi
call   10f0 <list_head@plt>
test   %rax,%rax
je     1507 <main+0x287>
mov    %r14,0x10(%rsp)
mov    %rax,%rdi
call   1090 <list_get_data@plt>
mov    %rax,%rdi
call   10b0 <graph_node_mark_target@plt>
jmp    149f <main+0x21f>
mov    %r14,0x10(%rsp)
cmp    %ebp,%r15d
jge    149f <main+0x21f>
movslq %ebp,%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%r13,%r15,8),%rdi
call   1050 <string_init@plt>
mov    %rax,%rbp
mov    0x10(%rsp),%rdi
mov    %rax,%rsi
call   1100 <graph_get_node_by_name@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1070 <string_destroy@plt>
test   %rbx,%rbx
je     1538 <main+0x2b8>
mov    %rbx,%rdi
call   10b0 <graph_node_mark_target@plt>
add    $0x1,%r15
cmp    %r15,%r12
jne    1460 <main+0x1e0>
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <update_all_files_info@plt>
test   %rax,%rax
je     14cd <main+0x24d>
mov    0x8(%rsp),%rdi
jmp    14e6 <main+0x266>
mov    0x2b09(%rip),%rax
mov    (%rax),%edi
lea    0xb85(%rip),%rsi
jmp    13f7 <main+0x177>
mov    %rbp,%rdi
call   1180 <graph_process@plt>
test   %rax,%rax
mov    0x8(%rsp),%rbx
je     1568 <main+0x2e8>
mov    %rbx,%rdi
call   1110 <dict_destroy@plt>
mov    %rbp,%rdi
call   1030 <graph_destroy@plt>
mov    $0x2,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2aba(%rip),%rax
mov    (%rax),%edi
lea    0xb81(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %r14,%rdi
jmp    1559 <main+0x2d9>
mov    0x2a9e(%rip),%rax
mov    (%rax),%edi
lea    0xaf6(%rip),%rsi
jmp    13f7 <main+0x177>
mov    0x2a89(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13,%r15,8),%rdx
lea    0xb60(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x10(%rsp),%rdi
call   1030 <graph_destroy@plt>
mov    0x8(%rsp),%rdi
jmp    13b2 <main+0x132>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    0x18(%rsp),%rdx
call   11a0 <run_jobs@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1110 <dict_destroy@plt>
mov    %rbp,%rdi
call   1030 <graph_destroy@plt>
mov    %r14d,%eax
jmp    14f8 <main+0x278>

LLVM IR (-O0):
%struct.graph = type { i32 }
%struct.dict = type { i32 }
%struct.list = type { i32 }
%struct.list_item = type { i32 }
%struct.graph_node = type { i32 }
%struct.string = type { i32 }
@.str = [7 x i8] c"C:f:j:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [34 x i8] c"Could not change directory to %s\0A\00"
@.str.2 = [36 x i8] c"Option -f specified multiple times\0A\00"
@errno = global i32 0
@.str.3 = [37 x i8] c"Invalid numeric value for option -j\0A\00"
@.str.4 = [9 x i8] c"Makefile\00"
@O_RDONLY = global i32 0
@.str.5 = [29 x i8] c"Could not open the makefile\0A\00"
@optind = global i32 0
@.str.6 = [21 x i8] c"No target specified\0A\00"
@.str.7 = [21 x i8] c"Unknown target \22%s\22\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca %struct.graph*
%11 = alloca %struct.dict*
%12 = alloca i32
%13 = alloca %struct.list*
%14 = alloca %struct.list_item*
%15 = alloca %struct.graph_node*
%16 = alloca i32
%17 = alloca %struct.string*
%18 = alloca %struct.graph_node*
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i64 1, i64* %8
br label %20
20: ; preds = %63, %2
%21 = load i32, i32* %4
%22 = load i8**, i8*** %5
%23 = call i32 @getopt(i32 %21, i8** %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %23, i32* %6
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %64
25: ; preds = %20
%26 = load i32, i32* %6
switch i32 %26, label %61 [
i32 67, label %27
i32 102, label %36
i32 106, label %44
]
27: ; preds = %25
%28 = load i8*, i8** @optarg
%29 = call i32 @chdir(i8* %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = load i8*, i8** @optarg
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %33)
store i32 2, i32* %3
br label %188
35: ; preds = %27
br label %63
36: ; preds = %25
%37 = load i8*, i8** %7
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32, i32* @stderr
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %188
42: ; preds = %36
%43 = load i8*, i8** @optarg
store i8* %43, i8** %7
br label %63
44: ; preds = %25
store i32 0, i32* @errno
%45 = load i8*, i8** @optarg
%46 = call i64 @strtol(i8* %45, i8** %9, i32 10)
store i64 %46, i64* %8
%47 = load i32, i32* @errno
%48 = icmp ne i32 %47, 0
br i1 %48, label %57, label %49
49: ; preds = %44
%50 = load i64, i64* %8
%51 = icmp slt i64 %50, 1
br i1 %51, label %57, label %52
52: ; preds = %49
%53 = load i8*, i8** %9
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %52, %49, %44
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %3
br label %188
60: ; preds = %52
br label %63
61: ; preds = %25
%62 = call i32 (...) @print_usage()
store i32 2, i32* %3
br label %188
63: ; preds = %60, %42, %35
br label %20
64: ; preds = %20
%65 = load i8*, i8** %7
%66 = icmp eq i8* %65, null
br i1 %66, label %67, label %68
67: ; preds = %64
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8** %7
br label %68
68: ; preds = %67, %64
%69 = load i8*, i8** %7
%70 = load i32, i32* @O_RDONLY
%71 = call i32 @open(i8* %69, i32 %70)
store i32 %71, i32* %12
%72 = load i32, i32* %12
%73 = icmp slt i32 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %68
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
store i32 2, i32* %3
br label %188
77: ; preds = %68
%78 = call %struct.graph* (...) @graph_init()
store %struct.graph* %78, %struct.graph** %10
%79 = call %struct.dict* (...) @dict_init()
store %struct.dict* %79, %struct.dict** %11
%80 = load %struct.dict*, %struct.dict** %11
%81 = call i32 @populate_builtin_macros(%struct.dict* %80)
%82 = load %struct.dict*, %struct.dict** %11
%83 = call i32 @populate_environment_variables(%struct.dict* %82)
%84 = load i32, i32* %12
%85 = load %struct.graph*, %struct.graph** %10
%86 = load %struct.dict*, %struct.dict** %11
%87 = call i64 @parse_file(i32 %84, %struct.graph* %85, %struct.dict* %86)
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %96
89: ; preds = %77
%90 = load i32, i32* %12
%91 = call i32 @close(i32 %90)
%92 = load %struct.graph*, %struct.graph** %10
%93 = call i32 @graph_destroy(%struct.graph* %92)
%94 = load %struct.dict*, %struct.dict** %11
%95 = call i32 @dict_destroy(%struct.dict* %94)
store i32 2, i32* %3
br label %188
96: ; preds = %77
%97 = load i32, i32* %12
%98 = call i32 @close(i32 %97)
%99 = load i32, i32* @optind
%100 = load i32, i32* %4
%101 = icmp eq i32 %99, %100
br i1 %101, label %102, label %121
102: ; preds = %96
%103 = load %struct.graph*, %struct.graph** %10
%104 = call %struct.list* @graph_get_nodes(%struct.graph* %103)
store %struct.list* %104, %struct.list** %13
%105 = load %struct.list*, %struct.list** %13
%106 = call %struct.list_item* @list_head(%struct.list* %105)
store %struct.list_item* %106, %struct.list_item** %14
%107 = load %struct.list_item*, %struct.list_item** %14
%108 = icmp eq %struct.list_item* %107, null
br i1 %108, label %109, label %116
109: ; preds = %102
%110 = load i32, i32* @stderr
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%112 = load %struct.graph*, %struct.graph** %10
%113 = call i32 @graph_destroy(%struct.graph* %112)
%114 = load %struct.dict*, %struct.dict** %11
%115 = call i32 @dict_destroy(%struct.dict* %114)
store i32 2, i32* %3
br label %188
116: ; preds = %102
%117 = load %struct.list_item*, %struct.list_item** %14
%118 = call %struct.graph_node* @list_get_data(%struct.list_item* %117)
store %struct.graph_node* %118, %struct.graph_node** %15
%119 = load %struct.graph_node*, %struct.graph_node** %15
%120 = call i32 @graph_node_mark_target(%struct.graph_node* %119)
br label %160
121: ; preds = %96
%122 = load i32, i32* @optind
store i32 %122, i32* %16
br label %123
123: ; preds = %156, %121
%124 = load i32, i32* %16
%125 = load i32, i32* %4
%126 = icmp slt i32 %124, %125
br i1 %126, label %127, label %159
127: ; preds = %123
%128 = load i8**, i8*** %5
%129 = load i32, i32* %16
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i8*, i8** %128, i64 %130
%132 = load i8*, i8** %131
%133 = call %struct.string* @string_init(i8* %132)
store %struct.string* %133, %struct.string** %17
%134 = load %struct.graph*, %struct.graph** %10
%135 = load %struct.string*, %struct.string** %17
%136 = call %struct.graph_node* @graph_get_node_by_name(%struct.graph* %134, %struct.string* %135)
store %struct.graph_node* %136, %struct.graph_node** %18
%137 = load %struct.string*, %struct.string** %17
%138 = call i32 @string_destroy(%struct.string* %137)
%139 = load %struct.graph_node*, %struct.graph_node** %18
%140 = icmp eq %struct.graph_node* %139, null
br i1 %140, label %141, label %153
141: ; preds = %127
%142 = load i32, i32* @stderr
%143 = load i8**, i8*** %5
%144 = load i32, i32* %16
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i8*, i8** %143, i64 %145
%147 = load i8*, i8** %146
%148 = call i32 (i32, i8*, ...) @fprintf(i32 %142, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %147)
%149 = load %struct.graph*, %struct.graph** %10
%150 = call i32 @graph_destroy(%struct.graph* %149)
%151 = load %struct.dict*, %struct.dict** %11
%152 = call i32 @dict_destroy(%struct.dict* %151)
store i32 2, i32* %3
br label %188
153: ; preds = %127
%154 = load %struct.graph_node*, %struct.graph_node** %18
%155 = call i32 @graph_node_mark_target(%struct.graph_node* %154)
br label %156
156: ; preds = %153
%157 = load i32, i32* %16
%158 = add nsw i32 %157, 1
store i32 %158, i32* %16
br label %123
159: ; preds = %123
br label %160
160: ; preds = %159, %116
%161 = load %struct.graph*, %struct.graph** %10
%162 = call i64 @update_all_files_info(%struct.graph* %161)
%163 = icmp ne i64 %162, 0
br i1 %163, label %164, label %169
164: ; preds = %160
%165 = load %struct.dict*, %struct.dict** %11
%166 = call i32 @dict_destroy(%struct.dict* %165)
%167 = load %struct.graph*, %struct.graph** %10
%168 = call i32 @graph_destroy(%struct.graph* %167)
store i32 2, i32* %3
br label %188
169: ; preds = %160
%170 = load %struct.graph*, %struct.graph** %10
%171 = call i64 @graph_process(%struct.graph* %170)
%172 = icmp ne i64 %171, 0
br i1 %172, label %173, label %178
173: ; preds = %169
%174 = load %struct.dict*, %struct.dict** %11
%175 = call i32 @dict_destroy(%struct.dict* %174)
%176 = load %struct.graph*, %struct.graph** %10
%177 = call i32 @graph_destroy(%struct.graph* %176)
store i32 2, i32* %3
br label %188
178: ; preds = %169
%179 = load %struct.graph*, %struct.graph** %10
%180 = load %struct.dict*, %struct.dict** %11
%181 = load i64, i64* %8
%182 = call i32 @run_jobs(%struct.graph* %179, %struct.dict* %180, i64 %181)
store i32 %182, i32* %19
%183 = load %struct.dict*, %struct.dict** %11
%184 = call i32 @dict_destroy(%struct.dict* %183)
%185 = load %struct.graph*, %struct.graph** %10
%186 = call i32 @graph_destroy(%struct.graph* %185)
%187 = load i32, i32* %19
store i32 %187, i32* %3
br label %188
188: ; preds = %178, %173, %164, %141, %109, %89, %74, %61, %57, %39, %31
%189 = load i32, i32* %3
ret i32 %189
}

LLVM IR (-O2):
%struct.graph = type { i32 }
%struct.dict = type { i32 }
%struct.list = type { i32 }
%struct.list_item = type { i32 }
%struct.graph_node = type { i32 }
%struct.string = type { i32 }
@.str = [7 x i8] c"C:f:j:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [34 x i8] c"Could not change directory to %s\0A\00"
@.str.2 = [36 x i8] c"Option -f specified multiple times\0A\00"
@errno = global i32 0
@.str.3 = [37 x i8] c"Invalid numeric value for option -j\0A\00"
@.str.4 = [9 x i8] c"Makefile\00"
@O_RDONLY = global i32 0
@.str.5 = [29 x i8] c"Could not open the makefile\0A\00"
@optind = global i32 0
@.str.6 = [21 x i8] c"No target specified\0A\00"
@.str.7 = [21 x i8] c"Unknown target \22%s\22\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
br label %5
5: ; preds = %34, %2
%6 = phi i64 [ %29, %34 ], [ 1, %2 ]
%7 = phi i8* [ %9, %34 ], [ null, %2 ]
br label %8
8: ; preds = %5, %25
%9 = phi i8* [ %7, %5 ], [ %26, %25 ]
br label %10
10: ; preds = %8, %12
%11 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %11, label %41 [
i32 -1, label %43
i32 67, label %12
i32 102, label %20
i32 106, label %27
]
12: ; preds = %10
%13 = load i8*, i8** @optarg
%14 = tail call i32 @chdir(i8* %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %10, label %16
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = load i8*, i8** @optarg
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %118
20: ; preds = %10
%21 = icmp eq i8* %9, null
br i1 %21, label %25, label %22
22: ; preds = %20
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %118
25: ; preds = %20
%26 = load i8*, i8** @optarg
br label %8
27: ; preds = %10
store i32 0, i32* @errno
%28 = load i8*, i8** @optarg
%29 = call i64 @strtol(i8* %28, i8** %3, i32 10)
%30 = load i32, i32* @errno
%31 = icmp ne i32 %30, 0
%32 = icmp slt i64 %29, 1
%33 = select i1 %31, i1 true, i1 %32
br i1 %33, label %38, label %34
34: ; preds = %27
%35 = load i8*, i8** %3
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 0
br i1 %37, label %5, label %38
38: ; preds = %34, %27
%39 = load i32, i32* @stderr
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %118
41: ; preds = %10
%42 = tail call i32 (...) @print_usage()
br label %118
43: ; preds = %10
%44 = icmp eq i8* %9, null
%45 = select i1 %44, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %9
%46 = load i32, i32* @O_RDONLY
%47 = tail call i32 @open(i8* %45, i32 %46)
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %43
%50 = load i32, i32* @stderr
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %118
52: ; preds = %43
%53 = tail call %struct.graph* (...) @graph_init()
%54 = tail call %struct.dict* (...) @dict_init()
%55 = tail call i32 @populate_builtin_macros(%struct.dict* %54)
%56 = tail call i32 @populate_environment_variables(%struct.dict* %54)
%57 = tail call i64 @parse_file(i32 %47, %struct.graph* %53, %struct.dict* %54)
%58 = icmp eq i64 %57, 0
%59 = tail call i32 @close(i32 %47)
br i1 %58, label %63, label %60
60: ; preds = %52
%61 = tail call i32 @graph_destroy(%struct.graph* %53)
%62 = tail call i32 @dict_destroy(%struct.dict* %54)
br label %118
63: ; preds = %52
%64 = load i32, i32* @optind
%65 = icmp eq i32 %64, %0
br i1 %65, label %71, label %66
66: ; preds = %63
%67 = icmp slt i32 %64, %0
br i1 %67, label %68, label %102
68: ; preds = %66
%69 = sext i32 %64 to i64
%70 = sext i32 %0 to i64
br label %83
71: ; preds = %63
%72 = tail call %struct.list* @graph_get_nodes(%struct.graph* %53)
%73 = tail call %struct.list_item* @list_head(%struct.list* %72)
%74 = icmp eq %struct.list_item* %73, null
br i1 %74, label %75, label %80
75: ; preds = %71
%76 = load i32, i32* @stderr
%77 = tail call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%78 = tail call i32 @graph_destroy(%struct.graph* %53)
%79 = tail call i32 @dict_destroy(%struct.dict* %54)
br label %118
80: ; preds = %71
%81 = tail call %struct.graph_node* @list_get_data(%struct.list_item* %73)
%82 = tail call i32 @graph_node_mark_target(%struct.graph_node* %81)
br label %102
83: ; preds = %68, %98
%84 = phi i64 [ %69, %68 ], [ %100, %98 ]
%85 = getelementptr inbounds i8*, i8** %1, i64 %84
%86 = load i8*, i8** %85
%87 = tail call %struct.string* @string_init(i8* %86)
%88 = tail call %struct.graph_node* @graph_get_node_by_name(%struct.graph* %53, %struct.string* %87)
%89 = tail call i32 @string_destroy(%struct.string* %87)
%90 = icmp eq %struct.graph_node* %88, null
br i1 %90, label %91, label %98
91: ; preds = %83
%92 = getelementptr inbounds i8*, i8** %1, i64 %84
%93 = load i32, i32* @stderr
%94 = load i8*, i8** %92
%95 = tail call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %94)
%96 = tail call i32 @graph_destroy(%struct.graph* %53)
%97 = tail call i32 @dict_destroy(%struct.dict* %54)
br label %118
98: ; preds = %83
%99 = tail call i32 @graph_node_mark_target(%struct.graph_node* %88)
%100 = add nsw i64 %84, 1
%101 = icmp eq i64 %100, %70
br i1 %101, label %102, label %83
102: ; preds = %98, %66, %80
%103 = tail call i64 @update_all_files_info(%struct.graph* %53)
%104 = icmp eq i64 %103, 0
br i1 %104, label %108, label %105
105: ; preds = %102
%106 = tail call i32 @dict_destroy(%struct.dict* %54)
%107 = tail call i32 @graph_destroy(%struct.graph* %53)
br label %118
108: ; preds = %102
%109 = tail call i64 @graph_process(%struct.graph* %53)
%110 = icmp eq i64 %109, 0
br i1 %110, label %114, label %111
111: ; preds = %108
%112 = tail call i32 @dict_destroy(%struct.dict* %54)
%113 = tail call i32 @graph_destroy(%struct.graph* %53)
br label %118
114: ; preds = %108
%115 = tail call i32 @run_jobs(%struct.graph* %53, %struct.dict* %54, i64 %6)
%116 = tail call i32 @dict_destroy(%struct.dict* %54)
%117 = tail call i32 @graph_destroy(%struct.graph* %53)
br label %118
118: ; preds = %91, %75, %49, %60, %105, %111, %114, %41, %38, %22, %16
%119 = phi i32 [ 2, %41 ], [ 2, %38 ], [ 2, %22 ], [ 2, %16 ], [ 2, %49 ], [ 2, %60 ], [ 2, %105 ], [ 2, %111 ], [ %115, %114 ], [ 2, %75 ], [ 2, %91 ]
ret i32 %119
}