#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();
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ setspent();
int main(void) {
  struct spwd *ptr;
  setspent();
  while ((ptr = getspent()) != NULL) {
    printf("name= %s\tshaow passwd = %s\n", ptr->sp_namp, ptr->sp_pwdp);
  }
  endspent();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <setspent@plt>
mov    $0x0,%al
call   1060 <getspent@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     118b <main+0x4b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
jmp    1156 <main+0x16>
mov    $0x0,%al
call   1040 <endspent@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <setspent@plt>
xor    %eax,%eax
call   1060 <getspent@plt>
test   %rax,%rax
je     117b <main+0x3b>
lea    0xea5(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
mov    %rbx,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getspent@plt>
test   %rax,%rax
jne    1160 <main+0x20>
xor    %eax,%eax
call   1040 <endspent@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.spwd = type { i8*, i8* }
@.str = [28 x i8] c"name= %s\09shaow passwd = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.spwd*
store i32 0, i32* %1
%3 = call i32 (...) @setspent()
br label %4
4: ; preds = %7, %0
%5 = call %struct.spwd* (...) @getspent()
store %struct.spwd* %5, %struct.spwd** %2
%6 = icmp ne %struct.spwd* %5, null
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load %struct.spwd*, %struct.spwd** %2
%9 = getelementptr inbounds %struct.spwd, %struct.spwd* %8, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = load %struct.spwd*, %struct.spwd** %2
%12 = getelementptr inbounds %struct.spwd, %struct.spwd* %11, i32 0, i32 1
%13 = load i8*, i8** %12
%14 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %13)
br label %4
15: ; preds = %4
%16 = call i32 (...) @endspent()
ret i32 0
}

LLVM IR (-O2):
%struct.spwd = type { i8*, i8* }
@.str = [28 x i8] c"name= %s\09shaow passwd = %s\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @setspent()
%2 = tail call %struct.spwd* (...) @getspent()
%3 = icmp eq %struct.spwd* %2, null
br i1 %3, label %13, label %4
4: ; preds = %0, %4
%5 = phi %struct.spwd* [ %11, %4 ], [ %2, %0 ]
%6 = getelementptr inbounds %struct.spwd, %struct.spwd* %5, i64 0, i32 0
%7 = load i8*, i8** %6
%8 = getelementptr inbounds %struct.spwd, %struct.spwd* %5, i64 0, i32 1
%9 = load i8*, i8** %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %9)
%11 = tail call %struct.spwd* (...) @getspent()
%12 = icmp eq %struct.spwd* %11, null
br i1 %12, label %13, label %4
13: ; preds = %4, %0
%14 = tail call i32 (...) @endspent()
ret i32 0
}