#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*/ execve(char *, char **, int /*<<< orphan*/ *);
scalar_t__ getuid();
int /*<<< orphan*/ printf(char *);
void get_shell() {
  char *argv[] = {"/bin/sh", NULL};
  if (getuid() == 0) {
    printf("[+] Root shell success !! :)\n");
    execve("/bin/sh", argv, NULL);
  }
  printf("[-] failed to get root shell :(\n");
}


x86 assembly (clang, -O0):
<get_shell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2cd1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2cce(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getuid@plt>
cmp    $0x0,%rax
jne    117f <get_shell+0x4f>
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
lea    -0x10(%rbp),%rsi
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <execve@plt>
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_shell>:
sub    $0x18,%rsp
movaps 0x2cd5(%rip),%xmm0
movaps %xmm0,(%rsp)
xor    %eax,%eax
call   1040 <getuid@plt>
test   %rax,%rax
jne    1168 <get_shell+0x38>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%rdi
mov    %rsp,%rsi
xor    %edx,%edx
call   1050 <execve@plt>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"/bin/sh\00"
@__const.get_shell.argv = [2 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [30 x i8] c"[+] Root shell success !! :)\0A\00"
@.str.2 = [33 x i8] c"[-] failed to get root shell :(\0A\00"
define void @get_shell() {
%1 = alloca [2 x i8*]
%2 = bitcast [2 x i8*]* %1 to i8*
%3 = call i64 (...) @getuid()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
%8 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %7, i32* null)
br label %9
9: ; preds = %5, %0
%10 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"/bin/sh\00"
@__const.get_shell.argv = [2 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* null]
@str = [32 x i8] c"[-] failed to get root shell :(\00"
@str.3 = [29 x i8] c"[+] Root shell success !! :)\00"
define void @get_shell() {
%1 = alloca [2 x i8*]
%2 = bitcast [2 x i8*]* %1 to i8*
%3 = tail call i64 (...) @getuid()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.3, i64 0, i64 0))
%7 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
%8 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %7, i32* null)
br label %9
9: ; preds = %5, %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
ret void
}