#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 geteuid();
int getuid();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ system(char *);
int main() {
  char cmd[128];
  int real = getuid();
  int euid = geteuid();
  if (euid != 0) {
    printf("Error: not root. Exiting");
    return 1;
  }
  sprintf(cmd, "/usr/bin/amxa-laptop-update-image");
  system(cmd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getuid@plt>
mov    %eax,-0x94(%rbp)
mov    $0x0,%al
call   1060 <geteuid@plt>
mov    %eax,-0x98(%rbp)
cmpl   $0x0,-0x98(%rbp)
je     11a1 <main+0x51>
lea    0xe70(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <main+0x77>
lea    -0x90(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <getuid@plt>
xor    %eax,%eax
call   1060 <geteuid@plt>
test   %eax,%eax
je     116f <main+0x2f>
lea    0xe9d(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%ebx
jmp    1195 <main+0x55>
movups 0xeb3(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xe97(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x65,0x20(%rsp)
mov    %rsp,%rdi
call   1040 <system@plt>
mov    %ebx,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Error: not root. Exiting\00"
@.str.1 = [34 x i8] c"/usr/bin/amxa-laptop-update-image\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @getuid()
store i32 %5, i32* %3
%6 = call i32 (...) @geteuid()
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %16
11: ; preds = %0
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%13 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%15 = call i32 @system(i8* %14)
store i32 0, i32* %1
br label %16
16: ; preds = %11, %9
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [25 x i8] c"Error: not root. Exiting\00"
@.str.1 = [34 x i8] c"/usr/bin/amxa-laptop-update-image\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @getuid()
%4 = tail call i32 (...) @geteuid()
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %10
8: ; preds = %0
%9 = call i32 @system(i8* %2)
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ 1, %6 ], [ 0, %8 ]
ret i32 %11
}