#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ getuid();
int sprintf(char *, char *, char *, char *);
void check_root(char *buffer, uint32_t *pos, uint32_t max) {
  if (!getuid()) {
    (*pos) += sprintf(buffer + (*pos), "Root UID:\t\t\t%sTRUE%s\n", "\x1b[32m",
                      "\x1b[0m");
  } else {
    (*pos) += sprintf(buffer + (*pos), "Root UID:\t\t\t%sFALSE%s\n", "\x1b[31m",
                      "\x1b[0m");
  }
}


x86 assembly (clang, -O0):
<check_root>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1030 <getuid@plt>
cmp    $0x0,%eax
jne    117a <check_root+0x5a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
add    %rax,%rdi
lea    0xea8(%rip),%rsi
lea    0xeb7(%rip),%rdx
lea    0xeb6(%rip),%rcx
call   1040 <sprintf@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
jmp    11ac <check_root+0x8c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
add    %rax,%rdi
lea    0xe92(%rip),%rsi
lea    0xea2(%rip),%rdx
lea    0xe7f(%rip),%rcx
call   1040 <sprintf@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_root>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <getuid@plt>
movslq (%r14),%rdi
add    %rbx,%rdi
test   %eax,%eax
je     114b <check_root+0x2b>
lea    0xedf(%rip),%rsi
lea    0xeef(%rip),%rdx
jmp    1159 <check_root+0x39>
lea    0xeae(%rip),%rsi
lea    0xebd(%rip),%rdx
lea    0xebc(%rip),%rcx
call   1040 <sprintf@plt>
add    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Root UID:\09\09\09%sTRUE%s\0A\00"
@.str.1 = [6 x i8] c"\1B[32m\00"
@.str.2 = [5 x i8] c"\1B[0m\00"
@.str.3 = [23 x i8] c"Root UID:\09\09\09%sFALSE%s\0A\00"
@.str.4 = [6 x i8] c"\1B[31m\00"
define void @check_root(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%7 = call i32 (...) @getuid()
%8 = icmp ne i32 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i32*, i32** %5
%12 = load i32, i32* %11
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32*, i32** %5
%17 = load i32, i32* %16
%18 = add nsw i32 %17, %15
store i32 %18, i32* %16
br label %29
19: ; preds = %3
%20 = load i8*, i8** %4
%21 = load i32*, i32** %5
%22 = load i32, i32* %21
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32*, i32** %5
%27 = load i32, i32* %26
%28 = add nsw i32 %27, %25
store i32 %28, i32* %26
br label %29
29: ; preds = %19, %9
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Root UID:\09\09\09%sTRUE%s\0A\00"
@.str.1 = [6 x i8] c"\1B[32m\00"
@.str.2 = [5 x i8] c"\1B[0m\00"
@.str.3 = [23 x i8] c"Root UID:\09\09\09%sFALSE%s\0A\00"
@.str.4 = [6 x i8] c"\1B[31m\00"
define void @check_root(i8* nocapture writeonly %0, i32* nocapture %1, i32 %2) {
%4 = tail call i32 (...) @getuid()
%5 = icmp eq i32 %4, 0
%6 = load i32, i32* %1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
br i1 %5, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @sprintf(i8* dereferenceable(1) %8, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %13
11: ; preds = %3
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %8, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = phi i32 [ %12, %11 ], [ %10, %9 ]
%15 = load i32, i32* %1
%16 = add nsw i32 %15, %14
store i32 %16, i32* %1
ret void
}