getpwentry(name, buf) char *name, *buf;
{
  extern fin;
  int fi, r, c;
  register char *gnp, *rnp;
  fi = fin;
  r = 1;
  if ((fin = open("/etc/passwd", 0)) < 0)
    goto ret;
loop:
  gnp = name;
  rnp = buf;
  while ((c = getchar()) != '\n') {
    if (c <= 0)
      goto ret;
    *rnp++ = c;
  }
  *rnp++ = '\0';
  rnp = buf;
  while (*gnp++ == *rnp++)
    ;
  if ((*--gnp != ' ' && gnp < name + 8) || *--rnp != ':')
    goto loop;
  r = 0;
ret:
  close(fin);
  fin = 0;
  (&fin)[1] = 0;
  (&fin)[2] = 0;
  return (r);
}


x86 assembly (clang, -O0):
<getpwentry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xea6(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1050 <open@plt>
mov    0x2e7e(%rip),%rcx
mov    %eax,(%rcx)
cmp    $0x0,%eax
jge    117a <getpwentry+0x4a>
jmp    1270 <getpwentry+0x140>
jmp    117f <getpwentry+0x4f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xa,%eax
je     11cc <getpwentry+0x9c>
cmpl   $0x0,-0x1c(%rbp)
jg     11b1 <getpwentry+0x81>
jmp    1270 <getpwentry+0x140>
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
jmp    118f <getpwentry+0x5f>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movsbl (%rax),%eax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1217 <getpwentry+0xe7>
jmp    11e6 <getpwentry+0xb6>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x28(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0x20,%eax
je     1248 <getpwentry+0x118>
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    $0x8,%rcx
cmp    %rcx,%rax
jb     1264 <getpwentry+0x134>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x30(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0x3a,%eax
je     1269 <getpwentry+0x139>
jmp    117f <getpwentry+0x4f>
movl   $0x0,-0x18(%rbp)
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1030 <close@plt>
mov    0x2d61(%rip),%rax
movl   $0x0,(%rax)
mov    0x2d54(%rip),%rax
movl   $0x0,0x4(%rax)
mov    0x2d46(%rip),%rax
movl   $0x0,0x8(%rax)
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getpwentry>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbp
mov    %rdi,%r12
lea    0xebb(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <open@plt>
mov    0x2e93(%rip),%r15
mov    %eax,(%r15)
mov    $0x1,%r14d
test   %eax,%eax
js     11ce <getpwentry+0x9e>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %rbp,%rbx
cmp    $0xa,%eax
je     1196 <getpwentry+0x66>
mov    %rbp,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %eax,%eax
jle    11ce <getpwentry+0x9e>
mov    %al,(%rbx)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
jne    1180 <getpwentry+0x50>
movb   $0x0,(%rbx)
mov    $0xffffffffffffffff,%rcx
movzbl 0x1(%r12,%rcx,1),%edx
movzbl 0x1(%rbp,%rcx,1),%eax
add    $0x1,%rcx
cmp    %al,%dl
je     11a0 <getpwentry+0x70>
cmp    $0x20,%dl
sete   %dl
cmp    $0x8,%rcx
setae  %cl
or     %dl,%cl
cmp    $0x1,%cl
jne    1162 <getpwentry+0x32>
cmp    $0x3a,%al
jne    1162 <getpwentry+0x32>
xor    %r14d,%r14d
mov    (%r15),%edi
xor    %eax,%eax
call   1030 <close@plt>
movq   $0x0,(%r15)
movl   $0x0,0x8(%r15)
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@fin = external global i32
@.str = [12 x i8] c"/etc/passwd\00"
define i32 @getpwentry(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%10 = load i32, i32* @fin
store i32 %10, i32* %5
store i32 1, i32* %6
%11 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %11, i32* @fin
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %2
br label %64
14: ; preds = %2
br label %15
15: ; preds = %62, %14
%16 = load i8*, i8** %3
store i8* %16, i8** %8
%17 = load i8*, i8** %4
store i8* %17, i8** %9
br label %18
18: ; preds = %25, %15
%19 = call i32 (...) @getchar()
store i32 %19, i32* %7
%20 = icmp ne i32 %19, 10
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i32, i32* %7
%23 = icmp sle i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
br label %64
25: ; preds = %21
%26 = load i32, i32* %7
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %9
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %9
store i8 %27, i8* %28
br label %18
30: ; preds = %18
%31 = load i8*, i8** %9
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %9
store i8 0, i8* %31
%33 = load i8*, i8** %4
store i8* %33, i8** %9
br label %34
34: ; preds = %44, %30
%35 = load i8*, i8** %8
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %8
%37 = load i8, i8* %35
%38 = sext i8 %37 to i32
%39 = load i8*, i8** %9
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %9
%41 = load i8, i8* %39
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %38, %42
br i1 %43, label %44, label %45
44: ; preds = %34
br label %34
45: ; preds = %34
%46 = load i8*, i8** %8
%47 = getelementptr inbounds i8, i8* %46, i32 -1
store i8* %47, i8** %8
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 32
br i1 %50, label %51, label %56
51: ; preds = %45
%52 = load i8*, i8** %8
%53 = load i8*, i8** %3
%54 = getelementptr inbounds i8, i8* %53, i64 8
%55 = icmp ult i8* %52, %54
br i1 %55, label %62, label %56
56: ; preds = %51, %45
%57 = load i8*, i8** %9
%58 = getelementptr inbounds i8, i8* %57, i32 -1
store i8* %58, i8** %9
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %60, 58
br i1 %61, label %62, label %63
62: ; preds = %56, %51
br label %15
63: ; preds = %56
store i32 0, i32* %6
br label %64
64: ; preds = %63, %24, %13
%65 = load i32, i32* @fin
%66 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %65)
store i32 0, i32* @fin
store i32 0, i32* getelementptr inbounds (i32, i32* @fin, i64 1)
store i32 0, i32* getelementptr inbounds (i32, i32* @fin, i64 2)
%67 = load i32, i32* %6
ret i32 %67
}

LLVM IR (-O2):
@fin = external global i32
@.str = [12 x i8] c"/etc/passwd\00"
define i32 @getpwentry(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %3, i32* @fin
%4 = icmp slt i32 %3, 0
br i1 %4, label %34, label %5
5: ; preds = %2, %28
%6 = tail call i32 (...) @getchar()
%7 = icmp eq i32 %6, 10
br i1 %7, label %17, label %8
8: ; preds = %5, %12
%9 = phi i32 [ %15, %12 ], [ %6, %5 ]
%10 = phi i8* [ %14, %12 ], [ %1, %5 ]
%11 = icmp slt i32 %9, 1
br i1 %11, label %34, label %12
12: ; preds = %8
%13 = trunc i32 %9 to i8
%14 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %13, i8* %10
%15 = tail call i32 (...) @getchar()
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %8
17: ; preds = %12, %5
%18 = phi i8* [ %1, %5 ], [ %14, %12 ]
store i8 0, i8* %18
br label %19
19: ; preds = %19, %17
%20 = phi i64 [ 0, %17 ], [ %23, %19 ]
%21 = phi i8* [ %1, %17 ], [ %25, %19 ]
%22 = getelementptr inbounds i8, i8* %0, i64 %20
%23 = add nuw nsw i64 %20, 1
%24 = load i8, i8* %22
%25 = getelementptr inbounds i8, i8* %21, i64 1
%26 = load i8, i8* %21
%27 = icmp eq i8 %24, %26
br i1 %27, label %19, label %28
28: ; preds = %19
%29 = icmp eq i8 %24, 32
%30 = icmp ugt i64 %20, 7
%31 = select i1 %29, i1 true, i1 %30
%32 = icmp eq i8 %26, 58
%33 = select i1 %31, i1 %32, i1 false
br i1 %33, label %34, label %5
34: ; preds = %28, %8, %2
%35 = phi i32 [ 1, %2 ], [ 1, %8 ], [ 0, %28 ]
%36 = load i32, i32* @fin
%37 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %36)
store i32 0, i32* @fin
store i32 0, i32* getelementptr inbounds (i32, i32* @fin, i64 1)
store i32 0, i32* getelementptr inbounds (i32, i32* @fin, i64 2)
ret i32 %35
}