main(argc, argv) int argc;
char *argv[];
{
  int pid, i, j;
  int letter;
  char **argblk;
  argblk = (char **)malloc((argc + 2) * sizeof(char *));
  if (!argblk) {
    perror(argv[0]);
    exit(2);
  }
  i = strlen(argv[0]);
  letter = argv[0][i - 1];
  argblk[0] = "elvis";
  i = j = 1;
  switch (letter) {
  case 'w':
  case 'W':
    argblk[i++] = "-R";
    break;
  case 'x':
  case 'X':
    argblk[i++] = "-e";
    break;
  case 't':
  case 'T':
    argblk[i++] = "-i";
    break;
  }
  while (j < argc) {
    argblk[i++] = argv[j++];
  }
  argblk[i] = (char *)0;
  (void)execvp(argblk[0], argblk);
  perror("elvis");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x2,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    119f <main+0x4f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x0,%al
call   1050 <perror@plt>
mov    $0x2,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
lea    0xe30(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x54,%eax
je     128e <main+0x13e>
jmp    11f5 <main+0xa5>
mov    -0x2c(%rbp),%eax
sub    $0x57,%eax
je     124a <main+0xfa>
jmp    1206 <main+0xb6>
mov    -0x2c(%rbp),%eax
sub    $0x58,%eax
je     126c <main+0x11c>
jmp    1217 <main+0xc7>
mov    -0x2c(%rbp),%eax
sub    $0x74,%eax
je     128e <main+0x13e>
jmp    1228 <main+0xd8>
mov    -0x2c(%rbp),%eax
sub    $0x77,%eax
je     124a <main+0xfa>
jmp    1239 <main+0xe9>
mov    -0x2c(%rbp),%eax
sub    $0x78,%eax
je     126c <main+0x11c>
jmp    12ab <main+0x15b>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
lea    0xda3(%rip),%rdx
mov    %rdx,(%rax,%rcx,8)
jmp    12ab <main+0x15b>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
lea    0xd84(%rip),%rdx
mov    %rdx,(%rax,%rcx,8)
jmp    12ab <main+0x15b>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
lea    0xd65(%rip),%rdx
mov    %rdx,(%rax,%rcx,8)
jmp    12b0 <main+0x160>
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12ed <main+0x19d>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    12b0 <main+0x160>
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1060 <execvp@plt>
lea    0xcea(%rip),%rdi
mov    $0x0,%al
call   1050 <perror@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%r14d
movslq %edi,%rax
lea    0x10(,%rax,8),%rdi
call   1050 <malloc@plt>
mov    (%r15),%rbx
test   %rax,%rax
je     1263 <main+0x103>
mov    %rax,%r12
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
cltq
movsbl (%rbx,%rax,1),%eax
lea    0xe5b(%rip),%rcx
mov    %rcx,(%r12)
mov    $0x1,%ebx
add    $0xffffffac,%eax
cmp    $0x24,%eax
ja     1209 <main+0xa9>
movabs $0x100000001,%rcx
bt     %rax,%rcx
jb     11ef <main+0x8f>
movabs $0x800000008,%rcx
bt     %rax,%rcx
jb     11f8 <main+0x98>
movabs $0x1000000010,%rcx
bt     %rax,%rcx
jae    1209 <main+0xa9>
lea    0xe1c(%rip),%rax
jmp    11ff <main+0x9f>
lea    0xe16(%rip),%rax
jmp    11ff <main+0x9f>
lea    0xe07(%rip),%rax
mov    %rax,0x8(%r12)
mov    $0x2,%ebx
cmp    $0x2,%r14d
jl     122f <main+0xcf>
mov    %ebx,%eax
lea    (%r12,%rax,8),%rdi
add    $0x8,%r15
lea    -0x1(%r14),%edx
shl    $0x3,%rdx
mov    %r15,%rsi
call   1040 <memcpy@plt>
add    %r14d,%ebx
add    $0xffffffff,%ebx
mov    %ebx,%eax
movq   $0x0,(%r12,%rax,8)
mov    (%r12),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <execvp@plt>
lea    0xdb2(%rip),%rdi
xor    %eax,%eax
call   1060 <perror@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <perror@plt>
mov    $0x2,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"elvis\00"
@.str.1 = [3 x i8] c"-R\00"
@.str.2 = [3 x i8] c"-e\00"
@.str.3 = [3 x i8] c"-i\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 2
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 8
%15 = call i8* @malloc(i64 %14)
%16 = bitcast i8* %15 to i8**
store i8** %16, i8*** %10
%17 = load i8**, i8*** %10
%18 = icmp ne i8** %17, null
br i1 %18, label %24, label %19
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* %22)
unreachable
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i64 @strlen(i8* %27)
%29 = trunc i64 %28 to i32
store i32 %29, i32* %7
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = load i32, i32* %7
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
store i32 %38, i32* %9
%39 = load i8**, i8*** %10
%40 = getelementptr inbounds i8*, i8** %39, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %40
store i32 1, i32* %8
store i32 1, i32* %7
%41 = load i32, i32* %9
switch i32 %41, label %60 [
i32 119, label %42
i32 87, label %42
i32 120, label %48
i32 88, label %48
i32 116, label %54
i32 84, label %54
]
42: ; preds = %24, %24
%43 = load i8**, i8*** %10
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds i8*, i8** %43, i64 %46
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %47
br label %60
48: ; preds = %24, %24
%49 = load i8**, i8*** %10
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds i8*, i8** %49, i64 %52
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %53
br label %60
54: ; preds = %24, %24
%55 = load i8**, i8*** %10
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
%58 = sext i32 %56 to i64
%59 = getelementptr inbounds i8*, i8** %55, i64 %58
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %59
br label %60
60: ; preds = %24, %54, %48, %42
br label %61
61: ; preds = %65, %60
%62 = load i32, i32* %8
%63 = load i32, i32* %4
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %77
65: ; preds = %61
%66 = load i8**, i8*** %5
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
%69 = sext i32 %67 to i64
%70 = getelementptr inbounds i8*, i8** %66, i64 %69
%71 = load i8*, i8** %70
%72 = load i8**, i8*** %10
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
store i32 %74, i32* %7
%75 = sext i32 %73 to i64
%76 = getelementptr inbounds i8*, i8** %72, i64 %75
store i8* %71, i8** %76
br label %61
77: ; preds = %61
%78 = load i8**, i8*** %10
%79 = load i32, i32* %7
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8*, i8** %78, i64 %80
store i8* null, i8** %81
%82 = load i8**, i8*** %10
%83 = getelementptr inbounds i8*, i8** %82, i64 0
%84 = load i8*, i8** %83
%85 = load i8**, i8*** %10
%86 = call i32 (i8*, i8**, ...) bitcast (i32 (...)* @execvp to i32 (i8*, i8**, ...)*)(i8* %84, i8** %85)
%87 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%88 = load i32, i32* %3
ret i32 %88
}

