#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 passwd {
  int /*<<< orphan*/ pw_name;
};

/* Variables and functions */
int /*<<< orphan*/ endpwent();
struct passwd *getpwent();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setpwent();
scalar_t__ strchr(int /*<<< orphan*/, char);
int main(int argc, char **argv) {
  struct passwd *pw;
  int found = 0;
  int num_users, i;
  for (i = 0; i < 100; i++) {
    pw = getpwent();
  }
  num_users = 0;
  setpwent();
  while (1) {
    pw = getpwent();
    num_users++;
    if (pw == NULL)
      break;
    if (strchr(pw->pw_name, '/')) {
      found = 1;
      break;
    }
  }
  if (!found) {
    printf("FAIL: could not find any domain users\n");
    return 1;
  }
  endpwent();
  setpwent();
  for (i = 0; i < (num_users - 1); i++) {
    getpwent();
  }
  endpwent();
  setpwent();
  for (i = 0; i < (num_users - 1); i++) {
    getpwent();
  }
  for (i = 0; i < 100; i++) {
    setpwent();
  }
  setpwent();
  for (i = 0; i < (num_users - 1); i++) {
    getpwent();
  }
  for (i = 0; i < 100; i++) {
    endpwent();
  }
  printf("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jge    1197 <main+0x47>
mov    $0x0,%al
call   1060 <getpwent@plt>
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1174 <main+0x24>
movl   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1050 <setpwent@plt>
mov    $0x0,%al
call   1060 <getpwent@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c9 <main+0x79>
jmp    11f4 <main+0xa4>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    $0x2f,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     11ef <main+0x9f>
movl   $0x1,-0x1c(%rbp)
jmp    11f4 <main+0xa4>
jmp    11a5 <main+0x55>
cmpl   $0x0,-0x1c(%rbp)
jne    1216 <main+0xc6>
lea    0xdfb(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131f <main+0x1cf>
mov    $0x0,%al
call   1070 <endpwent@plt>
mov    $0x0,%al
call   1050 <setpwent@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1251 <main+0x101>
mov    $0x0,%al
call   1060 <getpwent@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    122b <main+0xdb>
mov    $0x0,%al
call   1070 <endpwent@plt>
mov    $0x0,%al
call   1050 <setpwent@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    128c <main+0x13c>
mov    $0x0,%al
call   1060 <getpwent@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1266 <main+0x116>
movl   $0x0,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jge    12b2 <main+0x162>
mov    $0x0,%al
call   1050 <setpwent@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1293 <main+0x143>
mov    $0x0,%al
call   1050 <setpwent@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12e6 <main+0x196>
mov    $0x0,%al
call   1060 <getpwent@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12c0 <main+0x170>
movl   $0x0,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jge    130c <main+0x1bc>
mov    $0x0,%al
call   1070 <endpwent@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12ed <main+0x19d>
lea    0xd14(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x64,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getpwent@plt>
add    $0xffffffff,%ebx
jne    1160 <main+0x10>
xor    %eax,%eax
call   1050 <setpwent@plt>
mov    $0xffffffff,%ebp
lea    0xe81(%rip),%r14
nop
xor    %eax,%eax
call   1060 <getpwent@plt>
test   %rax,%rax
je     11ee <main+0x9e>
mov    (%rax),%edi
mov    $0x2f,%esi
call   1040 <strchr@plt>
add    $0x1,%ebp
test   %rax,%rax
je     1180 <main+0x30>
xor    %eax,%eax
call   1070 <endpwent@plt>
xor    %eax,%eax
call   1050 <setpwent@plt>
test   %ebp,%ebp
je     11f5 <main+0xa5>
mov    %ebp,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <getpwent@plt>
add    $0xffffffff,%ebx
jne    11c0 <main+0x70>
xor    %eax,%eax
call   1070 <endpwent@plt>
xor    %eax,%eax
call   1050 <setpwent@plt>
test   %ebp,%ebp
je     1203 <main+0xb3>
mov    %ebp,%ebx
xor    %eax,%eax
call   1060 <getpwent@plt>
add    $0xffffffff,%ebx
jne    11e0 <main+0x90>
jmp    1203 <main+0xb3>
mov    $0x1,%ebp
jmp    125c <main+0x10c>
xor    %eax,%eax
call   1070 <endpwent@plt>
xor    %eax,%eax
call   1050 <setpwent@plt>
mov    $0x64,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <setpwent@plt>
add    $0xffffffff,%ebx
jne    1210 <main+0xc0>
xor    %eax,%eax
call   1050 <setpwent@plt>
test   %ebp,%ebp
je     123c <main+0xec>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getpwent@plt>
add    $0xffffffff,%ebp
jne    1230 <main+0xe0>
mov    $0x64,%ebx
lea    0xdde(%rip),%r14
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <endpwent@plt>
add    $0xffffffff,%ebx
jne    1250 <main+0x100>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.passwd = type { i32 }
@.str = [39 x i8] c"FAIL: could not find any domain users\0A\00"
@.str.1 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %9
br label %10
10: ; preds = %15, %2
%11 = load i32, i32* %9
%12 = icmp slt i32 %11, 100
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = call %struct.passwd* (...) @getpwent()
store %struct.passwd* %14, %struct.passwd** %6
br label %15
15: ; preds = %13
%16 = load i32, i32* %9
%17 = add nsw i32 %16, 1
store i32 %17, i32* %9
br label %10
18: ; preds = %10
store i32 0, i32* %8
%19 = call i32 (...) @setpwent()
br label %20
20: ; preds = %18, %34
%21 = call %struct.passwd* (...) @getpwent()
store %struct.passwd* %21, %struct.passwd** %6
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
store i32 %23, i32* %8
%24 = load %struct.passwd*, %struct.passwd** %6
%25 = icmp eq %struct.passwd* %24, null
br i1 %25, label %26, label %27
26: ; preds = %20
br label %35
27: ; preds = %20
%28 = load %struct.passwd*, %struct.passwd** %6
%29 = getelementptr inbounds %struct.passwd, %struct.passwd* %28, i32 0, i32 0
%30 = load i32, i32* %29
%31 = call i64 @strchr(i32 %30, i8 signext 47)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %27
store i32 1, i32* %7
br label %35
34: ; preds = %27
br label %20
35: ; preds = %33, %26
%36 = load i32, i32* %7
%37 = icmp ne i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %98
40: ; preds = %35
%41 = call i32 (...) @endpwent()
%42 = call i32 (...) @setpwent()
store i32 0, i32* %9
br label %43
43: ; preds = %50, %40
%44 = load i32, i32* %9
%45 = load i32, i32* %8
%46 = sub nsw i32 %45, 1
%47 = icmp slt i32 %44, %46
br i1 %47, label %48, label %53
48: ; preds = %43
%49 = call %struct.passwd* (...) @getpwent()
br label %50
50: ; preds = %48
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %43
53: ; preds = %43
%54 = call i32 (...) @endpwent()
%55 = call i32 (...) @setpwent()
store i32 0, i32* %9
br label %56
56: ; preds = %63, %53
%57 = load i32, i32* %9
%58 = load i32, i32* %8
%59 = sub nsw i32 %58, 1
%60 = icmp slt i32 %57, %59
br i1 %60, label %61, label %66
61: ; preds = %56
%62 = call %struct.passwd* (...) @getpwent()
br label %63
63: ; preds = %61
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 1
store i32 %65, i32* %9
br label %56
66: ; preds = %56
store i32 0, i32* %9
br label %67
67: ; preds = %72, %66
%68 = load i32, i32* %9
%69 = icmp slt i32 %68, 100
br i1 %69, label %70, label %75
70: ; preds = %67
%71 = call i32 (...) @setpwent()
br label %72
72: ; preds = %70
%73 = load i32, i32* %9
%74 = add nsw i32 %73, 1
store i32 %74, i32* %9
br label %67
75: ; preds = %67
%76 = call i32 (...) @setpwent()
store i32 0, i32* %9
br label %77
77: ; preds = %84, %75
%78 = load i32, i32* %9
%79 = load i32, i32* %8
%80 = sub nsw i32 %79, 1
%81 = icmp slt i32 %78, %80
br i1 %81, label %82, label %87
82: ; preds = %77
%83 = call %struct.passwd* (...) @getpwent()
br label %84
84: ; preds = %82
%85 = load i32, i32* %9
%86 = add nsw i32 %85, 1
store i32 %86, i32* %9
br label %77
87: ; preds = %77
store i32 0, i32* %9
br label %88
88: ; preds = %93, %87
%89 = load i32, i32* %9
%90 = icmp slt i32 %89, 100
br i1 %90, label %91, label %96
91: ; preds = %88
%92 = call i32 (...) @endpwent()
br label %93
93: ; preds = %91
%94 = load i32, i32* %9
%95 = add nsw i32 %94, 1
store i32 %95, i32* %9
br label %88
96: ; preds = %88
%97 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %98
98: ; preds = %96, %38
%99 = load i32, i32* %3
ret i32 %99
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
@str = [38 x i8] c"FAIL: could not find any domain users\00"
@str.2 = [5 x i8] c"PASS\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %6, %3 ]
%5 = tail call %struct.passwd* (...) @getpwent()
%6 = add nuw nsw i32 %4, 1
%7 = icmp eq i32 %6, 100
br i1 %7, label %8, label %3
8: ; preds = %3
%9 = tail call i32 (...) @setpwent()
br label %10
10: ; preds = %14, %8
%11 = phi i32 [ 0, %8 ], [ %15, %14 ]
%12 = tail call %struct.passwd* (...) @getpwent()
%13 = icmp eq %struct.passwd* %12, null
br i1 %13, label %59, label %14
14: ; preds = %10
%15 = add nuw nsw i32 %11, 1
%16 = getelementptr inbounds %struct.passwd, %struct.passwd* %12, i64 0, i32 0
%17 = load i32, i32* %16
%18 = tail call i64 @strchr(i32 %17, i8 signext 47)
%19 = icmp eq i64 %18, 0
br i1 %19, label %10, label %20
20: ; preds = %14
%21 = tail call i32 (...) @endpwent()
%22 = tail call i32 (...) @setpwent()
%23 = icmp eq i32 %11, 0
br i1 %23, label %32, label %24
24: ; preds = %20, %24
%25 = phi i32 [ %27, %24 ], [ 0, %20 ]
%26 = tail call %struct.passwd* (...) @getpwent()
%27 = add nuw nsw i32 %25, 1
%28 = icmp eq i32 %27, %11
br i1 %28, label %29, label %24
29: ; preds = %24
%30 = tail call i32 (...) @endpwent()
%31 = tail call i32 (...) @setpwent()
br i1 %23, label %40, label %35
32: ; preds = %20
%33 = tail call i32 (...) @endpwent()
%34 = tail call i32 (...) @setpwent()
br label %40
35: ; preds = %29, %35
%36 = phi i32 [ %38, %35 ], [ 0, %29 ]
%37 = tail call %struct.passwd* (...) @getpwent()
%38 = add nuw nsw i32 %36, 1
%39 = icmp eq i32 %38, %11
br i1 %39, label %40, label %35
40: ; preds = %35, %32, %29
br label %41
41: ; preds = %40, %41
%42 = phi i32 [ %44, %41 ], [ 0, %40 ]
%43 = tail call i32 (...) @setpwent()
%44 = add nuw nsw i32 %42, 1
%45 = icmp eq i32 %44, 100
br i1 %45, label %46, label %41
46: ; preds = %41
%47 = tail call i32 (...) @setpwent()
br i1 %23, label %53, label %48
48: ; preds = %46, %48
%49 = phi i32 [ %51, %48 ], [ 0, %46 ]
%50 = tail call %struct.passwd* (...) @getpwent()
%51 = add nuw nsw i32 %49, 1
%52 = icmp eq i32 %51, %11
br i1 %52, label %53, label %48
53: ; preds = %48, %46
br label %54
54: ; preds = %53, %54
%55 = phi i32 [ %57, %54 ], [ 0, %53 ]
%56 = tail call i32 (...) @endpwent()
%57 = add nuw nsw i32 %55, 1
%58 = icmp eq i32 %57, 100
br i1 %58, label %59, label %54
59: ; preds = %10, %54
%60 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.2, i64 0, i64 0), %54 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0), %10 ]
%61 = phi i32 [ 0, %54 ], [ 1, %10 ]
%62 = tail call i32 @puts(i8* dereferenceable(1) %60)
ret i32 %61
}