#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 */

/* Variables and functions */
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ parse_dep_file(void *, char const *, int);
int /*<<< orphan*/ printf(char *, char const *, char const *);
void *read_file(char const *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  const char *depfile, *target, *cmdline;
  int insert_extra_deps = 0;
  void *buf;
  if (argc == 5 && !strcmp(argv[1], "-e")) {
    insert_extra_deps = 1;
    argv++;
  } else if (argc != 4)
    usage();
  depfile = argv[1];
  target = argv[2];
  cmdline = argv[3];
  printf("cmd_%s := %s\n\n", target, cmdline);
  buf = read_file(depfile);
  parse_dep_file(buf, target, insert_extra_deps);
  free(buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x5,-0x8(%rbp)
jne    11bc <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11bc <main+0x5c>
movl   $0x1,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11d2 <main+0x72>
cmpl   $0x4,-0x8(%rbp)
je     11cd <main+0x6d>
mov    $0x0,%al
call   1080 <usage@plt>
jmp    11d2 <main+0x72>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xdfe(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <read_file@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <parse_dep_file@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
je     1194 <main+0x34>
cmp    $0x5,%edi
jne    1188 <main+0x28>
mov    0x8(%rbx),%rdi
lea    0xe81(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1199 <main+0x39>
xor    %r14d,%r14d
xor    %eax,%eax
call   1080 <usage@plt>
jmp    11a3 <main+0x43>
xor    %r14d,%r14d
jmp    11a3 <main+0x43>
add    $0x8,%rbx
mov    $0x1,%r14d
mov    0x8(%rbx),%r15
mov    0x10(%rbx),%rbp
mov    0x18(%rbx),%rdx
lea    0xe4d(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    %r15,%rdi
call   1070 <read_file@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1030 <parse_dep_file@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-e\00"
@.str.1 = [15 x i8] c"cmd_%s := %s\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 5
br i1 %12, label %13, label %22
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %13
store i32 1, i32* %9
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i32 1
store i8** %21, i8*** %5
br label %28
22: ; preds = %13, %2
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 4
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (...) @usage()
br label %27
27: ; preds = %25, %22
br label %28
28: ; preds = %27, %19
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
store i8* %31, i8** %6
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
store i8* %34, i8** %7
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
store i8* %37, i8** %8
%38 = load i8*, i8** %7
%39 = load i8*, i8** %8
%40 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %38, i8* %39)
%41 = load i8*, i8** %6
%42 = call i8* @read_file(i8* %41)
store i8* %42, i8** %10
%43 = load i8*, i8** %10
%44 = load i8*, i8** %7
%45 = load i32, i32* %9
%46 = call i32 @parse_dep_file(i8* %43, i8* %44, i32 %45)
%47 = load i8*, i8** %10
%48 = call i32 @free(i8* %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-e\00"
@.str.1 = [15 x i8] c"cmd_%s := %s\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %8 [
i32 5, label %3
i32 4, label %10
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %5, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %3, %2
%9 = tail call i32 (...) @usage()
br label %10
10: ; preds = %3, %2, %8
%11 = phi i32 [ 0, %8 ], [ 0, %2 ], [ 1, %3 ]
%12 = phi i8** [ %1, %8 ], [ %1, %2 ], [ %4, %3 ]
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %12, i64 2
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8*, i8** %12, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* %18)
%20 = tail call i8* @read_file(i8* %14)
%21 = tail call i32 @parse_dep_file(i8* %20, i8* %16, i32 %11)
%22 = tail call i32 @free(i8* %20)
ret i32 0
}