#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 */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ printf(char *, char *);
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
char *strtok(char *, char *);
int _parse_line(char *in_line, char **user_name, int *user_id) {
  char *tok, *shell;
  *user_name = strtok(in_line, ":");
  (void)strtok(NULL, ":");
  tok = strtok(NULL, ":");
  if (tok)
    *user_id = atoi(tok);
  else {
    printf("ERROR: parsing /etc/passwd: %s\n", in_line);
    *user_id = 0;
  }
  (void)strtok(NULL, ":");
  (void)strtok(NULL, ":");
  (void)strtok(NULL, ":");
  shell = strtok(NULL, ":");
  if (shell) {
    tok = strchr(shell, '\n');
    if (tok)
      tok[0] = '\0';
    if ((strcmp(shell, "/sbin/nologin") == 0) ||
        (strcmp(shell, "/bin/false") == 0))
      return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<_parse_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe77(%rip),%rsi
call   1060 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe67(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11c3 <_parse_line+0x73>
mov    -0x28(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    11dd <_parse_line+0x8d>
mov    -0x10(%rbp),%rsi
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe18(%rip),%rsi
call   1060 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe08(%rip),%rsi
call   1060 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdf8(%rip),%rsi
call   1060 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xde8(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1295 <_parse_line+0x145>
mov    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1250 <_parse_line+0x100>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
lea    0xdc7(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1284 <_parse_line+0x134>
mov    -0x30(%rbp),%rdi
lea    0xdbb(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1290 <_parse_line+0x140>
movl   $0xffffffff,-0x4(%rbp)
jmp    129c <_parse_line+0x14c>
jmp    1295 <_parse_line+0x145>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_parse_line>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xe99(%rip),%rbp
mov    %rbp,%rsi
call   1060 <strtok@plt>
mov    %rax,(%rbx)
xor    %ebx,%ebx
xor    %edi,%edi
mov    %rbp,%rsi
call   1060 <strtok@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     1199 <_parse_line+0x49>
mov    %rax,%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
jmp    11a8 <_parse_line+0x58>
lea    0xe62(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    %ebx,(%r14)
lea    0xe4e(%rip),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     1224 <_parse_line+0xd4>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11f7 <_parse_line+0xa7>
movb   $0x0,(%rax)
lea    0xe24(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     1226 <_parse_line+0xd6>
lea    0xe19(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1226 <_parse_line+0xd6>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@.str.1 = [32 x i8] c"ERROR: parsing /etc/passwd: %s\0A\00"
@.str.2 = [14 x i8] c"/sbin/nologin\00"
@.str.3 = [11 x i8] c"/bin/false\00"
define i32 @_parse_line(i8* %0, i8** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
%10 = load i8*, i8** %5
%11 = call i8* @strtok(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = load i8**, i8*** %6
store i8* %11, i8** %12
%13 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %8
%15 = load i8*, i8** %8
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %21
17: ; preds = %3
%18 = load i8*, i8** %8
%19 = call i32 @atoi(i8* %18)
%20 = load i32*, i32** %7
store i32 %19, i32* %20
br label %25
21: ; preds = %3
%22 = load i8*, i8** %5
%23 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i32*, i32** %7
store i32 0, i32* %24
br label %25
25: ; preds = %21, %17
%26 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%28 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%29 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %29, i8** %9
%30 = load i8*, i8** %9
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %50
32: ; preds = %25
%33 = load i8*, i8** %9
%34 = call i8* @strchr(i8* %33, i8 signext 10)
store i8* %34, i8** %8
%35 = load i8*, i8** %8
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i8*, i8** %8
%39 = getelementptr inbounds i8, i8* %38, i64 0
store i8 0, i8* %39
br label %40
40: ; preds = %37, %32
%41 = load i8*, i8** %9
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = load i8*, i8** %9
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %44, %40
store i32 -1, i32* %4
br label %51
49: ; preds = %44
br label %50
50: ; preds = %49, %25
store i32 0, i32* %4
br label %51
51: ; preds = %50, %48
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@.str.1 = [32 x i8] c"ERROR: parsing /etc/passwd: %s\0A\00"
@.str.2 = [14 x i8] c"/sbin/nologin\00"
@.str.3 = [11 x i8] c"/bin/false\00"
define i32 @_parse_line(i8* %0, i8** nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %1
%5 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = tail call i32 @atoi(i8* %6)
br label %12
10: ; preds = %3
%11 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ 0, %10 ], [ %9, %8 ]
store i32 %13, i32* %2
%14 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i8* %17, null
br i1 %18, label %29, label %19
19: ; preds = %12
%20 = tail call i8* @strchr(i8* %17, i8 signext 10)
%21 = icmp eq i8* %20, null
br i1 %21, label %23, label %22
22: ; preds = %19
store i8 0, i8* %20
br label %23
23: ; preds = %22, %19
%24 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %23
%27 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %26, %12
br label %30
30: ; preds = %23, %26, %29
%31 = phi i32 [ 0, %29 ], [ -1, %26 ], [ -1, %23 ]
ret i32 %31
}