main(argc, argv) int argc;
char *argv[];
{
  if (strcmp("xyzzy", argv[0]) == 0) {
    if ((argc == 2) && (strcmp("-c", argv[1]) == 0)) {
      if (pass() == 0) {
        printf("poof\n");
        suid();
      } else
        printf("Permission denied\n");
    } else
      printf("Nothing happens.\n");
  } else {
    execv("/usr/bin/ping", argv);
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7c(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1209 <main+0xa9>
cmpl   $0x2,-0x8(%rbp)
jne    11f6 <main+0x96>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe5b(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11f6 <main+0x96>
mov    $0x0,%al
call   1030 <pass@plt>
cmp    $0x0,%eax
jne    11e3 <main+0x83>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <suid@plt>
jmp    11f1 <main+0x91>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1204 <main+0xa4>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1225 <main+0xc5>
mov    -0x10(%rbp),%rsi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1080 <execv@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rsi
lea    0xe8e(%rip),%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11b9 <main+0x59>
cmp    $0x2,%ebp
jne    11d4 <main+0x74>
mov    0x8(%rbx),%rsi
lea    0xe7b(%rip),%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11d4 <main+0x74>
xor    %eax,%eax
call   1040 <pass@plt>
test   %eax,%eax
jne    11e7 <main+0x87>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <suid@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe49(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <execv@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe3c(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe3a(%rip),%rdi
jmp    11db <main+0x7b>

LLVM IR (-O0):
@.str = [6 x i8] c"xyzzy\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [6 x i8] c"poof\0A\00"
@.str.3 = [19 x i8] c"Permission denied\0A\00"
@.str.4 = [18 x i8] c"Nothing happens.\0A\00"
@.str.5 = [14 x i8] c"/usr/bin/ping\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 0
%8 = load i8*, i8** %7
%9 = call i32 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %32
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %29
14: ; preds = %11
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %14
%21 = call i32 (...) @pass()
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 (...) @suid()
br label %28
26: ; preds = %20
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
br label %31
29: ; preds = %14, %11
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %28
br label %35
32: ; preds = %2
%33 = load i8**, i8*** %5
%34 = call i32 (i8*, i8**, ...) bitcast (i32 (...)* @execv to i32 (i8*, i8**, ...)*)(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %33)
unreachable
35: ; preds = %31
unreachable
}

LLVM IR (-O2):
@.str = [6 x i8] c"xyzzy\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.5 = [14 x i8] c"/usr/bin/ping\00"
@str = [17 x i8] c"Nothing happens.\00"
@str.6 = [18 x i8] c"Permission denied\00"
@str.7 = [5 x i8] c"poof\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 @strcmp(i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %23
6: ; preds = %2
%7 = icmp eq i32 %0, 2
br i1 %7, label %8, label %21
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = tail call i32 (...) @pass()
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.7, i64 0, i64 0))
%18 = tail call i32 (...) @suid()
br label %25
19: ; preds = %13
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
br label %25
21: ; preds = %8, %6
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %25
23: ; preds = %2
%24 = tail call i32 (i8*, i8**, ...) bitcast (i32 (...)* @execv to i32 (i8*, i8**, ...)*)(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %1)
tail call void @exit(i32 1)
unreachable
25: ; preds = %21, %19, %16
tail call void @exit(i32 0)
unreachable
}