#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 {
  int pw_uid;
  char *pw_name;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ endpwent();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct passwd *getpwent();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setpwent();
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  struct passwd *pwd;
  char *user_name;
  if (argc < 2) {
    fprintf(stderr,
            "Usage: %s <user>\n\n"
            "find a <user> in the system.\n",
            argv[0]);
    exit(EXIT_FAILURE);
  }
  user_name = argv[1];
  while ((pwd = getpwent()) != NULL)
    printf("%6d %s\n", pwd->pw_uid, pwd->pw_name);
  setpwent();
  while ((pwd = getpwent()) != NULL) {
    if (strcmp(user_name, pwd->pw_name) == 0) {
      printf("account \'%s\' is in the system.\n", argv[1]);
      break;
    }
  }
  endpwent();
  return (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)
jge    11ba <main+0x4a>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1070 <getpwent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11fc <main+0x8c>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c6 <main+0x56>
mov    $0x0,%al
call   1050 <setpwent@plt>
mov    $0x0,%al
call   1070 <getpwent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1253 <main+0xe3>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    124e <main+0xde>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1253 <main+0xe3>
jmp    1203 <main+0x93>
mov    $0x0,%al
call   1080 <endpwent@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x1,%edi
jle    1215 <main+0xa5>
mov    0x8(%r14),%r15
xor    %eax,%eax
call   1070 <getpwent@plt>
test   %rax,%rax
je     11bc <main+0x4c>
lea    0xe98(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    (%rax),%esi
mov    0x8(%rax),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1070 <getpwent@plt>
test   %rax,%rax
jne    11a0 <main+0x30>
xor    %eax,%eax
call   1050 <setpwent@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1070 <getpwent@plt>
test   %rax,%rax
je     11ff <main+0x8f>
mov    0x8(%rax),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11d0 <main+0x60>
mov    0x8(%r14),%rsi
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1080 <endpwent@plt>
mov    0x2dc3(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xdd8(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.passwd = type { i32, i8* }
@stderr = global i32 0
@.str = [48 x i8] c"Usage: %s <user>\0A\0Afind a <user> in the system.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [8 x i8] c"%6d %s\0A\00"
@.str.2 = [32 x i8] c"account '%s' is in the system.\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.passwd*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
store i8* %21, i8** %7
br label %22
22: ; preds = %25, %18
%23 = call %struct.passwd* (...) @getpwent()
store %struct.passwd* %23, %struct.passwd** %6
%24 = icmp ne %struct.passwd* %23, null
br i1 %24, label %25, label %33
25: ; preds = %22
%26 = load %struct.passwd*, %struct.passwd** %6
%27 = getelementptr inbounds %struct.passwd, %struct.passwd* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = load %struct.passwd*, %struct.passwd** %6
%30 = getelementptr inbounds %struct.passwd, %struct.passwd* %29, i32 0, i32 1
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %28, i8* %31)
br label %22
33: ; preds = %22
%34 = call i32 (...) @setpwent()
br label %35
35: ; preds = %50, %33
%36 = call %struct.passwd* (...) @getpwent()
store %struct.passwd* %36, %struct.passwd** %6
%37 = icmp ne %struct.passwd* %36, null
br i1 %37, label %38, label %51
38: ; preds = %35
%39 = load i8*, i8** %7
%40 = load %struct.passwd*, %struct.passwd** %6
%41 = getelementptr inbounds %struct.passwd, %struct.passwd* %40, i32 0, i32 1
%42 = load i8*, i8** %41
%43 = call i64 @strcmp(i8* %39, i8* %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %38
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %48)
br label %51
50: ; preds = %38
br label %35
51: ; preds = %45, %35
%52 = call i32 (...) @endpwent()
%53 = load i32, i32* @EXIT_SUCCESS
ret i32 %53
}

LLVM IR (-O2):
%struct.passwd = type { i32, i8* }
@stderr = global i32 0
@.str = [48 x i8] c"Usage: %s <user>\0A\0Afind a <user> in the system.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [8 x i8] c"%6d %s\0A\00"
@.str.2 = [32 x i8] c"account '%s' is in the system.\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 %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call %struct.passwd* (...) @getpwent()
%14 = icmp eq %struct.passwd* %13, null
br i1 %14, label %24, label %15
15: ; preds = %10, %15
%16 = phi %struct.passwd* [ %22, %15 ], [ %13, %10 ]
%17 = getelementptr inbounds %struct.passwd, %struct.passwd* %16, i64 0, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.passwd, %struct.passwd* %16, i64 0, i32 1
%20 = load i8*, i8** %19
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %20)
%22 = tail call %struct.passwd* (...) @getpwent()
%23 = icmp eq %struct.passwd* %22, null
br i1 %23, label %24, label %15
24: ; preds = %15, %10
%25 = tail call i32 (...) @setpwent()
br label %26
26: ; preds = %29, %24
%27 = tail call %struct.passwd* (...) @getpwent()
%28 = icmp eq %struct.passwd* %27, null
br i1 %28, label %37, label %29
29: ; preds = %26
%30 = getelementptr inbounds %struct.passwd, %struct.passwd* %27, i64 0, i32 1
%31 = load i8*, i8** %30
%32 = tail call i64 @strcmp(i8* %12, i8* %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %26
34: ; preds = %29
%35 = load i8*, i8** %11
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %26, %34
%38 = tail call i32 (...) @endpwent()
%39 = load i32, i32* @EXIT_SUCCESS
ret i32 %39
}