#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 */
typedef int /*<<< orphan*/ uid_t;

/* Variables and functions */
int EXIT_FAILURE;
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int setreuid(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv, char **env) {
  if (argc < 2) {
    fprintf(stderr, "%s: Must pass in program to run\n", argv[0]);
    exit(1);
  }
  uid_t ruid = 0;
  uid_t euid = 0;
  if (setreuid(ruid, euid) == -1) {
    fprintf(stderr, "%s: Must chmod u+s this execuatble\n", argv[0]);
    exit(1);
  }
  execvp(argv[1], &(argv[1]));
  perror(argv[1]);
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119a <main+0x4a>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe75(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1040 <setreuid@plt>
cmp    $0xffffffff,%eax
jne    11e2 <main+0x92>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4e(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1060 <execvp@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <perror@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     116e <main+0x1e>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe94(%rip),%rsi
jmp    118f <main+0x3f>
xor    %edi,%edi
xor    %esi,%esi
call   1040 <setreuid@plt>
cmp    $0xffffffff,%eax
jne    119e <main+0x4e>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe92(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0x8(%rbx),%rsi
mov    0x8(%rbx),%rdi
call   1060 <execvp@plt>
mov    0x8(%rbx),%rdi
call   1050 <perror@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"%s: Must pass in program to run\0A\00"
@.str.1 = [36 x i8] c"%s: Must chmod u+s this execuatble\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %6
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %3
store i32 0, i32* %8
store i32 0, i32* %9
%20 = load i32, i32* %8
%21 = load i32, i32* %9
%22 = call i32 @setreuid(i32 %20, i32 %21)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %31
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = load i8**, i8*** %6
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %19
%32 = load i8**, i8*** %6
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = load i8**, i8*** %6
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = call i32 @execvp(i8* %34, i8** %36)
%38 = load i8**, i8*** %6
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @perror(i8* %40)
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"%s: Must pass in program to run\0A\00"
@.str.1 = [36 x i8] c"%s: Must chmod u+s this execuatble\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1, i8** nocapture readnone %2) {
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %10
5: ; preds = %3
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %3
%11 = tail call i32 @setreuid(i32 0, i32 0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %1
%16 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %10
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i32 @execvp(i8* %20, i8** %19)
%22 = load i8*, i8** %19
%23 = tail call i32 @perror(i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = tail call i32 @exit(i32 %24)
unreachable
}