#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 const *sp_pwdp;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
struct spwd *getspnam(char const *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, const char *argv[]) {
  struct spwd *ptr;
  if (argc != 2) {
    printf("wrong argument\n");
    exit(-1);
  }
  if ((ptr = getspnam(argv[1])) != NULL) {
    printf("shaow passwd = %s\n", ptr->sp_pwdp);
  } else {
    printf("there is no username %s\n", argv[1]);
    exit(-1);
  }
  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     1168 <main+0x38>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <getspnam@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     119d <main+0x6d>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bd <main+0x8d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    116c <main+0x2c>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <getspnam@plt>
test   %rax,%rax
je     1182 <main+0x42>
mov    (%rax),%rsi
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    0x8(%rbx),%rsi
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.spwd = type { i8* }
@.str = [16 x i8] c"wrong argument\0A\00"
@.str.1 = [19 x i8] c"shaow passwd = %s\0A\00"
@.str.2 = [25 x i8] c"there is no username %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.spwd*
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 %12
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call %struct.spwd* @getspnam(i8* %15)
store %struct.spwd* %16, %struct.spwd** %6
%17 = icmp ne %struct.spwd* %16, null
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load %struct.spwd*, %struct.spwd** %6
%20 = getelementptr inbounds %struct.spwd, %struct.spwd* %19, i32 0, i32 0
%21 = load i8*, i8** %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %29
23: ; preds = %12
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
%struct.spwd = type { i8* }
@.str.1 = [19 x i8] c"shaow passwd = %s\0A\00"
@.str.2 = [25 x i8] c"there is no username %s\0A\00"
@str = [15 x i8] c"wrong argument\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call %struct.spwd* @getspnam(i8* %9)
%11 = icmp eq %struct.spwd* %10, null
br i1 %11, label %16, label %12
12: ; preds = %7
%13 = getelementptr inbounds %struct.spwd, %struct.spwd* %10, i64 0, i32 0
%14 = load i8*, i8** %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %14)
ret i32 0
16: ; preds = %7
%17 = load i8*, i8** %8
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = tail call i32 @exit(i32 -1)
unreachable
}