#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 execvp(char *, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, int);
int setuid(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
main(int argc, char *argv[]) {
  int rc, cc;
  cc = setuid(0);
  rc = execvp("/usr/sbin/virtualmin", argv);
  if ((rc != 0) || (cc != 0)) {
    fprintf(stderr, "__ %s:  failed %d  %d\n", argv[0], rc, cc);
    return 1;
  }
  return 0;
}


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)
xor    %edi,%edi
call   1050 <setuid@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea5(%rip),%rdi
call   1040 <execvp@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1177 <main+0x47>
cmpl   $0x0,-0x18(%rbp)
je     11a6 <main+0x76>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xe80(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ad <main+0x7d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
xor    %ebp,%ebp
xor    %edi,%edi
call   1050 <setuid@plt>
mov    %eax,%r14d
lea    0xeb6(%rip),%rdi
mov    %rbx,%rsi
call   1040 <execvp@plt>
mov    %eax,%ecx
or     %r14d,%ecx
je     117b <main+0x4b>
mov    0x2e80(%rip),%rcx
mov    (%rcx),%edi
mov    (%rbx),%rdx
lea    0xea9(%rip),%rsi
mov    %eax,%ecx
mov    %r14d,%r8d
call   1030 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"/usr/sbin/virtualmin\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"__ %s: failed %d %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @setuid(i32 0)
store i32 %8, i32* %7
%9 = load i8**, i8*** %5
%10 = call i32 @execvp(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp ne i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %13, %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %20, i32 %21, i32 %22)
store i32 1, i32* %3
br label %25
24: ; preds = %13
store i32 0, i32* %3
br label %25
25: ; preds = %24, %16
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [21 x i8] c"/usr/sbin/virtualmin\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"__ %s: failed %d %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @setuid(i32 0)
%4 = tail call i32 @execvp(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %1)
%5 = icmp ne i32 %4, 0
%6 = icmp ne i32 %3, 0
%7 = select i1 %5, i1 true, i1 %6
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 %4, i32 %3)
br label %12
12: ; preds = %2, %8
%13 = phi i32 [ 1, %8 ], [ 0, %2 ]
ret i32 %13
}