#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*/ errno;
int /*<<< orphan*/ execv(char *, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
char *getenv(char *);
int /*<<< orphan*/ perror(char *);
int setenv(char *, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  for (char **argv_iter = argv + 1; *argv_iter; ++argv_iter) {
    char *arg = *argv_iter;
    switch (arg[0]) {
    case '\\':
      switch (arg[1]) {
      case '\\':
      case '@':
        *argv_iter = arg + 1;
        break;
      }
      break;
    case '@':
      *argv_iter = getenv(arg + 1);
      break;
    }
  }
  if (setenv("builder", argv[1], 1) == -1) {
    perror("Setting $builder");
    return 1;
  }
  execv(argv[1], argv + 1);
  fprintf(stderr, "Executing %s: %s", argv[1], strerror(errno));
  return 1;
}


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)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     122f <main+0xcf>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
sub    $0x40,%eax
je     1202 <main+0xa2>
jmp    11b3 <main+0x53>
mov    -0x24(%rbp),%eax
sub    $0x5c,%eax
jne    1219 <main+0xb9>
jmp    11c4 <main+0x64>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x28(%rbp)
sub    $0x40,%eax
je     11ee <main+0x8e>
jmp    11dd <main+0x7d>
mov    -0x28(%rbp),%eax
sub    $0x5c,%eax
jne    11fd <main+0x9d>
jmp    11ee <main+0x8e>
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1219 <main+0xb9>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    121e <main+0xbe>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    1182 <main+0x22>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdcb(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
cmp    $0xffffffff,%eax
jne    1269 <main+0x109>
lea    0xda8(%rip),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c1 <main+0x161>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1080 <execv@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
lea    0xd5c(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0x8(%rsi),%r14
mov    0x8(%rsi),%rax
test   %rax,%rax
je     11c2 <main+0x62>
mov    %rsi,%rbx
add    $0x10,%rbx
jmp    119c <main+0x3c>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
mov    %rax,%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbx)
mov    (%rbx),%rax
add    $0x8,%rbx
test   %rax,%rax
je     11bd <main+0x5d>
movsbl (%rax),%ecx
cmp    $0x40,%ecx
je     1180 <main+0x20>
cmp    $0x5c,%ecx
jne    1190 <main+0x30>
movsbl 0x1(%rax),%ecx
add    $0x1,%rax
cmp    $0x40,%ecx
je     118c <main+0x2c>
cmp    $0x5c,%ecx
je     118c <main+0x2c>
jmp    1190 <main+0x30>
mov    (%r14),%rsi
jmp    11c4 <main+0x64>
xor    %esi,%esi
lea    0xe3e(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
cmp    $0xffffffff,%eax
je     1220 <main+0xc0>
mov    (%r14),%rdi
mov    %r14,%rsi
call   1080 <execv@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%r14
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe0b(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
call   1050 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xdd9(%rip),%rdi
call   1060 <perror@plt>
jmp    1213 <main+0xb3>

LLVM IR (-O0):
@.str = [8 x i8] c"builder\00"
@.str.1 = [17 x i8] c"Setting $builder\00"
@stderr = global i32 0
@.str.2 = [17 x i8] c"Executing %s: %s\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
store i8** %9, i8*** %6
br label %10
10: ; preds = %37, %2
%11 = load i8**, i8*** %6
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %40
14: ; preds = %10
%15 = load i8**, i8*** %6
%16 = load i8*, i8** %15
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %36 [
i32 92, label %21
i32 64, label %31
]
21: ; preds = %14
%22 = load i8*, i8** %7
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
switch i32 %25, label %30 [
i32 92, label %26
i32 64, label %26
]
26: ; preds = %21, %21
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8**, i8*** %6
store i8* %28, i8** %29
br label %30
30: ; preds = %21, %26
br label %36
31: ; preds = %14
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = call i8* @getenv(i8* %33)
%35 = load i8**, i8*** %6
store i8* %34, i8** %35
br label %36
36: ; preds = %14, %31, %30
br label %37
37: ; preds = %36
%38 = load i8**, i8*** %6
%39 = getelementptr inbounds i8*, i8** %38, i32 1
store i8** %39, i8*** %6
br label %10
40: ; preds = %10
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32 @setenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %43, i32 1)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %62
48: ; preds = %40
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = call i32 @execv(i8* %51, i8** %53)
%55 = load i32, i32* @stderr
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 1
%58 = load i8*, i8** %57
%59 = load i32, i32* @errno
%60 = call i8* @strerror(i32 %59)
%61 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %58, i8* %60)
store i32 1, i32* %3
br label %62
62: ; preds = %48, %46
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
@.str = [8 x i8] c"builder\00"
@.str.1 = [17 x i8] c"Setting $builder\00"
@stderr = global i32 0
@.str.2 = [17 x i8] c"Executing %s: %s\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %12
6: ; preds = %26
%7 = load i8*, i8** %3
br label %8
8: ; preds = %6, %2
%9 = phi i8* [ %7, %6 ], [ null, %2 ]
%10 = tail call i32 @setenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %9, i32 1)
%11 = icmp eq i32 %10, -1
br i1 %11, label %30, label %32
12: ; preds = %2, %26
%13 = phi i8* [ %28, %26 ], [ %4, %2 ]
%14 = phi i8** [ %27, %26 ], [ %3, %2 ]
%15 = load i8, i8* %13
%16 = sext i8 %15 to i32
switch i32 %16, label %26 [
i32 92, label %17
i32 64, label %21
]
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %13, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %26 [
i32 92, label %24
i32 64, label %24
]
21: ; preds = %12
%22 = getelementptr inbounds i8, i8* %13, i64 1
%23 = tail call i8* @getenv(i8* %22)
br label %24
24: ; preds = %17, %17, %21
%25 = phi i8* [ %23, %21 ], [ %18, %17 ], [ %18, %17 ]
store i8* %25, i8** %14
br label %26
26: ; preds = %24, %17, %12
%27 = getelementptr inbounds i8*, i8** %14, i64 1
%28 = load i8*, i8** %27
%29 = icmp eq i8* %28, null
br i1 %29, label %6, label %12
30: ; preds = %8
%31 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %40
32: ; preds = %8
%33 = load i8*, i8** %3
%34 = tail call i32 @execv(i8* %33, i8** %3)
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %3
%37 = load i32, i32* @errno
%38 = tail call i8* @strerror(i32 %37)
%39 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %36, i8* %38)
br label %40
40: ; preds = %32, %30
ret i32 1
}