#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ geteuid();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  if (geteuid() != 0) {
    fprintf(stderr, "Sorry, %s must be setuid root.\n", argv[0]);
    exit(1);
  } else {
    fprintf(stdout, "Ok, %s have been setuid root.\n", argv[0]);
    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    $0x0,%al
call   1030 <geteuid@plt>
cmp    $0x0,%rax
je     117d <main+0x4d>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe92(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe8c(%rip),%rsi
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
xor    %eax,%eax
call   1030 <geteuid@plt>
test   %rax,%rax
jne    115f <main+0x2f>
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xecd(%rip),%rsi
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe8e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"Sorry, %s must be setuid root.\0A\00"
@stdout = global i32 0
@.str.1 = [31 x i8] c"Ok, %s have been setuid root.\0A\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 = call i64 (...) @geteuid()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i32, i32* @stdout
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Sorry, %s must be setuid root.\0A\00"
@stdout = global i32 0
@.str.1 = [31 x i8] c"Ok, %s have been setuid root.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i64 (...) @geteuid()
%4 = icmp eq i64 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = load i32, i32* @stdout
%12 = load i8*, i8** %1
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = tail call i32 @exit(i32 0)
unreachable
}