#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 {
  char *sp_pwdp;
};
struct passwd {
  char *pw_passwd;
  char *pw_name;
  char *pw_gecos;
  char *pw_dir;
  char *pw_shell;
  scalar_t__ pw_gid;
  scalar_t__ pw_uid;
};
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(char **, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strsep(char **, char *);
scalar_t__ valid(char *);
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;
  if ((pw = getpwnam("root")) && !strcmp(pw->pw_passwd, "x") &&
      (spw = getspnam("root")))
    pw->pw_passwd = spw->sp_pwdp;
  if (pw || !try_manually)
    return pw;
  pwd.pw_name = "root";
  pwd.pw_passwd = "";
  pwd.pw_gecos = "Super User";
  pwd.pw_dir = "/";
  pwd.pw_shell = "";
  pwd.pw_uid = 0;
  pwd.pw_gid = 0;
  if ((fp = fopen("/etc/passwd", "r")) == NULL) {
    perror("/etc/passwd");
    return &pwd;
  }
  while ((p = fgets(line, 256, fp)) != NULL) {
    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 == NULL) {
    fprintf(stderr, "%s: no entry for root\n", "/etc/passwd");
    return &pwd;
  }
  if (valid(pwd.pw_passwd))
    return &pwd;
  strcpy(pwd.pw_passwd, "");
  if ((fp = fopen("/etc/shadow", "r")) == NULL) {
    fprintf(stderr, "%s: root password garbled\n", "/etc/passwd");
    return &pwd;
  }
  while ((p = fgets(sline, 256, fp)) != NULL) {
    if (strncmp(sline, "root:", 5) != 0)
      continue;
    p += 5;
    set(&pwd.pw_passwd, strsep(&p, ":"));
    break;
  }
  fclose(fp);
  if (p == NULL) {
    fprintf(stderr, "%s: no entry for root\n", "/etc/shadow");
    strcpy(pwd.pw_passwd, "");
  }
  if (!(strcmp(pwd.pw_passwd, "*") == 0) ||
      !(strcmp(pwd.pw_passwd, "!") == 0) || !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    0xe1e(%rip),%rdi
call   1080 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     123a <getrootpwent+0x6a>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xe02(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    123a <getrootpwent+0x6a>
lea    0xde7(%rip),%rdi
call   10c0 <getspnam@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     123a <getrootpwent+0x6a>
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x18(%rbp)
jne    124f <getrootpwent+0x7f>
cmpl   $0x0,-0xc(%rbp)
jne    125c <getrootpwent+0x8c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    160b <getrootpwent+0x43b>
lea    0xd9d(%rip),%rax
mov    %rax,0x2e3e(%rip)
lea    0xdf2(%rip),%rax
mov    %rax,0x2e28(%rip)
lea    0xd88(%rip),%rax
mov    %rax,0x2e2a(%rip)
lea    0xd85(%rip),%rax
mov    %rax,0x2e24(%rip)
lea    0xdc8(%rip),%rax
mov    %rax,0x2e1e(%rip)
movq   $0x0,0x2e23(%rip)
movq   $0x0,0x2e10(%rip)
lea    0xd55(%rip),%rdi
lea    0xd4a(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12f5 <getrootpwent+0x125>
lea    0xd34(%rip),%rdi
call   10e0 <perror@plt>
lea    0x2db4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    160b <getrootpwent+0x43b>
jmp    12fa <getrootpwent+0x12a>
mov    -0x28(%rbp),%rdx
lea    0x2ddb(%rip),%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     13ff <getrootpwent+0x22f>
lea    0x2dbc(%rip),%rdi
lea    0xcf5(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1344 <getrootpwent+0x174>
jmp    12fa <getrootpwent+0x12a>
mov    -0x30(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xcc9(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2d37(%rip),%rdi
call   10f0 <set@plt>
lea    -0x30(%rbp),%rdi
lea    0xcab(%rip),%rsi
call   10b0 <strsep@plt>
lea    -0x30(%rbp),%rdi
lea    0xc9b(%rip),%rsi
call   10b0 <strsep@plt>
lea    -0x30(%rbp),%rdi
lea    0xc8b(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2cf9(%rip),%rdi
add    $0x10,%rdi
call   10f0 <set@plt>
lea    -0x30(%rbp),%rdi
lea    0xc69(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2cd7(%rip),%rdi
add    $0x18,%rdi
call   10f0 <set@plt>
lea    -0x30(%rbp),%rdi
lea    0xc85(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2cb5(%rip),%rdi
add    $0x20,%rdi
call   10f0 <set@plt>
lea    0x2ce5(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x30(%rbp)
jne    143f <getrootpwent+0x26f>
mov    0x2bc6(%rip),%rax
mov    (%rax),%edi
lea    0xc03(%rip),%rsi
lea    0xbea(%rip),%rdx
call   1090 <fprintf@plt>
lea    0x2c6a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    160b <getrootpwent+0x43b>
mov    0x2c5a(%rip),%rdi
call   10a0 <valid@plt>
cmp    $0x0,%rax
je     1465 <getrootpwent+0x295>
lea    0x2c44(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    160b <getrootpwent+0x43b>
mov    0x2c34(%rip),%rdi
lea    0xbf0(%rip),%rsi
call   1040 <strcpy@plt>
lea    0xbbe(%rip),%rdi
lea    0xb8a(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    14c5 <getrootpwent+0x2f5>
mov    0x2b40(%rip),%rax
mov    (%rax),%edi
lea    0xba0(%rip),%rsi
lea    0xb64(%rip),%rdx
call   1090 <fprintf@plt>
lea    0x2be4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    160b <getrootpwent+0x43b>
jmp    14ca <getrootpwent+0x2fa>
mov    -0x28(%rbp),%rdx
lea    0x2d0b(%rip),%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     153e <getrootpwent+0x36e>
lea    0x2cec(%rip),%rdi
lea    0xb25(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1514 <getrootpwent+0x344>
jmp    14ca <getrootpwent+0x2fa>
mov    -0x30(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xaf9(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2b67(%rip),%rdi
call   10f0 <set@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x30(%rbp)
jne    1581 <getrootpwent+0x3b1>
mov    0x2a87(%rip),%rax
mov    (%rax),%edi
lea    0xac4(%rip),%rsi
lea    0xad4(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2b2b(%rip),%rdi
lea    0xae7(%rip),%rsi
call   1040 <strcpy@plt>
mov    0x2b18(%rip),%rdi
lea    0xad5(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    15d1 <getrootpwent+0x401>
mov    0x2afb(%rip),%rdi
lea    0xaba(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    15d1 <getrootpwent+0x401>
mov    0x2ade(%rip),%rdi
call   10a0 <valid@plt>
cmp    $0x0,%rax
jne    1600 <getrootpwent+0x430>
mov    0x2a08(%rip),%rax
mov    (%rax),%edi
lea    0xa68(%rip),%rsi
lea    0xa55(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2aac(%rip),%rdi
lea    0xa68(%rip),%rsi
call   1040 <strcpy@plt>
lea    0x2a99(%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    0xe1c(%rip),%rbx
mov    %rbx,%rdi
call   1080 <getpwnam@plt>
test   %rax,%rax
je     122d <getrootpwent+0x5d>
mov    %rax,%r13
mov    (%rax),%rdi
lea    0xe07(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1523 <getrootpwent+0x353>
lea    0xded(%rip),%rdi
call   10c0 <getspnam@plt>
test   %rax,%rax
je     1523 <getrootpwent+0x353>
mov    (%rax),%rax
mov    %rax,0x0(%r13)
jmp    1523 <getrootpwent+0x353>
test   %ebp,%ebp
je     1373 <getrootpwent+0x1a3>
mov    %rbx,0x2e6c(%rip)
lea    0xe20(%rip),%rax
mov    %rax,0x2e56(%rip)
lea    0xdb6(%rip),%rcx
mov    %rcx,0x2e58(%rip)
lea    0xdb3(%rip),%rcx
mov    %rcx,0x2e52(%rip)
mov    %rax,0x2e53(%rip)
xorps  %xmm0,%xmm0
movups %xmm0,0x2e51(%rip)
lea    0xd96(%rip),%rdi
lea    0xd8b(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1553 <getrootpwent+0x383>
mov    %rax,%r14
lea    0x2e43(%rip),%r13
lea    0xd7c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     137b <getrootpwent+0x1ab>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    12b0 <getrootpwent+0xe0>
add    $0x5,%rbx
mov    %rbx,(%rsp)
lea    0xd34(%rip),%r12
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <strsep@plt>
lea    0x2d9b(%rip),%rdi
mov    %eax,%esi
call   10f0 <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    0x2d7c(%rip),%rdi
mov    %eax,%esi
call   10f0 <set@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <strsep@plt>
lea    0x2d6b(%rip),%rdi
mov    %eax,%esi
call   10f0 <set@plt>
lea    0xd07(%rip),%rsi
mov    %r15,%rdi
call   10b0 <strsep@plt>
lea    0x2d56(%rip),%rdi
mov    %eax,%esi
call   10f0 <set@plt>
jmp    137e <getrootpwent+0x1ae>
xor    %r13d,%r13d
jmp    1523 <getrootpwent+0x353>
xor    %r13d,%r13d
mov    %r13,(%rsp)
mov    %r14,%rdi
call   1050 <fclose@plt>
cmpq   $0x0,(%rsp)
je     1500 <getrootpwent+0x330>
lea    0x2d04(%rip),%r13
mov    0x2cfd(%rip),%rdi
call   10a0 <valid@plt>
test   %rax,%rax
jne    1523 <getrootpwent+0x353>
mov    0x2ce8(%rip),%rdi
lea    0xca4(%rip),%rsi
call   1040 <strcpy@plt>
lea    0xc72(%rip),%rdi
lea    0xc3e(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1535 <getrootpwent+0x365>
mov    %rax,%r14
lea    0x2df6(%rip),%r15
lea    0xc2f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     1450 <getrootpwent+0x280>
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1400 <getrootpwent+0x230>
addq   $0x5,(%rsp)
lea    0xbea(%rip),%rsi
mov    %rsp,%rdi
call   10b0 <strsep@plt>
lea    0x2c57(%rip),%rdi
mov    %eax,%esi
call   10f0 <set@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
cmpq   $0x0,(%rsp)
jne    148e <getrootpwent+0x2be>
mov    0x2b7a(%rip),%rax
mov    (%rax),%edi
lea    0xbb7(%rip),%rsi
lea    0xbc7(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2c1e(%rip),%rdi
lea    0xbda(%rip),%rsi
call   1040 <strcpy@plt>
mov    0x2c0b(%rip),%rdi
lea    0xbc8(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    14cf <getrootpwent+0x2ff>
mov    0x2bf3(%rip),%rdi
lea    0xbb2(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    14cf <getrootpwent+0x2ff>
mov    0x2bdb(%rip),%rdi
call   10a0 <valid@plt>
test   %rax,%rax
jne    1523 <getrootpwent+0x353>
mov    0x2b0a(%rip),%rax
mov    (%rax),%edi
lea    0xb6a(%rip),%rsi
lea    0xb57(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2bae(%rip),%rdi
lea    0xb6a(%rip),%rsi
call   1040 <strcpy@plt>
jmp    1523 <getrootpwent+0x353>
mov    0x2ad9(%rip),%rax
mov    (%rax),%edi
lea    0xb16(%rip),%rsi
lea    0xafd(%rip),%rdx
call   1090 <fprintf@plt>
lea    0x2b7d(%rip),%r13
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2aa4(%rip),%rax
mov    (%rax),%edi
lea    0xb04(%rip),%rsi
lea    0xac8(%rip),%rdx
call   1090 <fprintf@plt>
jmp    1523 <getrootpwent+0x353>
lea    0xaba(%rip),%rdi
call   10e0 <perror@plt>
jmp    151c <getrootpwent+0x34c>

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

LLVM IR (-O2):
%struct.passwd = type { i8*, i8*, i8*, i8*, i8*, i64, i64 }
%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"
@.str.13 = [2 x i8] c"*\00"
@.str.14 = [2 x i8] c"!\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 i64 @strcmp(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %99
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 %99, 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 %99
17: ; preds = %1
%18 = icmp eq i32 %0, 0
br i1 %18, label %99, label %19
19: ; preds = %17
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 1)
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 2)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 3)
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 4)
%20 = 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))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %99
24: ; preds = %19, %27
%25 = tail call i8* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.line, i64 0, i64 0), i32 256, i32* %20)
%26 = icmp eq i8* %25, null
br i1 %26, label %42, label %27
27: ; preds = %24
%28 = 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)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %24
30: ; preds = %27
%31 = getelementptr inbounds i8, i8* %25, i64 5
store i8* %31, i8** %2
%32 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%33 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0), i32 %32)
%34 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%35 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%36 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%37 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 2), i32 %36)
%38 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%39 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 3), i32 %38)
%40 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%41 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 4), i32 %40)
br label %42
42: ; preds = %24, %30
%43 = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.line, i64 0, i64 0), %30 ], [ null, %24 ]
store i8* %43, i8** %2
%44 = call i32 @fclose(i32* %20)
%45 = load i8*, i8** %2
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %50
47: ; preds = %42
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, 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 %99
50: ; preds = %42
%51 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%52 = call i64 @valid(i8* %51)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %99
54: ; preds = %50
%55 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%56 = call i32 @strcpy(i8* %55, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%57 = 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))
%58 = icmp eq i32* %57, null
br i1 %58, label %59, label %62
59: ; preds = %54
%60 = load i32, i32* @stderr
%61 = call i32 @fprintf(i32 %60, 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 %99
62: ; preds = %54, %65
%63 = call i8* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @getrootpwent.sline, i64 0, i64 0), i32 256, i32* %57)
store i8* %63, i8** %2
%64 = icmp eq i8* %63, null
br i1 %64, label %73, label %65
65: ; preds = %62
%66 = 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)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %62
68: ; preds = %65
%69 = load i8*, i8** %2
%70 = getelementptr inbounds i8, i8* %69, i64 5
store i8* %70, i8** %2
%71 = call i32 @strsep(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%72 = call i32 @set(i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0), i32 %71)
br label %73
73: ; preds = %62, %68
%74 = call i32 @fclose(i32* %57)
%75 = load i8*, i8** %2
%76 = icmp eq i8* %75, null
br i1 %76, label %77, label %82
77: ; preds = %73
%78 = load i32, i32* @stderr
%79 = call i32 @fprintf(i32 %78, 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))
%80 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%81 = call i32 @strcpy(i8* %80, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %82
82: ; preds = %77, %73
%83 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%84 = call i64 @strcmp(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %94
86: ; preds = %82
%87 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%88 = call i64 @strcmp(i8* %87, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %94
90: ; preds = %86
%91 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%92 = call i64 @valid(i8* %91)
%93 = icmp eq i64 %92, 0
br i1 %93, label %94, label %99
94: ; preds = %90, %86, %82
%95 = load i32, i32* @stderr
%96 = call i32 @fprintf(i32 %95, 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))
%97 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%98 = call i32 @strcpy(i8* %97, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %99
99: ; preds = %6, %11, %14, %90, %94, %50, %17, %59, %47, %22
%100 = phi %struct.passwd* [ @getrootpwent.pwd, %22 ], [ @getrootpwent.pwd, %47 ], [ @getrootpwent.pwd, %59 ], [ null, %17 ], [ @getrootpwent.pwd, %50 ], [ @getrootpwent.pwd, %94 ], [ @getrootpwent.pwd, %90 ], [ %4, %14 ], [ %4, %11 ], [ %4, %6 ]
ret %struct.passwd* %100
}