#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_test_data {
  int dummy;
};
struct passwd {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ __passwd_test_data_append(struct passwd_test_data *,
                                             struct passwd *);
int /*<<< orphan*/ endpwent();
struct passwd *getpwent();
scalar_t__ passwd_test_correctness(struct passwd *, int /*<<< orphan*/ *);
int /*<<< orphan*/ setpassent(int);
int passwd_fill_test_data(struct passwd_test_data *td) {
  struct passwd *pwd;
  setpassent(1);
  while ((pwd = getpwent()) != NULL) {
    if (passwd_test_correctness(pwd, NULL) == 0)
      __passwd_test_data_append(td, pwd);
    else
      return (-1);
  }
  endpwent();
  return (0);
}


x86 assembly (clang, -O0):
<passwd_fill_test_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x1,%edi
call   1030 <setpassent@plt>
mov    $0x0,%al
call   1040 <getpwent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11b5 <passwd_fill_test_data+0x65>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <passwd_test_correctness@plt>
cmp    $0x0,%rax
jne    11a4 <passwd_fill_test_data+0x54>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <__passwd_test_data_append@plt>
jmp    11b0 <passwd_fill_test_data+0x60>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c3 <passwd_fill_test_data+0x73>
jmp    1166 <passwd_fill_test_data+0x16>
mov    $0x0,%al
call   1050 <endpwent@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<passwd_fill_test_data>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0x1,%edi
call   1030 <setpassent@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <getpwent@plt>
test   %rax,%rax
je     11a9 <passwd_fill_test_data+0x59>
mov    %rax,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
xor    %esi,%esi
call   1070 <passwd_test_correctness@plt>
test   %rax,%rax
jne    11b2 <passwd_fill_test_data+0x62>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <__passwd_test_data_append@plt>
xor    %eax,%eax
call   1040 <getpwent@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1180 <passwd_fill_test_data+0x30>
xor    %eax,%eax
call   1050 <endpwent@plt>
jmp    11b8 <passwd_fill_test_data+0x68>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.passwd_test_data = type { i32 }
%struct.passwd = type { i32 }
define i32 @passwd_fill_test_data(%struct.passwd_test_data* %0) {
%2 = alloca i32
%3 = alloca %struct.passwd_test_data*
%4 = alloca %struct.passwd*
store %struct.passwd_test_data* %0, %struct.passwd_test_data** %3
%5 = call i32 @setpassent(i32 1)
br label %6
6: ; preds = %18, %1
%7 = call %struct.passwd* (...) @getpwent()
store %struct.passwd* %7, %struct.passwd** %4
%8 = icmp ne %struct.passwd* %7, null
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = load %struct.passwd*, %struct.passwd** %4
%11 = call i64 @passwd_test_correctness(%struct.passwd* %10, i32* null)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load %struct.passwd_test_data*, %struct.passwd_test_data** %3
%15 = load %struct.passwd*, %struct.passwd** %4
%16 = call i32 @__passwd_test_data_append(%struct.passwd_test_data* %14, %struct.passwd* %15)
br label %18
17: ; preds = %9
store i32 -1, i32* %2
br label %21
18: ; preds = %13
br label %6
19: ; preds = %6
%20 = call i32 (...) @endpwent()
store i32 0, i32* %2
br label %21
21: ; preds = %19, %17
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
%struct.passwd_test_data = type { i32 }
%struct.passwd = type { i32 }
define i32 @passwd_fill_test_data(%struct.passwd_test_data* %0) {
%2 = tail call i32 @setpassent(i32 1)
%3 = tail call %struct.passwd* (...) @getpwent()
%4 = icmp eq %struct.passwd* %3, null
br i1 %4, label %13, label %5
5: ; preds = %1, %9
%6 = phi %struct.passwd* [ %11, %9 ], [ %3, %1 ]
%7 = tail call i64 @passwd_test_correctness(%struct.passwd* %6, i32* null)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = tail call i32 @__passwd_test_data_append(%struct.passwd_test_data* %0, %struct.passwd* %6)
%11 = tail call %struct.passwd* (...) @getpwent()
%12 = icmp eq %struct.passwd* %11, null
br i1 %12, label %13, label %5
13: ; preds = %9, %1
%14 = tail call i32 (...) @endpwent()
br label %15
15: ; preds = %5, %13
%16 = phi i32 [ 0, %13 ], [ -1, %5 ]
ret i32 %16
}