#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 /*<<< orphan*/ uid_t;
struct passwd {
  int dummy;
};

/* Variables and functions */
int EINTR;
int getpwuid_r(int /*<<< orphan*/, struct passwd *, char *, size_t,
               struct passwd **);
extern int slurm_getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
                            size_t bufsiz, struct passwd **result) {
  int rc;
  while (1) {
    rc = getpwuid_r(uid, pwd, buf, bufsiz, result);
    if (rc == EINTR)
      continue;
    if (rc != 0)
      *result = NULL;
    break;
  }
  return rc;
}


x86 assembly (clang, -O0):
<slurm_getpwuid_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <getpwuid_r@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2e90(%rip),%rcx
cmp    (%rcx),%eax
jne    115d <slurm_getpwuid_r+0x4d>
jmp    112b <slurm_getpwuid_r+0x1b>
cmpl   $0x0,-0x2c(%rbp)
je     1172 <slurm_getpwuid_r+0x62>
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
jmp    1177 <slurm_getpwuid_r+0x67>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slurm_getpwuid_r>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2eb0(%rip),%r13
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <getpwuid_r@plt>
cmp    0x0(%r13),%eax
je     1130 <slurm_getpwuid_r+0x20>
test   %eax,%eax
je     1154 <slurm_getpwuid_r+0x44>
movq   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.passwd = type { i32 }
@EINTR = global i32 0
define i32 @slurm_getpwuid_r(i32 %0, %struct.passwd* %1, i8* %2, i64 %3, %struct.passwd** %4) {
%6 = alloca i32
%7 = alloca %struct.passwd*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca %struct.passwd**
%11 = alloca i32
store i32 %0, i32* %6
store %struct.passwd* %1, %struct.passwd** %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store %struct.passwd** %4, %struct.passwd*** %10
br label %12
12: ; preds = %5, %22
%13 = load i32, i32* %6
%14 = load %struct.passwd*, %struct.passwd** %7
%15 = load i8*, i8** %8
%16 = load i64, i64* %9
%17 = load %struct.passwd**, %struct.passwd*** %10
%18 = call i32 @getpwuid_r(i32 %13, %struct.passwd* %14, i8* %15, i64 %16, %struct.passwd** %17)
store i32 %18, i32* %11
%19 = load i32, i32* %11
%20 = load i32, i32* @EINTR
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %12
br label %12
23: ; preds = %12
%24 = load i32, i32* %11
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load %struct.passwd**, %struct.passwd*** %10
store %struct.passwd* null, %struct.passwd** %27
br label %28
28: ; preds = %26, %23
br label %29
29: ; preds = %28
%30 = load i32, i32* %11
ret i32 %30
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
@EINTR = global i32 0
define i32 @slurm_getpwuid_r(i32 %0, %struct.passwd* %1, i8* %2, i64 %3, %struct.passwd** %4) {
br label %6
6: ; preds = %6, %5
%7 = tail call i32 @getpwuid_r(i32 %0, %struct.passwd* %1, i8* %2, i64 %3, %struct.passwd** %4)
%8 = load i32, i32* @EINTR
%9 = icmp eq i32 %7, %8
br i1 %9, label %6, label %10
10: ; preds = %6
%11 = icmp eq i32 %7, 0
br i1 %11, label %13, label %12
12: ; preds = %10
store %struct.passwd* null, %struct.passwd** %4
br label %13
13: ; preds = %10, %12
ret i32 %7
}