#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 scalar_t__ uid_t;

/* Variables and functions */
char *blurb();
int /*<<< orphan*/ exec_complex_command(char const *, char const *);
int /*<<< orphan*/ exec_simple_command(char const *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ geteuid();
scalar_t__ getuid();
int /*<<< orphan*/ nice_process(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strpbrk(char const *, char *);
void exec_command(const char *shell, const char *command, int nice_level) {
  int hairy_p;
  nice_process(nice_level);
  hairy_p = !!strpbrk(command, "*?$&!<>[];`'\\\"=");
  if (getuid() == (uid_t)0 || geteuid() == (uid_t)0) {
    fprintf(stderr, "%s: we're still running as root!  Disaster!\n", blurb());
    exit(-1);
  }
  if (hairy_p)
    exec_complex_command(shell, command);
  else
    exec_simple_command(command);
}


x86 assembly (clang, -O0):
<exec_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   10b0 <nice_process@plt>
mov    -0x10(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1080 <strpbrk@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <getuid@plt>
cmp    $0x0,%rax
je     11ef <exec_command+0x5f>
mov    $0x0,%al
call   1040 <geteuid@plt>
cmp    $0x0,%rax
jne    121e <exec_command+0x8e>
mov    0x2dea(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1070 <blurb@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe01(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
cmpl   $0x0,-0x18(%rbp)
je     123a <exec_command+0xaa>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <exec_complex_command@plt>
jmp    1243 <exec_command+0xb3>
mov    -0x10(%rbp),%rdi
call   1090 <exec_simple_command@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exec_command>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %edx,%edi
call   10b0 <nice_process@plt>
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strpbrk@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <getuid@plt>
test   %rax,%rax
je     11e9 <exec_command+0x59>
xor    %eax,%eax
call   1040 <geteuid@plt>
test   %rax,%rax
je     11e9 <exec_command+0x59>
test   %ebp,%ebp
je     11dd <exec_command+0x4d>
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <exec_complex_command@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1090 <exec_simple_command@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1070 <blurb@plt>
lea    0xe10(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"*?$&!<>[];`'\\\22=\00"
@stderr = global i32 0
@.str.1 = [45 x i8] c"%s: we're still running as root! Disaster!\0A\00"
define void @exec_command(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = call i32 @nice_process(i32 %8)
%10 = load i8*, i8** %5
%11 = call i32 @strpbrk(i8* %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
%14 = xor i1 %13, true
%15 = zext i1 %14 to i32
store i32 %15, i32* %7
%16 = call i64 (...) @getuid()
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %3
%19 = call i64 (...) @geteuid()
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %18, %3
%22 = load i32, i32* @stderr
%23 = call i8* (...) @blurb()
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 -1)
unreachable
26: ; preds = %18
%27 = load i32, i32* %7
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = call i32 @exec_complex_command(i8* %30, i8* %31)
br label %36
33: ; preds = %26
%34 = load i8*, i8** %5
%35 = call i32 @exec_simple_command(i8* %34)
br label %36
36: ; preds = %33, %29
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"*?$&!<>[];`'\\\22=\00"
@stderr = global i32 0
@.str.1 = [45 x i8] c"%s: we're still running as root! Disaster!\0A\00"
define void @exec_command(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @nice_process(i32 %2)
%5 = tail call i32 @strpbrk(i8* %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
%7 = tail call i64 (...) @getuid()
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = tail call i64 (...) @geteuid()
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9, %3
%13 = load i32, i32* @stderr
%14 = tail call i8* (...) @blurb()
%15 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 -1)
unreachable
17: ; preds = %9
br i1 %6, label %20, label %18
18: ; preds = %17
%19 = tail call i32 @exec_complex_command(i8* %0, i8* %1)
br label %22
20: ; preds = %17
%21 = tail call i32 @exec_simple_command(i8* %1)
br label %22
22: ; preds = %20, %18
ret void
}