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

/* Variables and functions */
int EINTR;
int getpwnam_r(char const *, struct passwd *, char *, size_t, struct passwd **);
int _getpwnam_r(const char *name, struct passwd *pwd, char *buf, size_t bufsiz,
                struct passwd **result) {
  int rc;
  while (1) {
    rc = getpwnam_r(name, pwd, buf, bufsiz, result);
    if (rc == EINTR)
      continue;
    if (rc != 0)
      *result = NULL;
    break;
  }
  return (rc);
}


x86 assembly (clang, -O0):
<_getpwnam_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <getpwnam_r@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2e8e(%rip),%rcx
cmp    (%rcx),%eax
jne    115f <_getpwnam_r+0x4f>
jmp    112c <_getpwnam_r+0x1c>
cmpl   $0x0,-0x2c(%rbp)
je     1174 <_getpwnam_r+0x64>
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
jmp    1179 <_getpwnam_r+0x69>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_getpwnam_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,%r13
mov    %rdi,%rbx
mov    0x2eaf(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <getpwnam_r@plt>
cmp    0x0(%rbp),%eax
je     1140 <_getpwnam_r+0x30>
test   %eax,%eax
je     1164 <_getpwnam_r+0x54>
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 @_getpwnam_r(i8* %0, %struct.passwd* %1, i8* %2, i64 %3, %struct.passwd** %4) {
%6 = alloca i8*
%7 = alloca %struct.passwd*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca %struct.passwd**
%11 = alloca i32
store i8* %0, i8** %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 i8*, i8** %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 @getpwnam_r(i8* %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 @_getpwnam_r(i8* %0, %struct.passwd* %1, i8* %2, i64 %3, %struct.passwd** %4) {
br label %6
6: ; preds = %6, %5
%7 = tail call i32 @getpwnam_r(i8* %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
}