#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_namp;
  char *sp_pwdp;
};

/* Variables and functions */
int /*<<< orphan*/ endspent();
struct spwd *getspent();
struct spwd *getspnam(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setspent();
int main(int argc, char *argv[]) {
  struct spwd *user;
  setspent();
  while ((user = getspent()) != NULL) {
    printf("loginname:%s,password:%s\n", user->sp_namp, user->sp_pwdp);
  }
  endspent();
  user = getspnam("linuxmin");
  if (user != NULL)
    printf("loginname:%s,password:%s\n", user->sp_namp, user->sp_pwdp);
  printf("......\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <setspent@plt>
mov    $0x0,%al
call   1060 <getspent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11a4 <main+0x54>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    116d <main+0x1d>
mov    $0x0,%al
call   1040 <endspent@plt>
lea    0xe68(%rip),%rdi
call   1070 <getspnam@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11e3 <main+0x93>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <setspent@plt>
xor    %eax,%eax
call   1070 <getspent@plt>
test   %rax,%rax
je     119d <main+0x3d>
lea    0xe85(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <getspent@plt>
test   %rax,%rax
jne    1180 <main+0x20>
xor    %eax,%eax
call   1040 <endspent@plt>
lea    0xe6f(%rip),%rdi
call   1080 <getspnam@plt>
test   %rax,%rax
je     11ca <main+0x6a>
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe52(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.spwd = type { i8*, i8* }
@.str = [26 x i8] c"loginname:%s,password:%s\0A\00"
@.str.1 = [9 x i8] c"linuxmin\00"
@.str.2 = [8 x i8] c"......\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.spwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @setspent()
br label %8
8: ; preds = %11, %2
%9 = call %struct.spwd* (...) @getspent()
store %struct.spwd* %9, %struct.spwd** %6
%10 = icmp ne %struct.spwd* %9, null
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = load %struct.spwd*, %struct.spwd** %6
%13 = getelementptr inbounds %struct.spwd, %struct.spwd* %12, i32 0, i32 0
%14 = load i8*, i8** %13
%15 = load %struct.spwd*, %struct.spwd** %6
%16 = getelementptr inbounds %struct.spwd, %struct.spwd* %15, i32 0, i32 1
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %17)
br label %8
19: ; preds = %8
%20 = call i32 (...) @endspent()
%21 = call %struct.spwd* @getspnam(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store %struct.spwd* %21, %struct.spwd** %6
%22 = load %struct.spwd*, %struct.spwd** %6
%23 = icmp ne %struct.spwd* %22, null
br i1 %23, label %24, label %32
24: ; preds = %19
%25 = load %struct.spwd*, %struct.spwd** %6
%26 = getelementptr inbounds %struct.spwd, %struct.spwd* %25, i32 0, i32 0
%27 = load i8*, i8** %26
%28 = load %struct.spwd*, %struct.spwd** %6
%29 = getelementptr inbounds %struct.spwd, %struct.spwd* %28, i32 0, i32 1
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %27, i8* %30)
br label %32
32: ; preds = %24, %19
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.spwd = type { i8*, i8* }
@.str = [26 x i8] c"loginname:%s,password:%s\0A\00"
@.str.1 = [9 x i8] c"linuxmin\00"
@str = [7 x i8] c"......\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @setspent()
%4 = tail call %struct.spwd* (...) @getspent()
%5 = icmp eq %struct.spwd* %4, null
br i1 %5, label %15, label %6
6: ; preds = %2, %6
%7 = phi %struct.spwd* [ %13, %6 ], [ %4, %2 ]
%8 = getelementptr inbounds %struct.spwd, %struct.spwd* %7, i64 0, i32 0
%9 = load i8*, i8** %8
%10 = getelementptr inbounds %struct.spwd, %struct.spwd* %7, i64 0, i32 1
%11 = load i8*, i8** %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %11)
%13 = tail call %struct.spwd* (...) @getspent()
%14 = icmp eq %struct.spwd* %13, null
br i1 %14, label %15, label %6
15: ; preds = %6, %2
%16 = tail call i32 (...) @endspent()
%17 = tail call %struct.spwd* @getspnam(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq %struct.spwd* %17, null
br i1 %18, label %25, label %19
19: ; preds = %15
%20 = getelementptr inbounds %struct.spwd, %struct.spwd* %17, i64 0, i32 0
%21 = load i8*, i8** %20
%22 = getelementptr inbounds %struct.spwd, %struct.spwd* %17, i64 0, i32 1
%23 = load i8*, i8** %22
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %23)
br label %25
25: ; preds = %19, %15
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
ret i32 0
}