LLVM IR (-O2):
@.str = [6 x i8] c"elvis\00"
@.str.1 = [3 x i8] c"-R\00"
@.str.2 = [3 x i8] c"-e\00"
@.str.3 = [3 x i8] c"-i\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add nsw i32 %0, 2
%4 = sext i32 %3 to i64
%5 = shl nsw i64 %4, 3
%6 = tail call i8* @malloc(i64 %5)
%7 = bitcast i8* %6 to i8**
%8 = icmp eq i8* %6, null
%9 = load i8*, i8** %1
br i1 %8, label %10, label %12
10: ; preds = %2
%11 = tail call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* %9)
tail call void @exit(i32 2)
unreachable
12: ; preds = %2
%13 = tail call i64 @strlen(i8* dereferenceable(1) %9)
%14 = shl i64 %13, 32
%15 = add i64 %14, -4294967296
%16 = ashr exact i64 %15, 32
%17 = getelementptr inbounds i8, i8* %9, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %7
switch i32 %19, label %25 [
i32 119, label %22
i32 87, label %22
i32 120, label %20
i32 88, label %20
i32 116, label %21
i32 84, label %21
]
20: ; preds = %12, %12
br label %22
21: ; preds = %12, %12
br label %22
22: ; preds = %12, %12, %20, %21
%23 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %21 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %20 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %12 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %12 ]
%24 = getelementptr inbounds i8*, i8** %7, i64 1
store i8* %23, i8** %24
br label %25
25: ; preds = %22, %12
%26 = phi i32 [ 1, %12 ], [ 2, %22 ]
%27 = icmp sgt i32 %0, 1
br i1 %27, label %28, label %40
28: ; preds = %25
%29 = shl nuw nsw i32 %26, 3
%30 = zext i32 %29 to i64
%31 = getelementptr i8, i8* %6, i64 %30
%32 = getelementptr i8*, i8** %1, i64 1
%33 = bitcast i8** %32 to i8*
%34 = add nsw i32 %0, -1
%35 = zext i32 %34 to i64
%36 = shl nuw nsw i64 %35, 3
%37 = add nsw i32 %0, -2
%38 = add nuw nsw i32 %26, %37
%39 = add nuw i32 %38, 1
br label %40
40: ; preds = %28, %25
%41 = phi i32 [ %26, %25 ], [ %39, %28 ]
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %7, i64 %42
store i8* null, i8** %43
%44 = load i8*, i8** %7
%45 = tail call i32 (i8*, i8**, ...) bitcast (i32 (...)* @execvp to i32 (i8*, i8**, ...)*)(i8* %44, i8** %7)
%46 = tail call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
ret i32 0
}