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

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ endspent();
int /*<<< orphan*/ err_exit(char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
struct spwd *getspent();
struct spwd *getspnam(char *);
int /*<<< orphan*/ print_shadow_info(struct spwd *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  struct spwd *shadow;
  if (argc < 2 || strcmp(argv[1], "--help") == 0) {
    err_exit("Usage: %s login\n", argv[0]);
  }
  print_shadow_info(getspnam(argv[1]));
  while ((shadow = getspent()) != NULL) {
    print_shadow_info(shadow);
  }
  endspent();
  exit(EXIT_SUCCESS);
}


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)
jl     11ae <main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe61(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c1 <main+0x51>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4b(%rip),%rdi
call   1060 <err_exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <getspnam@plt>
mov    %rax,%rdi
call   1090 <print_shadow_info@plt>
mov    $0x0,%al
call   1050 <getspent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11f9 <main+0x89>
mov    -0x18(%rbp),%rdi
call   1090 <print_shadow_info@plt>
jmp    11d6 <main+0x66>
mov    $0x0,%al
call   1030 <endspent@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     118e <main+0x1e>
mov    0x8(%rbx),%rdi
lea    0xe7c(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    119d <main+0x2d>
mov    (%rbx),%rsi
lea    0xe6f(%rip),%rdi
call   1060 <err_exit@plt>
mov    0x8(%rbx),%rdi
call   1070 <getspnam@plt>
cs nopw 0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1090 <print_shadow_info@plt>
xor    %eax,%eax
call   1050 <getspent@plt>
test   %rax,%rax
jne    11b0 <main+0x40>
xor    %eax,%eax
call   1030 <endspent@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.spwd = type { i32 }
@.str = [7 x i8] c"--help\00"
@.str.1 = [17 x i8] c"Usage: %s login\0A\00"
@EXIT_SUCCESS = global i32 0
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 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %9, %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @err_exit(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %15, %9
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call %struct.spwd* @getspnam(i8* %23)
%25 = call i32 @print_shadow_info(%struct.spwd* %24)
br label %26
26: ; preds = %29, %20
%27 = call %struct.spwd* (...) @getspent()
store %struct.spwd* %27, %struct.spwd** %6
%28 = icmp ne %struct.spwd* %27, null
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load %struct.spwd*, %struct.spwd** %6
%31 = call i32 @print_shadow_info(%struct.spwd* %30)
br label %26
32: ; preds = %26
%33 = call i32 (...) @endspent()
%34 = load i32, i32* @EXIT_SUCCESS
%35 = call i32 @exit(i32 %34)
unreachable
}

LLVM IR (-O2):
%struct.spwd = type { i32 }
@.str = [7 x i8] c"--help\00"
@.str.1 = [17 x i8] c"Usage: %s login\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %4, %2
%10 = load i8*, i8** %1
%11 = tail call i32 @err_exit(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %9, %4
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call %struct.spwd* @getspnam(i8* %14)
%16 = tail call i32 @print_shadow_info(%struct.spwd* %15)
%17 = tail call %struct.spwd* (...) @getspent()
%18 = icmp eq %struct.spwd* %17, null
br i1 %18, label %24, label %19
19: ; preds = %12, %19
%20 = phi %struct.spwd* [ %22, %19 ], [ %17, %12 ]
%21 = tail call i32 @print_shadow_info(%struct.spwd* %20)
%22 = tail call %struct.spwd* (...) @getspent()
%23 = icmp eq %struct.spwd* %22, null
br i1 %23, label %24, label %19
24: ; preds = %19, %12
%25 = tail call i32 (...) @endspent()
%26 = load i32, i32* @EXIT_SUCCESS
%27 = tail call i32 @exit(i32 %26)
unreachable
}