#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SIGSEGV;
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *, ...);
scalar_t__ geteuid();
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ kill(int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc != 1) {
    errx(EXIT_FAILURE, "Usage:\n  %s", argv[0]);
  }
  if (geteuid() != 0) {
    errx(EXIT_FAILURE, "No running under root user");
  }
  kill(getpid(), SIGSEGV);
  return 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)
cmpl   $0x1,-0x8(%rbp)
je     117e <main+0x3e>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
mov    $0x0,%al
call   1050 <geteuid@plt>
cmp    $0x0,%rax
je     11a6 <main+0x66>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x1,%edi
je     1160 <main+0x20>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xea7(%rip),%rsi
xor    %eax,%eax
call   1040 <errx@plt>
xor    %eax,%eax
call   1050 <geteuid@plt>
test   %rax,%rax
je     1183 <main+0x43>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
xor    %eax,%eax
call   1040 <errx@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    0x2e57(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1060 <kill@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [12 x i8] c"Usage:\0A %s\00"
@.str.1 = [27 x i8] c"No running under root user\00"
@SIGSEGV = global i32 0
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 i32, i32* %4
%7 = icmp ne i32 %6, 1
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32, i32* @EXIT_FAILURE
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 (i32, i8*, ...) @errx(i32 %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %8, %2
%15 = call i64 (...) @geteuid()
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 (i32, i8*, ...) @errx(i32 %18, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %17, %14
%21 = call i32 (...) @getpid()
%22 = load i32, i32* @SIGSEGV
%23 = call i32 @kill(i32 %21, i32 %22)
ret i32 0
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [12 x i8] c"Usage:\0A %s\00"
@.str.1 = [27 x i8] c"No running under root user\00"
@SIGSEGV = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @EXIT_FAILURE
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @errx(i32 %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %8
8: ; preds = %4, %2
%9 = tail call i64 (...) @geteuid()
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 (i32, i8*, ...) @errx(i32 %12, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %11, %8
%15 = tail call i32 (...) @getpid()
%16 = load i32, i32* @SIGSEGV
%17 = tail call i32 @kill(i32 %15, i32 %16)
ret i32 0
}