#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_shell;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *getlogin();
struct passwd *getpwnam(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char *login_name;
  struct passwd *pw;
  if ((login_name = getlogin()) == NULL) {
    fprintf(stderr, "Err.(%s) getlogin() failed\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  pw = getpwnam(login_name);
  printf("       login name: %s\n", login_name);
  printf("/etc/passwd shell: %s\n", pw->pw_shell);
  return (EXIT_SUCCESS);
}


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    $0x0,%al
call   1060 <getlogin@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11c5 <main+0x65>
mov    0x2e4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xe4e(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1040 <getpwnam@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe43(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <getlogin@plt>
test   %rax,%rax
je     11ad <main+0x4d>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <getpwnam@plt>
mov    %rax,%r14
lea    0xe97(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    (%r14),%rsi
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e2c(%rip),%rax
mov    (%rax),%ebx
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe35(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.passwd = type { i8* }
@stderr = global i32 0
@.str = [28 x i8] c"Err.(%s) getlogin() failed\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [23 x i8] c" login name: %s\0A\00"
@.str.2 = [23 x i8] c"/etc/passwd shell: %s\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 i8*
%7 = alloca %struct.passwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i8* (...) @getlogin()
store i8* %8, i8** %6
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = load i8*, i8** %6
%19 = call %struct.passwd* @getpwnam(i8* %18)
store %struct.passwd* %19, %struct.passwd** %7
%20 = load i8*, i8** %6
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load %struct.passwd*, %struct.passwd** %7
%23 = getelementptr inbounds %struct.passwd, %struct.passwd* %22, i32 0, i32 0
%24 = load i8*, i8** %23
%25 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}

LLVM IR (-O2):
%struct.passwd = type { i8* }
@stderr = global i32 0
@.str = [28 x i8] c"Err.(%s) getlogin() failed\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [23 x i8] c" login name: %s\0A\00"
@.str.2 = [23 x i8] c"/etc/passwd shell: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* (...) @getlogin()
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = tail call %struct.passwd* @getpwnam(i8* %3)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%15 = getelementptr inbounds %struct.passwd, %struct.passwd* %13, i64 0, i32 0
%16 = load i8*, i8** %15
%17 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}