#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*/ fprintf(int /*<<< orphan*/, char *);
int setuid(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ system(char *);
int main() {
  int rc = setuid(0);
  if (rc) {
    fprintf(stderr, "Privilege escalation failed. Is the setuid bit set (chmod "
                    "u+s iolatency.elf)?\n");
    return -1;
  }
  system("/opt/circonus/nad/etc/node-agent.d/linux/bccbpf/iolatency.py");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1050 <setuid@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1174 <main+0x44>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1187 <main+0x57>
lea    0xed4(%rip),%rdi
call   1030 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <setuid@plt>
test   %eax,%eax
je     115a <main+0x2a>
mov    0x2e9b(%rip),%rax
mov    (%rax),%edi
lea    0xeb2(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    1166 <main+0x36>
lea    0xeee(%rip),%rdi
call   1030 <system@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [79 x i8] c"Privilege escalation failed. Is the setuid bit set (chmod u+s iolatency.elf)?\0A\00"
@.str.1 = [61 x i8] c"/opt/circonus/nad/etc/node-agent.d/linux/bccbpf/iolatency.py\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @setuid(i32 0)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %11
9: ; preds = %0
%10 = call i32 @system(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %11
11: ; preds = %9, %6
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [79 x i8] c"Privilege escalation failed. Is the setuid bit set (chmod u+s iolatency.elf)?\0A\00"
@.str.1 = [61 x i8] c"/opt/circonus/nad/etc/node-agent.d/linux/bccbpf/iolatency.py\00"
define i32 @main() {
%1 = tail call i32 @setuid(i32 0)
%2 = icmp eq i32 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0))
br label %8
6: ; preds = %0
%7 = tail call i32 @system(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %3
%9 = phi i32 [ -1, %3 ], [ 0, %6 ]
ret i32 %9
}