#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 {
  char *sp_namp;
  char *sp_pwdp;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct spwd *my_getspnam(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  struct spwd pwd;
  struct spwd *result;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s username\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  result = my_getspnam(argv[1]);
  if (result == NULL) {
    perror("my_getspnam");
    exit(EXIT_FAILURE);
  }
  pwd = *result;
  printf("Name: %s; Pwd: %s\n", pwd.sp_namp, pwd.sp_pwdp);
  exit(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)
cmpl   $0x2,-0x8(%rbp)
je     119a <main+0x4a>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <my_getspnam@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11d0 <main+0x80>
lea    0xe57(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
mov    %rcx,-0x20(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    1172 <main+0x22>
mov    0x8(%rsi),%rdi
call   1030 <my_getspnam@plt>
test   %rax,%rax
jne    1198 <main+0x48>
lea    0xea9(%rip),%rdi
call   1060 <perror@plt>
jmp    118a <main+0x3a>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe7b(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.spwd = type { i8*, i8* }
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s username\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"my_getspnam\00"
@.str.2 = [19 x i8] c"Name: %s; Pwd: %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 %struct.spwd
%7 = alloca %struct.spwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne 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 ([20 x i8], [20 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
%22 = call %struct.spwd* @my_getspnam(i8* %21)
store %struct.spwd* %22, %struct.spwd** %7
%23 = load %struct.spwd*, %struct.spwd** %7
%24 = icmp eq %struct.spwd* %23, null
br i1 %24, label %25, label %29
25: ; preds = %18
%26 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %18
%30 = load %struct.spwd*, %struct.spwd** %7
%31 = bitcast %struct.spwd* %6 to i8*
%32 = bitcast %struct.spwd* %30 to i8*
%33 = getelementptr inbounds %struct.spwd, %struct.spwd* %6, i32 0, i32 0
%34 = load i8*, i8** %33
%35 = getelementptr inbounds %struct.spwd, %struct.spwd* %6, i32 0, i32 1
%36 = load i8*, i8** %35
%37 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* %36)
%38 = load i32, i32* @EXIT_SUCCESS
%39 = call i32 @exit(i32 %38)
unreachable
}

LLVM IR (-O2):
%struct.spwd = type { i8*, i8* }
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s username\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"my_getspnam\00"
@.str.2 = [19 x i8] c"Name: %s; Pwd: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 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.spwd* @my_getspnam(i8* %12)
%14 = icmp eq %struct.spwd* %13, null
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = tail call i32 @exit(i32 %17)
unreachable
19: ; preds = %10
%20 = getelementptr inbounds %struct.spwd, %struct.spwd* %13, i64 0, i32 0
%21 = load i8*, i8** %20
%22 = getelementptr inbounds %struct.spwd, %struct.spwd* %13, i64 0, i32 1
%23 = load i8*, i8** %22
%24 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %21, i8* %23)
%25 = load i32, i32* @EXIT_SUCCESS
%26 = tail call i32 @exit(i32 %25)
unreachable
}