#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 spwd {
  void *sp_pwdp;
};
struct passwd {
  void *pw_passwd;
  void *pw_shell;
  void *pw_dir;
  void *pw_gecos;
  scalar_t__ pw_gid;
  scalar_t__ pw_uid;
  void *pw_name;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct passwd *getpwnam(char *);
struct spwd *getspnam(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ set(void **, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(void *, char *);
int /*<<< orphan*/ strcpy(void *, char *);
void *strdup(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strsep(char **, char *);
scalar_t__ valid(void *);
struct passwd *getrootpwent(int try_manually) {
  static struct passwd pwd;
  struct passwd *pw;
  struct spwd *spw;
  FILE *fp;
  static char line[256];
  static char sline[256];
  char *p;
  pw = getpwnam("root");
  if (pw && !strcmp(pw->pw_passwd, "x") && (spw = getspnam("root")))
    pw->pw_passwd = spw->sp_pwdp;
  if (pw || !try_manually)
    return pw;
  pwd.pw_name = strdup("root");
  pwd.pw_passwd = strdup("");
  pwd.pw_gecos = strdup("Super User");
  pwd.pw_dir = strdup("/");
  pwd.pw_shell = strdup("");
  pwd.pw_uid = 0;
  pwd.pw_gid = 0;
  fp = fopen("/etc/passwd", "r");
  if (!fp) {
    perror("/etc/passwd");
    return &pwd;
  }
  while (p = fgets(line, 256, fp)) {
    if (strncmp(line, "root:", 5) != 0)
      continue;
    p += 5;
    set(&pwd.pw_passwd, strsep(&p, ":"));
    (void)strsep(&p, ":");
    (void)strsep(&p, ":");
    set(&pwd.pw_gecos, strsep(&p, ":"));
    set(&pwd.pw_dir, strsep(&p, ":"));
    set(&pwd.pw_shell, strsep(&p, "\n"));
    p = line;
    break;
  }
  fclose(fp);
  if (!p) {
    fprintf(stderr, "%s: no entry for root\n", "/etc/passwd");
    return &pwd;
  }
  if (valid(pwd.pw_passwd))
    return &pwd;
  strcpy(pwd.pw_passwd, "");
  fp = fopen("/etc/shadow", "r");
  if (!fp) {
    fprintf(stderr, "%s: root password garbled\n", "/etc/passwd");
    return &pwd;
  }
  while (p = fgets(sline, 256, fp)) {
    if (strncmp(sline, "root:", 5) != 0)
      continue;
    p += 5;
    set(&pwd.pw_passwd, strsep(&p, ":"));
    break;
  }
  fclose(fp);
  if (!p) {
    fprintf(stderr, "%s: no entry for root\n", "/etc/shadow");
    strcpy(pwd.pw_passwd, "");
  }
  if (!valid(pwd.pw_passwd)) {
    fprintf(stderr, "%s: root password garbled\n", "/etc/shadow");
    strcpy(pwd.pw_passwd, "");
  }
  return &pwd;
}


x86 assembly (clang, -O0):
<getrootpwent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
lea    0xe0e(%rip),%rdi
call   1080 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     124a <getrootpwent+0x6a>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xdf1(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    124a <getrootpwent+0x6a>
lea    0xdd7(%rip),%rdi
call   10c0 <getspnam@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     124a <getrootpwent+0x6a>
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x18(%rbp)
jne    125f <getrootpwent+0x7f>
cmpl   $0x0,-0xc(%rbp)
jne    126c <getrootpwent+0x8c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    15fc <getrootpwent+0x41c>
lea    0xd8d(%rip),%rdi
call   10f0 <strdup@plt>
mov    %rax,0x2e51(%rip)
lea    0xddd(%rip),%rdi
call   10f0 <strdup@plt>
mov    %rax,0x2e0e(%rip)
lea    0xd6e(%rip),%rdi
call   10f0 <strdup@plt>
mov    %rax,0x2e13(%rip)
lea    0xd66(%rip),%rdi
call   10f0 <strdup@plt>
mov    %rax,0x2df8(%rip)
lea    0xda4(%rip),%rdi
call   10f0 <strdup@plt>
mov    %rax,0x2ddd(%rip)
movq   $0x0,0x2df2(%rip)
movq   $0x0,0x2ddf(%rip)
lea    0xd2c(%rip),%rdi
lea    0xd21(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    131f <getrootpwent+0x13f>
lea    0xd0a(%rip),%rdi
call   10e0 <perror@plt>
lea    0x2d8a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    15fc <getrootpwent+0x41c>
jmp    1324 <getrootpwent+0x144>
mov    -0x28(%rbp),%rdx
lea    0x2db1(%rip),%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1429 <getrootpwent+0x249>
lea    0x2d92(%rip),%rdi
lea    0xccb(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     136e <getrootpwent+0x18e>
jmp    1324 <getrootpwent+0x144>
mov    -0x30(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xc9f(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2d0d(%rip),%rdi
call   1100 <set@plt>
lea    -0x30(%rbp),%rdi
lea    0xc81(%rip),%rsi
call   10b0 <strsep@plt>
lea    -0x30(%rbp),%rdi
lea    0xc71(%rip),%rsi
call   10b0 <strsep@plt>
lea    -0x30(%rbp),%rdi
lea    0xc61(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2ccf(%rip),%rdi
add    $0x18,%rdi
call   1100 <set@plt>
lea    -0x30(%rbp),%rdi
lea    0xc3f(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2cad(%rip),%rdi
add    $0x10,%rdi
call   1100 <set@plt>
lea    -0x30(%rbp),%rdi
lea    0xc5b(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2c8b(%rip),%rdi
add    $0x8,%rdi
call   1100 <set@plt>
lea    0x2cbb(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x30(%rbp)
jne    1469 <getrootpwent+0x289>
mov    0x2b9c(%rip),%rax
mov    (%rax),%edi
lea    0xbd9(%rip),%rsi
lea    0xbc0(%rip),%rdx
call   1090 <fprintf@plt>
lea    0x2c40(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    15fc <getrootpwent+0x41c>
mov    0x2c30(%rip),%rdi
call   10a0 <valid@plt>
cmp    $0x0,%rax
je     148f <getrootpwent+0x2af>
lea    0x2c1a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    15fc <getrootpwent+0x41c>
mov    0x2c0a(%rip),%rdi
lea    0xbc6(%rip),%rsi
call   1040 <strcpy@plt>
lea    0xb94(%rip),%rdi
lea    0xb60(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    14f0 <getrootpwent+0x310>
mov    0x2b15(%rip),%rax
mov    (%rax),%edi
lea    0xb75(%rip),%rsi
lea    0xb39(%rip),%rdx
call   1090 <fprintf@plt>
lea    0x2bb9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    15fc <getrootpwent+0x41c>
jmp    14f5 <getrootpwent+0x315>
mov    -0x28(%rbp),%rdx
lea    0x2ce0(%rip),%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1569 <getrootpwent+0x389>
lea    0x2cc1(%rip),%rdi
lea    0xafa(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     153f <getrootpwent+0x35f>
jmp    14f5 <getrootpwent+0x315>
mov    -0x30(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xace(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2b3c(%rip),%rdi
call   1100 <set@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x30(%rbp)
jne    15ac <getrootpwent+0x3cc>
mov    0x2a5c(%rip),%rax
mov    (%rax),%edi
lea    0xa99(%rip),%rsi
lea    0xaa9(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2b00(%rip),%rdi
lea    0xabc(%rip),%rsi
call   1040 <strcpy@plt>
mov    0x2aed(%rip),%rdi
call   10a0 <valid@plt>
cmp    $0x0,%rax
jne    15f1 <getrootpwent+0x411>
mov    0x2a17(%rip),%rax
mov    (%rax),%edi
lea    0xa77(%rip),%rsi
lea    0xa64(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2abb(%rip),%rdi
lea    0xa77(%rip),%rsi
call   1040 <strcpy@plt>
lea    0x2aa8(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getrootpwent>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xe0c(%rip),%rdi
call   1080 <getpwnam@plt>
test   %rax,%rax
je     1238 <getrootpwent+0x58>
mov    %rax,%rbx
mov    (%rax),%rdi
lea    0xdfa(%rip),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    1513 <getrootpwent+0x333>
lea    0xde1(%rip),%rdi
call   10c0 <getspnam@plt>
test   %rax,%rax
je     1513 <getrootpwent+0x333>
mov    (%rax),%rax
mov    %rax,(%rbx)
jmp    1513 <getrootpwent+0x333>
test   %ebp,%ebp
je     13a3 <getrootpwent+0x1c3>
lea    0xdb9(%rip),%rdi
call   10f0 <strdup@plt>
mov    %rax,0x2e7d(%rip)
lea    0xe09(%rip),%rbx
mov    %rbx,%rdi
call   10f0 <strdup@plt>
mov    %rax,0x2e37(%rip)
lea    0xd97(%rip),%rdi
call   10f0 <strdup@plt>
mov    %rax,0x2e3c(%rip)
lea    0xd8f(%rip),%rdi
call   10f0 <strdup@plt>
mov    %rax,0x2e21(%rip)
mov    %rbx,%rdi
call   10f0 <strdup@plt>
mov    %rax,0x2e0a(%rip)
xorps  %xmm0,%xmm0
movups %xmm0,0x2e18(%rip)
lea    0xd65(%rip),%rdi
lea    0xd5a(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1543 <getrootpwent+0x363>
mov    %rax,%r14
lea    0x2e12(%rip),%r13
lea    0xd4b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     13aa <getrootpwent+0x1ca>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    12e0 <getrootpwent+0x100>
add    $0x5,%rbx
mov    %rbx,(%rsp)
lea    0xd04(%rip),%r12
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <strsep@plt>
lea    0x2d6b(%rip),%rdi
mov    %eax,%esi
call   1100 <set@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <strsep@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <strsep@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <strsep@plt>
lea    0x2d54(%rip),%rdi
mov    %eax,%esi
call   1100 <set@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <strsep@plt>
lea    0x2d33(%rip),%rdi
mov    %eax,%esi
call   1100 <set@plt>
lea    0xcd7(%rip),%rsi
mov    %r15,%rdi
call   10b0 <strsep@plt>
lea    0x2d0e(%rip),%rdi
mov    %eax,%esi
call   1100 <set@plt>
jmp    13ad <getrootpwent+0x1cd>
xor    %ebx,%ebx
jmp    1513 <getrootpwent+0x333>
xor    %r13d,%r13d
mov    %r13,(%rsp)
mov    %r14,%rdi
call   1050 <fclose@plt>
cmpq   $0x0,(%rsp)
je     14f0 <getrootpwent+0x310>
lea    0x2cd5(%rip),%rbx
mov    0x2cce(%rip),%rdi
call   10a0 <valid@plt>
test   %rax,%rax
jne    1513 <getrootpwent+0x333>
mov    0x2cb9(%rip),%rdi
lea    0xc75(%rip),%rsi
call   1040 <strcpy@plt>
lea    0xc43(%rip),%rdi
lea    0xc0f(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1525 <getrootpwent+0x345>
mov    %rax,%r14
lea    0x2dc7(%rip),%r15
lea    0xc00(%rip),%r12
mov    %r15,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     1470 <getrootpwent+0x290>
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1420 <getrootpwent+0x240>
addq   $0x5,(%rsp)
lea    0xbca(%rip),%rsi
mov    %rsp,%rdi
call   10b0 <strsep@plt>
lea    0x2c37(%rip),%rdi
mov    %eax,%esi
call   1100 <set@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
cmpq   $0x0,(%rsp)
jne    14ae <getrootpwent+0x2ce>
mov    0x2b5a(%rip),%rax
mov    (%rax),%edi
lea    0xb97(%rip),%rsi
lea    0xba7(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2bfe(%rip),%rdi
lea    0xbba(%rip),%rsi
call   1040 <strcpy@plt>
mov    0x2beb(%rip),%rdi
call   10a0 <valid@plt>
test   %rax,%rax
jne    1513 <getrootpwent+0x333>
mov    0x2b1a(%rip),%rax
mov    (%rax),%edi
lea    0xb7a(%rip),%rsi
lea    0xb67(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2bbe(%rip),%rdi
lea    0xb7a(%rip),%rsi
call   1040 <strcpy@plt>
jmp    1513 <getrootpwent+0x333>
mov    0x2ae9(%rip),%rax
mov    (%rax),%edi
lea    0xb26(%rip),%rsi
lea    0xb0d(%rip),%rdx
call   1090 <fprintf@plt>
lea    0x2b8d(%rip),%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ab4(%rip),%rax
mov    (%rax),%edi
lea    0xb14(%rip),%rsi
lea    0xad8(%rip),%rdx
call   1090 <fprintf@plt>
jmp    1513 <getrootpwent+0x333>
lea    0xaca(%rip),%rdi
call   10e0 <perror@plt>
jmp    150c <getrootpwent+0x32c>

LLVM IR (-O0):
%struct.passwd = type { i8*, i8*, i8*, i8*, i64, i64, i8* }
%struct.spwd = type { i8* }
@getrootpwent.pwd = internal global %struct.passwd zeroinitializer
@getrootpwent.line = internal global [256 x i8] zeroinitializer
@getrootpwent.sline = internal global [256 x i8] zeroinitializer
@.str = [5 x i8] c"root\00"
@.str.1 = [2 x i8] c"x\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c"Super User\00"
@.str.4 = [2 x i8] c"/\00"
@.str.5 = [12 x i8] c"/etc/passwd\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [6 x i8] c"root:\00"
@.str.8 = [2 x i8] c":\00"
@.str.9 = [2 x i8] c"\0A\00"
@stderr = global i32 0
@.str.10 = [23 x i8] c"%s: no entry for root\0A\00"
@.str.11 = [12 x i8] c"/etc/shadow\00"
@.str.12 = [27 x i8] c"%s: root password garbled\0A\00"
define %struct.passwd* @getrootpwent(i32 %0) {
%2 = alloca %struct.passwd*
%3 = alloca i32
%4 = alloca %struct.passwd*
%5 = alloca %struct.spwd*
%6 = alloca i32*
%7 = alloca i8*
store i32 %0, i32* %3
%8 = call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store %struct.passwd* %8, %struct.passwd** %4
%9 = load %struct.passwd*, %struct.passwd** %4
%10 = icmp ne %struct.passwd* %9, null
br i1 %10, label %11, label %26
11: ; preds = %1
%12 = load %struct.passwd*, %struct.passwd** %4
%13 = getelementptr inbounds %struct.passwd, %struct.passwd* %12, i32 0, i32 0
%14 = load i8*, i8** %13
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %11
%18 = call %struct.spwd* @getspnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store %struct.spwd* %18, %struct.spwd** %5
%19 = icmp ne %struct.spwd* %18, null
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load %struct.spwd*, %struct.spwd** %5
%22 = getelementptr inbounds %struct.spwd, %struct.spwd* %21, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = load %struct.passwd*, %struct.passwd** %4
%25 = getelementptr inbounds %struct.passwd, %struct.passwd* %24, i32 0, i32 0
store i8* %23, i8** %25
br label %26
26: ; preds = %20, %17, %11, %1
%27 = load %struct.passwd*, %struct.passwd** %4
%28 = icmp ne %struct.passwd* %27, null
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i32, i32* %3
%31 = icmp ne i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29, %26
%33 = load %struct.passwd*, %struct.passwd** %4
store %struct.passwd* %33, %struct.passwd** %2
br label %123
34: ; preds = %29
%35 = call i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %35, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 6)
%36 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
store i8* %36, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 0)
%37 = call i8* @strdup(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
store i8* %37, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 3)
%38 = call i8* @strdup(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %38, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 2)
%39 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
store i8* %39, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 1)
store i64 0, i64* getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 5)
store i64 0, i64* getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 4)
%40 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %40, i32** %6
%41 = load i32*, i32** %6
%42 = icmp ne i32* %41, null
br i1 %42, label %45, label %43
43: ; preds = %34
%44 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store %struct.passwd* @getrootpwent.pwd, %struct.passwd** %2
br label %123
45: ; preds = %34
br label %46
46: ; preds = %53, %45
%47 = load i32*, i32** %6
%48 = call i8* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.line, i64 0, i64 0), i32 256, i32* %47)
store i8* %48, i8** %7
%49 = icmp ne i8* %48, null
br i1 %49, label %50, label %67
50: ; preds = %46
%51 = call i64 @strncmp(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.line, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %50
br label %46
54: ; preds = %50
%55 = load i8*, i8** %7
%56 = getelementptr inbounds i8, i8* %55, i64 5
store i8* %56, i8** %7
%57 = call i32 @strsep(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%58 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 0), i32 %57)
%59 = call i32 @strsep(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%60 = call i32 @strsep(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%61 = call i32 @strsep(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%62 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 3), i32 %61)
%63 = call i32 @strsep(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%64 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 2), i32 %63)
%65 = call i32 @strsep(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%66 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 1), i32 %65)
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.line, i64 0, i64 0), i8** %7
br label %67
67: ; preds = %54, %46
%68 = load i32*, i32** %6
%69 = call i32 @fclose(i32* %68)
%70 = load i8*, i8** %7
%71 = icmp ne i8* %70, null
br i1 %71, label %75, label %72
72: ; preds = %67
%73 = load i32, i32* @stderr
%74 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store %struct.passwd* @getrootpwent.pwd, %struct.passwd** %2
br label %123
75: ; preds = %67
%76 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 0)
%77 = call i64 @valid(i8* %76)
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %75
store %struct.passwd* @getrootpwent.pwd, %struct.passwd** %2
br label %123
80: ; preds = %75
%81 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 0)
%82 = call i32 @strcpy(i8* %81, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%83 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %83, i32** %6
%84 = load i32*, i32** %6
%85 = icmp ne i32* %84, null
br i1 %85, label %89, label %86
86: ; preds = %80
%87 = load i32, i32* @stderr
%88 = call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store %struct.passwd* @getrootpwent.pwd, %struct.passwd** %2
br label %123
89: ; preds = %80
br label %90
90: ; preds = %97, %89
%91 = load i32*, i32** %6
%92 = call i8* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.sline, i64 0, i64 0), i32 256, i32* %91)
store i8* %92, i8** %7
%93 = icmp ne i8* %92, null
br i1 %93, label %94, label %103
94: ; preds = %90
%95 = call i64 @strncmp(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.sline, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %98
97: ; preds = %94
br label %90
98: ; preds = %94
%99 = load i8*, i8** %7
%100 = getelementptr inbounds i8, i8* %99, i64 5
store i8* %100, i8** %7
%101 = call i32 @strsep(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%102 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 0), i32 %101)
br label %103
103: ; preds = %98, %90
%104 = load i32*, i32** %6
%105 = call i32 @fclose(i32* %104)
%106 = load i8*, i8** %7
%107 = icmp ne i8* %106, null
br i1 %107, label %113, label %108
108: ; preds = %103
%109 = load i32, i32* @stderr
%110 = call i32 @fprintf(i32 %109, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%111 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 0)
%112 = call i32 @strcpy(i8* %111, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %113
113: ; preds = %108, %103
%114 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 0)
%115 = call i64 @valid(i8* %114)
%116 = icmp ne i64 %115, 0
br i1 %116, label %122, label %117
117: ; preds = %113
%118 = load i32, i32* @stderr
%119 = call i32 @fprintf(i32 %118, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%120 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 0)
%121 = call i32 @strcpy(i8* %120, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %122
122: ; preds = %117, %113
store %struct.passwd* @getrootpwent.pwd, %struct.passwd** %2
br label %123
123: ; preds = %122, %86, %79, %72, %43, %32
%124 = load %struct.passwd*, %struct.passwd** %2
ret %struct.passwd* %124
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i8*, i8*, i8*, i64, i64, i8* }
%struct.spwd = type { i8* }
@getrootpwent.pwd = internal global %struct.passwd zeroinitializer
@getrootpwent.line = internal global [256 x i8] zeroinitializer
@getrootpwent.sline = internal global [256 x i8] zeroinitializer
@.str = [5 x i8] c"root\00"
@.str.1 = [2 x i8] c"x\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c"Super User\00"
@.str.4 = [2 x i8] c"/\00"
@.str.5 = [12 x i8] c"/etc/passwd\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [6 x i8] c"root:\00"
@.str.8 = [2 x i8] c":\00"
@.str.9 = [2 x i8] c"\0A\00"
@stderr = global i32 0
@.str.10 = [23 x i8] c"%s: no entry for root\0A\00"
@.str.11 = [12 x i8] c"/etc/shadow\00"
@.str.12 = [27 x i8] c"%s: root password garbled\0A\00"
define %struct.passwd* @getrootpwent(i32 %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = tail call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq %struct.passwd* %4, null
br i1 %5, label %17, label %6
6: ; preds = %1
%7 = getelementptr inbounds %struct.passwd, %struct.passwd* %4, i64 0, i32 0
%8 = load i8*, i8** %7
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %96
11: ; preds = %6
%12 = tail call %struct.spwd* @getspnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq %struct.spwd* %12, null
br i1 %13, label %96, label %14
14: ; preds = %11
%15 = getelementptr inbounds %struct.spwd, %struct.spwd* %12, i64 0, i32 0
%16 = load i8*, i8** %15
store i8* %16, i8** %7
br label %96
17: ; preds = %1
%18 = icmp eq i32 %0, 0
br i1 %18, label %96, label %19
19: ; preds = %17
%20 = tail call dereferenceable_or_null(5) i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 6)
%21 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
store i8* %21, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%22 = tail call dereferenceable_or_null(11) i8* @strdup(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
store i8* %22, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 3)
%23 = tail call dereferenceable_or_null(2) i8* @strdup(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %23, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 2)
%24 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
store i8* %24, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 1)
%25 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %29
27: ; preds = %19
%28 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %96
29: ; preds = %19, %32
%30 = tail call i8* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.line, i64 0, i64 0), i32 256, i32* %25)
%31 = icmp eq i8* %30, null
br i1 %31, label %47, label %32
32: ; preds = %29
%33 = tail call i64 @strncmp(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.line, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %29
35: ; preds = %32
%36 = getelementptr inbounds i8, i8* %30, i64 5
store i8* %36, i8** %2
%37 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%38 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0), i32 %37)
%39 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%40 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%41 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%42 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 3), i32 %41)
%43 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%44 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 2), i32 %43)
%45 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%46 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 1), i32 %45)
br label %47
47: ; preds = %29, %35
%48 = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.line, i64 0, i64 0), %35 ], [ null, %29 ]
store i8* %48, i8** %2
%49 = call i32 @fclose(i32* %25)
%50 = load i8*, i8** %2
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %55
52: ; preds = %47
%53 = load i32, i32* @stderr
%54 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %96
55: ; preds = %47
%56 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%57 = call i64 @valid(i8* %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %96
59: ; preds = %55
%60 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%61 = call i32 @strcpy(i8* %60, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%62 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %67
64: ; preds = %59
%65 = load i32, i32* @stderr
%66 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %96
67: ; preds = %59, %70
%68 = call i8* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.sline, i64 0, i64 0), i32 256, i32* %62)
store i8* %68, i8** %2
%69 = icmp eq i8* %68, null
br i1 %69, label %78, label %70
70: ; preds = %67
%71 = call i64 @strncmp(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.sline, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %67
73: ; preds = %70
%74 = load i8*, i8** %2
%75 = getelementptr inbounds i8, i8* %74, i64 5
store i8* %75, i8** %2
%76 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%77 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0), i32 %76)
br label %78
78: ; preds = %67, %73
%79 = call i32 @fclose(i32* %62)
%80 = load i8*, i8** %2
%81 = icmp eq i8* %80, null
br i1 %81, label %82, label %87
82: ; preds = %78
%83 = load i32, i32* @stderr
%84 = call i32 @fprintf(i32 %83, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%85 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%86 = call i32 @strcpy(i8* %85, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %87
87: ; preds = %82, %78
%88 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%89 = call i64 @valid(i8* %88)
%90 = icmp eq i64 %89, 0
br i1 %90, label %91, label %96
91: ; preds = %87
%92 = load i32, i32* @stderr
%93 = call i32 @fprintf(i32 %92, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%94 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%95 = call i32 @strcpy(i8* %94, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %96
96: ; preds = %6, %11, %14, %87, %91, %55, %17, %64, %52, %27
%97 = phi %struct.passwd* [ @getrootpwent.pwd, %64 ], [ @getrootpwent.pwd, %52 ], [ @getrootpwent.pwd, %27 ], [ null, %17 ], [ @getrootpwent.pwd, %55 ], [ @getrootpwent.pwd, %91 ], [ @getrootpwent.pwd, %87 ], [ %4, %14 ], [ %4, %11 ], [ %4, %6 ]
ret %struct.passwd* %97
}