#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;
  int sp_lstchg;
  int sp_min;
  int sp_max;
  int sp_warn;
  int sp_inact;
  int sp_expire;
  int sp_flag;
};

/* Variables and functions */
int /*<<< orphan*/ endspent();
struct spwd *getspnam(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setspent();
int main(int argc, char **argv) {
  if (argc != 2) {
    printf("Usage: test-shadow <name>\n");
    return -1;
  }
  char *name = argv[1];
  setspent();
  struct spwd *shadow = getspnam(name);
  if (!shadow) {
    printf("Shadow %s not found.\n", name);
    return -1;
  }
  printf("Username    : %s\n", shadow->sp_namp);
  printf("Password    : %s\n", shadow->sp_pwdp);
  printf("Last change : %d\n", shadow->sp_lstchg);
  printf("Mininum     : %d\n", shadow->sp_min);
  printf("Maximum     : %d\n", shadow->sp_max);
  printf("Warning     : %d\n", shadow->sp_warn);
  printf("Inactive    : %d\n", shadow->sp_inact);
  printf("Expire      : %d\n", shadow->sp_expire);
  printf("Flag        : %d\n", shadow->sp_flag);
  endspent();
  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)
cmpl   $0x2,-0x8(%rbp)
je     117a <main+0x3a>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    129d <main+0x15d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <setspent@plt>
mov    -0x18(%rbp),%rdi
call   1060 <getspnam@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c3 <main+0x83>
mov    -0x18(%rbp),%rsi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    129d <main+0x15d>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%esi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x1c(%rax),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x20(%rax),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x24(%rax),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x28(%rax),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <endspent@plt>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x2,%edi
jne    123c <main+0xdc>
mov    0x8(%rsi),%rbp
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <setspent@plt>
mov    %rbp,%rdi
call   1080 <getspnam@plt>
test   %rax,%rax
je     124a <main+0xea>
mov    %rax,%rbx
mov    (%rax),%rsi
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%rsi
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rbx),%esi
lea    0xe7e(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x14(%rbx),%esi
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x18(%rbx),%esi
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x1c(%rbx),%esi
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x20(%rbx),%esi
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x24(%rbx),%esi
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x28(%rbx),%esi
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <endspent@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1261 <main+0x101>
lea    0xe75(%rip),%rdi
call   1060 <puts@plt>
jmp    125b <main+0xfb>
lea    0xdaf(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.spwd = type { i8*, i8*, i32, i32, i32, i32, i32, i32, i32 }
@.str = [27 x i8] c"Usage: test-shadow <name>\0A\00"
@.str.1 = [22 x i8] c"Shadow %s not found.\0A\00"
@.str.2 = [18 x i8] c"Username : %s\0A\00"
@.str.3 = [18 x i8] c"Password : %s\0A\00"
@.str.4 = [18 x i8] c"Last change : %d\0A\00"
@.str.5 = [18 x i8] c"Mininum : %d\0A\00"
@.str.6 = [18 x i8] c"Maximum : %d\0A\00"
@.str.7 = [18 x i8] c"Warning : %d\0A\00"
@.str.8 = [18 x i8] c"Inactive : %d\0A\00"
@.str.9 = [18 x i8] c"Expire : %d\0A\00"
@.str.10 = [18 x i8] c"Flag : %d\0A\00"
@.str.11 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca %struct.spwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %63
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %6
%16 = call i32 (...) @setspent()
%17 = load i8*, i8** %6
%18 = call %struct.spwd* @getspnam(i8* %17)
store %struct.spwd* %18, %struct.spwd** %7
%19 = load %struct.spwd*, %struct.spwd** %7
%20 = icmp ne %struct.spwd* %19, null
br i1 %20, label %24, label %21
21: ; preds = %12
%22 = load i8*, i8** %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %22)
store i32 -1, i32* %3
br label %63
24: ; preds = %12
%25 = load %struct.spwd*, %struct.spwd** %7
%26 = getelementptr inbounds %struct.spwd, %struct.spwd* %25, i32 0, i32 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = load %struct.spwd*, %struct.spwd** %7
%30 = getelementptr inbounds %struct.spwd, %struct.spwd* %29, i32 0, i32 1
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = load %struct.spwd*, %struct.spwd** %7
%34 = getelementptr inbounds %struct.spwd, %struct.spwd* %33, i32 0, i32 2
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = load %struct.spwd*, %struct.spwd** %7
%38 = getelementptr inbounds %struct.spwd, %struct.spwd* %37, i32 0, i32 3
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %39)
%41 = load %struct.spwd*, %struct.spwd** %7
%42 = getelementptr inbounds %struct.spwd, %struct.spwd* %41, i32 0, i32 4
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %43)
%45 = load %struct.spwd*, %struct.spwd** %7
%46 = getelementptr inbounds %struct.spwd, %struct.spwd* %45, i32 0, i32 5
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %47)
%49 = load %struct.spwd*, %struct.spwd** %7
%50 = getelementptr inbounds %struct.spwd, %struct.spwd* %49, i32 0, i32 6
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %51)
%53 = load %struct.spwd*, %struct.spwd** %7
%54 = getelementptr inbounds %struct.spwd, %struct.spwd* %53, i32 0, i32 7
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %55)
%57 = load %struct.spwd*, %struct.spwd** %7
%58 = getelementptr inbounds %struct.spwd, %struct.spwd* %57, i32 0, i32 8
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i32 %59)
%61 = call i32 (...) @endspent()
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %3
br label %63
63: ; preds = %24, %21, %10
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
%struct.spwd = type { i8*, i8*, i32, i32, i32, i32, i32, i32, i32 }
@.str.1 = [22 x i8] c"Shadow %s not found.\0A\00"
@.str.2 = [18 x i8] c"Username : %s\0A\00"
@.str.3 = [18 x i8] c"Password : %s\0A\00"
@.str.4 = [18 x i8] c"Last change : %d\0A\00"
@.str.5 = [18 x i8] c"Mininum : %d\0A\00"
@.str.6 = [18 x i8] c"Maximum : %d\0A\00"
@.str.7 = [18 x i8] c"Warning : %d\0A\00"
@.str.8 = [18 x i8] c"Inactive : %d\0A\00"
@.str.9 = [18 x i8] c"Expire : %d\0A\00"
@.str.10 = [18 x i8] c"Flag : %d\0A\00"
@str = [26 x i8] c"Usage: test-shadow <name>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %44
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 (...) @setspent()
%10 = tail call %struct.spwd* @getspnam(i8* %8)
%11 = icmp eq %struct.spwd* %10, null
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %44
14: ; preds = %6
%15 = getelementptr inbounds %struct.spwd, %struct.spwd* %10, i64 0, i32 0
%16 = load i8*, i8** %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds %struct.spwd, %struct.spwd* %10, i64 0, i32 1
%19 = load i8*, i8** %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds %struct.spwd, %struct.spwd* %10, i64 0, i32 2
%22 = load i32, i32* %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds %struct.spwd, %struct.spwd* %10, i64 0, i32 3
%25 = load i32, i32* %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds %struct.spwd, %struct.spwd* %10, i64 0, i32 4
%28 = load i32, i32* %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds %struct.spwd, %struct.spwd* %10, i64 0, i32 5
%31 = load i32, i32* %30
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds %struct.spwd, %struct.spwd* %10, i64 0, i32 6
%34 = load i32, i32* %33
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds %struct.spwd, %struct.spwd* %10, i64 0, i32 7
%37 = load i32, i32* %36
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds %struct.spwd, %struct.spwd* %10, i64 0, i32 8
%40 = load i32, i32* %39
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i32 %40)
%42 = tail call i32 (...) @endspent()
%43 = tail call i32 @putchar(i32 10)
br label %44
44: ; preds = %12, %14, %4
%45 = phi i32 [ -1, %4 ], [ 0, %14 ], [ -1, %12 ]
ret i32 %45
}