#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;
  int pw_gid;
  char *pw_gecos;
  char *pw_dir;
  char *pw_shell;
};

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ endpwent();
struct passwd *getpwent();
int /*<<< orphan*/ printf(char *, char *, int, int, char *, char *, char *);
int /*<<< orphan*/ setpwent();
int main(int argc, char **argv) {
  struct passwd *p;
  int uid;
  while (--argc > 0) {
    uid = atoi(*++argv);
    setpwent();
    while ((p = getpwent()) != NULL) {
      if (p->pw_uid == uid) {
        printf("%s, %d, %d, %s, %s, %s\n", p->pw_name, p->pw_uid, p->pw_gid,
               p->pw_gecos, p->pw_dir, p->pw_shell);
        break;
      }
    }
    endpwent();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1211 <main+0xc1>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <setpwent@plt>
mov    $0x0,%al
call   1050 <getpwent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1205 <main+0xb5>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
cmp    -0x1c(%rbp),%eax
jne    1200 <main+0xb0>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%r8
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%r9
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rax
lea    0xe0e(%rip),%rdi
mov    %rax,(%rsp)
call   1030 <printf@plt>
jmp    1205 <main+0xb5>
jmp    119a <main+0x4a>
mov    $0x0,%al
call   1060 <endpwent@plt>
jmp    1166 <main+0x16>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jl     11d3 <main+0x83>
mov    %rsi,%r12
mov    %edi,%r15d
lea    0xe92(%rip),%r14
jmp    117c <main+0x2c>
xor    %eax,%eax
call   1060 <endpwent@plt>
cmp    $0x2,%ebx
jle    11d3 <main+0x83>
mov    %r15d,%ebx
lea    -0x1(%rbx),%r15d
mov    0x8(%r12),%rdi
add    $0x8,%r12
call   1070 <atoi@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <setpwent@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getpwent@plt>
test   %rax,%rax
je     1170 <main+0x20>
cmp    %ebp,(%rax)
jne    11a0 <main+0x50>
mov    0x8(%rax),%rsi
mov    0x10(%rax),%ecx
mov    0x18(%rax),%r8
mov    0x20(%rax),%r9
mov    0x28(%rax),%rax
mov    %rax,(%rsp)
mov    %r14,%rdi
mov    %ebp,%edx
call   1030 <printf@plt>
jmp    1170 <main+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.passwd = type { i32, i8*, i32, i8*, i8*, i8* }
@.str = [24 x i8] c"%s, %d, %d, %s, %s, %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %48, %2
%9 = load i32, i32* %4
%10 = add nsw i32 %9, -1
store i32 %10, i32* %4
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %50
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i32 1
store i8** %14, i8*** %5
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %7
%17 = call i32 (...) @setpwent()
br label %18
18: ; preds = %47, %12
%19 = call %struct.passwd* (...) @getpwent()
store %struct.passwd* %19, %struct.passwd** %6
%20 = icmp ne %struct.passwd* %19, null
br i1 %20, label %21, label %48
21: ; preds = %18
%22 = load %struct.passwd*, %struct.passwd** %6
%23 = getelementptr inbounds %struct.passwd, %struct.passwd* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = load i32, i32* %7
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %47
27: ; preds = %21
%28 = load %struct.passwd*, %struct.passwd** %6
%29 = getelementptr inbounds %struct.passwd, %struct.passwd* %28, i32 0, i32 1
%30 = load i8*, i8** %29
%31 = load %struct.passwd*, %struct.passwd** %6
%32 = getelementptr inbounds %struct.passwd, %struct.passwd* %31, i32 0, i32 0
%33 = load i32, i32* %32
%34 = load %struct.passwd*, %struct.passwd** %6
%35 = getelementptr inbounds %struct.passwd, %struct.passwd* %34, i32 0, i32 2
%36 = load i32, i32* %35
%37 = load %struct.passwd*, %struct.passwd** %6
%38 = getelementptr inbounds %struct.passwd, %struct.passwd* %37, i32 0, i32 3
%39 = load i8*, i8** %38
%40 = load %struct.passwd*, %struct.passwd** %6
%41 = getelementptr inbounds %struct.passwd, %struct.passwd* %40, i32 0, i32 4
%42 = load i8*, i8** %41
%43 = load %struct.passwd*, %struct.passwd** %6
%44 = getelementptr inbounds %struct.passwd, %struct.passwd* %43, i32 0, i32 5
%45 = load i8*, i8** %44
%46 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %30, i32 %33, i32 %36, i8* %39, i8* %42, i8* %45)
br label %48
47: ; preds = %21
br label %18
48: ; preds = %27, %18
%49 = call i32 (...) @endpwent()
br label %8
50: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i32, i8*, i32, i8*, i8*, i8* }
@.str = [24 x i8] c"%s, %d, %d, %s, %s, %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %34
4: ; preds = %2, %31
%5 = phi i32 [ %7, %31 ], [ %0, %2 ]
%6 = phi i8** [ %8, %31 ], [ %1, %2 ]
%7 = add nsw i32 %5, -1
%8 = getelementptr inbounds i8*, i8** %6, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = tail call i32 (...) @setpwent()
br label %12
12: ; preds = %15, %4
%13 = tail call %struct.passwd* (...) @getpwent()
%14 = icmp eq %struct.passwd* %13, null
br i1 %14, label %31, label %15
15: ; preds = %12
%16 = getelementptr inbounds %struct.passwd, %struct.passwd* %13, i64 0, i32 0
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, %10
br i1 %18, label %19, label %12
19: ; preds = %15
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %13, i64 0, i32 1
%21 = load i8*, i8** %20
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %13, i64 0, i32 2
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.passwd, %struct.passwd* %13, i64 0, i32 3
%25 = load i8*, i8** %24
%26 = getelementptr inbounds %struct.passwd, %struct.passwd* %13, i64 0, i32 4
%27 = load i8*, i8** %26
%28 = getelementptr inbounds %struct.passwd, %struct.passwd* %13, i64 0, i32 5
%29 = load i8*, i8** %28
%30 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %21, i32 %10, i32 %23, i8* %25, i8* %27, i8* %29)
br label %31
31: ; preds = %12, %19
%32 = tail call i32 (...) @endpwent()
%33 = icmp sgt i32 %5, 2
br i1 %33, label %4, label %34
34: ; preds = %31, %2
ret i32 0
}