#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;
int /*<<< orphan*/ 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, "sulogin: %s: no entry for root\n\r", "/etc/passwd");
    return &pwd;
  }
  if (valid(pwd.pw_passwd))
    return &pwd;
  strcpy(pwd.pw_passwd, "");
  if ((fp = fopen("/etc/shadow", "r")) == NULL) {
    fprintf(stderr, "sulogin: %s: root password garbled\n\r", "/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, "sulogin: %s: no entry for root\n\r", "/etc/shadow");
    strcpy(pwd.pw_passwd, "");
  }
  if (!valid(pwd.pw_passwd)) {
    fprintf(stderr, "sulogin: %s: root password garbled\n\r", "/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     1239 <getrootpwent+0x69>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xe02(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1239 <getrootpwent+0x69>
lea    0xde8(%rip),%rdi
call   10c0 <getspnam@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1239 <getrootpwent+0x69>
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x18(%rbp)
jne    124e <getrootpwent+0x7e>
cmpl   $0x0,-0xc(%rbp)
jne    125b <getrootpwent+0x8b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    15d0 <getrootpwent+0x400>
lea    0xd9e(%rip),%rax
mov    %rax,0x2e3f(%rip)
lea    0xdb7(%rip),%rax
mov    %rax,0x2e29(%rip)
lea    0xd89(%rip),%rax
mov    %rax,0x2e2b(%rip)
lea    0xd86(%rip),%rax
mov    %rax,0x2e25(%rip)
lea    0xd8d(%rip),%rax
mov    %rax,0x2e1f(%rip)
movq   $0x0,0x2e24(%rip)
movq   $0x0,0x2e11(%rip)
lea    0xd56(%rip),%rdi
lea    0xd4b(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12f4 <getrootpwent+0x124>
lea    0xd35(%rip),%rdi
call   10e0 <perror@plt>
lea    0x2db5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    15d0 <getrootpwent+0x400>
jmp    12f9 <getrootpwent+0x129>
mov    -0x28(%rbp),%rdx
lea    0x2ddc(%rip),%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     13fe <getrootpwent+0x22e>
lea    0x2dbd(%rip),%rdi
lea    0xcf6(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1343 <getrootpwent+0x173>
jmp    12f9 <getrootpwent+0x129>
mov    -0x30(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xcca(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2d38(%rip),%rdi
call   10f0 <set@plt>
lea    -0x30(%rbp),%rdi
lea    0xcac(%rip),%rsi
call   10b0 <strsep@plt>
lea    -0x30(%rbp),%rdi
lea    0xc9c(%rip),%rsi
call   10b0 <strsep@plt>
lea    -0x30(%rbp),%rdi
lea    0xc8c(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2cfa(%rip),%rdi
add    $0x10,%rdi
call   10f0 <set@plt>
lea    -0x30(%rbp),%rdi
lea    0xc6a(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2cd8(%rip),%rdi
add    $0x18,%rdi
call   10f0 <set@plt>
lea    -0x30(%rbp),%rdi
lea    0xc4a(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2cb6(%rip),%rdi
add    $0x20,%rdi
call   10f0 <set@plt>
lea    0x2ce6(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x30(%rbp)
jne    143e <getrootpwent+0x26e>
mov    0x2bc7(%rip),%rax
mov    (%rax),%edi
lea    0xc06(%rip),%rsi
lea    0xbeb(%rip),%rdx
call   1090 <fprintf@plt>
lea    0x2c6b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    15d0 <getrootpwent+0x400>
mov    0x2c5b(%rip),%rdi
call   10a0 <valid@plt>
cmp    $0x0,%rax
je     1464 <getrootpwent+0x294>
lea    0x2c45(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    15d0 <getrootpwent+0x400>
mov    0x2c35(%rip),%rdi
lea    0xbb5(%rip),%rsi
call   1040 <strcpy@plt>
lea    0xbcb(%rip),%rdi
lea    0xb8b(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    14c4 <getrootpwent+0x2f4>
mov    0x2b41(%rip),%rax
mov    (%rax),%edi
lea    0xbad(%rip),%rsi
lea    0xb65(%rip),%rdx
call   1090 <fprintf@plt>
lea    0x2be5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    15d0 <getrootpwent+0x400>
jmp    14c9 <getrootpwent+0x2f9>
mov    -0x28(%rbp),%rdx
lea    0x2d0c(%rip),%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     153d <getrootpwent+0x36d>
lea    0x2ced(%rip),%rdi
lea    0xb26(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1513 <getrootpwent+0x343>
jmp    14c9 <getrootpwent+0x2f9>
mov    -0x30(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xafa(%rip),%rsi
call   10b0 <strsep@plt>
mov    %eax,%esi
lea    0x2b68(%rip),%rdi
call   10f0 <set@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x30(%rbp)
jne    1580 <getrootpwent+0x3b0>
mov    0x2a88(%rip),%rax
mov    (%rax),%edi
lea    0xac7(%rip),%rsi
lea    0xae1(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2b2c(%rip),%rdi
lea    0xaac(%rip),%rsi
call   1040 <strcpy@plt>
mov    0x2b19(%rip),%rdi
call   10a0 <valid@plt>
cmp    $0x0,%rax
jne    15c5 <getrootpwent+0x3f5>
mov    0x2a43(%rip),%rax
mov    (%rax),%edi
lea    0xaaf(%rip),%rsi
lea    0xa9c(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2ae7(%rip),%rdi
lea    0xa67(%rip),%rsi
call   1040 <strcpy@plt>
lea    0x2ad4(%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     122c <getrootpwent+0x5c>
mov    %rax,%r13
mov    (%rax),%rdi
lea    0xe07(%rip),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    14f3 <getrootpwent+0x323>
lea    0xdee(%rip),%rdi
call   10c0 <getspnam@plt>
test   %rax,%rax
je     14f3 <getrootpwent+0x323>
mov    (%rax),%rax
mov    %rax,0x0(%r13)
jmp    14f3 <getrootpwent+0x323>
test   %ebp,%ebp
je     1373 <getrootpwent+0x1a3>
mov    %rbx,0x2e6d(%rip)
lea    0xde5(%rip),%rax
mov    %rax,0x2e57(%rip)
lea    0xdb7(%rip),%rcx
mov    %rcx,0x2e59(%rip)
lea    0xdb4(%rip),%rcx
mov    %rcx,0x2e53(%rip)
mov    %rax,0x2e54(%rip)
xorps  %xmm0,%xmm0
movups %xmm0,0x2e52(%rip)
lea    0xd97(%rip),%rdi
lea    0xd8c(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1523 <getrootpwent+0x353>
mov    %rax,%r14
lea    0x2e44(%rip),%r13
lea    0xd7d(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
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    0xccb(%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    14f3 <getrootpwent+0x323>
xor    %r13d,%r13d
mov    %r13,(%rsp)
mov    %r14,%rdi
call   1050 <fclose@plt>
cmpq   $0x0,(%rsp)
je     14d0 <getrootpwent+0x300>
lea    0x2d04(%rip),%r13
mov    0x2cfd(%rip),%rdi
call   10a0 <valid@plt>
test   %rax,%rax
jne    14f3 <getrootpwent+0x323>
mov    0x2ce8(%rip),%rdi
lea    0xc68(%rip),%rsi
call   1040 <strcpy@plt>
lea    0xc7e(%rip),%rdi
lea    0xc3e(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1505 <getrootpwent+0x335>
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    0xbb9(%rip),%rsi
lea    0xbd3(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2c1e(%rip),%rdi
lea    0xb9e(%rip),%rsi
call   1040 <strcpy@plt>
mov    0x2c0b(%rip),%rdi
call   10a0 <valid@plt>
test   %rax,%rax
jne    14f3 <getrootpwent+0x323>
mov    0x2b3a(%rip),%rax
mov    (%rax),%edi
lea    0xba6(%rip),%rsi
lea    0xb93(%rip),%rdx
call   1090 <fprintf@plt>
mov    0x2bde(%rip),%rdi
lea    0xb5e(%rip),%rsi
call   1040 <strcpy@plt>
jmp    14f3 <getrootpwent+0x323>
mov    0x2b09(%rip),%rax
mov    (%rax),%edi
lea    0xb48(%rip),%rsi
lea    0xb2d(%rip),%rdx
call   1090 <fprintf@plt>
lea    0x2bad(%rip),%r13
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ad4(%rip),%rax
mov    (%rax),%edi
lea    0xb40(%rip),%rsi
lea    0xaf8(%rip),%rdx
call   1090 <fprintf@plt>
jmp    14f3 <getrootpwent+0x323>
lea    0xaea(%rip),%rdi
call   10e0 <perror@plt>
jmp    14ec <getrootpwent+0x31c>

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 = [33 x i8] c"sulogin: %s: no entry for root\0A\0D\00"
@.str.11 = [12 x i8] c"/etc/shadow\00"
@.str.12 = [37 x i8] c"sulogin: %s: root password garbled\0A\0D\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 i32 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i32 %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 %115
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 %115
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 ([33 x i8], [33 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 %115
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 %115
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 ([37 x i8], [37 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 %115
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 ([33 x i8], [33 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 @valid(i8* %106)
%108 = icmp ne i64 %107, 0
br i1 %108, label %114, label %109
109: ; preds = %105
%110 = load i32, i32* @stderr
%111 = call i32 @fprintf(i32 %110, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%112 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i32 0, i32 0)
%113 = call i32 @strcpy(i8* %112, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %114
114: ; preds = %109, %105
store %struct.passwd* @getrootpwent.pwd, %struct.passwd** %2
br label %115
115: ; preds = %114, %78, %72, %65, %36, %31
%116 = load %struct.passwd*, %struct.passwd** %2
ret %struct.passwd* %116
}

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 = [33 x i8] c"sulogin: %s: no entry for root\0A\0D\00"
@.str.11 = [12 x i8] c"/etc/shadow\00"
@.str.12 = [37 x i8] c"sulogin: %s: root password garbled\0A\0D\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 %91
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 %91, 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 %91
17: ; preds = %1
%18 = icmp eq i32 %0, 0
br i1 %18, label %91, 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 %91
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 ([33 x i8], [33 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 %91
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 %91
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 ([37 x i8], [37 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 %91
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 ([33 x i8], [33 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 @valid(i8* %83)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %91
86: ; preds = %82
%87 = load i32, i32* @stderr
%88 = call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%89 = load i8*, i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getrootpwent.pwd, i64 0, i32 0)
%90 = call i32 @strcpy(i8* %89, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %91
91: ; preds = %6, %11, %14, %82, %86, %50, %17, %59, %47, %22
%92 = phi %struct.passwd* [ @getrootpwent.pwd, %22 ], [ @getrootpwent.pwd, %47 ], [ @getrootpwent.pwd, %59 ], [ null, %17 ], [ @getrootpwent.pwd, %50 ], [ @getrootpwent.pwd, %86 ], [ @getrootpwent.pwd, %82 ], [ %4, %14 ], [ %4, %11 ], [ %4, %6 ]
ret %struct.passwd* %92
}