#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 */
char *getenv(char *);
scalar_t__ getuid();
int /*<<< orphan*/ printf(char *);
int strlen(char *);
int get_parameters(void *params) {
  char *partition;
  if (getuid() == 0)
    return 0;
  partition = getenv("MPIRUN_PARTITION");
  if (!partition || (strlen(partition) < 3)) {
    printf("YOU ARE OUTSIDE OF SLURM!!!! NOT RUNNING MPIRUN!\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_parameters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getuid@plt>
cmp    $0x0,%rax
jne    1169 <get_parameters+0x29>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <get_parameters+0x75>
lea    0xe90(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1196 <get_parameters+0x56>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x3,%eax
jge    11ae <get_parameters+0x6e>
lea    0xe74(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b5 <get_parameters+0x75>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_parameters>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <getuid@plt>
test   %rax,%rax
je     117e <get_parameters+0x3e>
lea    0xeaa(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     116d <get_parameters+0x2d>
mov    %rax,%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jg     117e <get_parameters+0x3e>
lea    0xe9d(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"MPIRUN_PARTITION\00"
@.str.1 = [50 x i8] c"YOU ARE OUTSIDE OF SLURM!!!! NOT RUNNING MPIRUN!\0A\00"
define i32 @get_parameters(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = call i64 (...) @getuid()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %19
8: ; preds = %1
%9 = call i8* @getenv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %18
16: ; preds = %12, %8
%17 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %19
18: ; preds = %12
store i32 0, i32* %2
br label %19
19: ; preds = %18, %16, %7
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [17 x i8] c"MPIRUN_PARTITION\00"
@str = [49 x i8] c"YOU ARE OUTSIDE OF SLURM!!!! NOT RUNNING MPIRUN!\00"
define i32 @get_parameters(i8* nocapture readnone %0) {
%2 = tail call i64 (...) @getuid()
%3 = icmp eq i64 %2, 0
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32 @strlen(i8* %5)
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %7, %4
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %7, %1, %10
%13 = phi i32 [ 1, %10 ], [ 0, %1 ], [ 0, %7 ]
ret i32 %13
}