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

/* Variables and functions */
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ errx(int, char *);
struct passwd *getpwnam(char *);
int /*<<< orphan*/ printf(char *, char *, int, char *, char *);
int main(int argc, char **argv) {
  if (argc != 2)
    err(1, "getpwnam <username>");
  struct passwd *pw = getpwnam(argv[1]);
  if (!pw)
    errx(1, "getpwnam: no user");
  printf("user %s, uid %d, dir %s, shell %s\n", pw->pw_name, pw->pw_uid,
         pw->pw_dir, pw->pw_shell);
  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     1171 <main+0x31>
mov    $0x1,%edi
lea    0xe94(%rip),%rsi
call   1060 <err@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119e <main+0x5e>
mov    $0x1,%edi
lea    0xe7b(%rip),%rsi
call   1030 <errx@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rcx
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%r8
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
je     115a <main+0x1a>
lea    0xeb0(%rip),%rsi
mov    $0x1,%edi
call   1060 <err@plt>
mov    0x8(%rbx),%rdi
call   1050 <getpwnam@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    117c <main+0x3c>
lea    0xea2(%rip),%rsi
mov    $0x1,%edi
call   1030 <errx@plt>
mov    (%rbx),%rsi
mov    0x8(%rbx),%edx
mov    0x10(%rbx),%rcx
mov    0x18(%rbx),%r8
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.passwd = type { i8*, i32, i8*, i8* }
@.str = [20 x i8] c"getpwnam <username>\00"
@.str.1 = [18 x i8] c"getpwnam: no user\00"
@.str.2 = [35 x i8] c"user %s, uid %d, dir %s, shell %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @err(i32 1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call %struct.passwd* @getpwnam(i8* %14)
store %struct.passwd* %15, %struct.passwd** %6
%16 = load %struct.passwd*, %struct.passwd** %6
%17 = icmp ne %struct.passwd* %16, null
br i1 %17, label %20, label %18
18: ; preds = %11
%19 = call i32 @errx(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %11
%21 = load %struct.passwd*, %struct.passwd** %6
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %21, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = load %struct.passwd*, %struct.passwd** %6
%25 = getelementptr inbounds %struct.passwd, %struct.passwd* %24, i32 0, i32 1
%26 = load i32, i32* %25
%27 = load %struct.passwd*, %struct.passwd** %6
%28 = getelementptr inbounds %struct.passwd, %struct.passwd* %27, i32 0, i32 2
%29 = load i8*, i8** %28
%30 = load %struct.passwd*, %struct.passwd** %6
%31 = getelementptr inbounds %struct.passwd, %struct.passwd* %30, i32 0, i32 3
%32 = load i8*, i8** %31
%33 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %23, i32 %26, i8* %29, i8* %32)
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i32, i8*, i8* }
@.str = [20 x i8] c"getpwnam <username>\00"
@.str.1 = [18 x i8] c"getpwnam: no user\00"
@.str.2 = [35 x i8] c"user %s, uid %d, dir %s, shell %s\0A\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 @err(i32 1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call %struct.passwd* @getpwnam(i8* %8)
%10 = icmp eq %struct.passwd* %9, null
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
%14 = getelementptr inbounds %struct.passwd, %struct.passwd* %9, i64 0, i32 0
%15 = load i8*, i8** %14
%16 = getelementptr inbounds %struct.passwd, %struct.passwd* %9, i64 0, i32 1
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.passwd, %struct.passwd* %9, i64 0, i32 2
%19 = load i8*, i8** %18
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %9, i64 0, i32 3
%21 = load i8*, i8** %20
%22 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %15, i32 %17, i8* %19, i8* %21)
ret i32 0
}