#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_passwd;
  int pw_uid;
  int pw_gid;
  char *pw_gecos;
  char *pw_dir;
  char *pw_shell;
  int /*<<< orphan*/ pw_name;
};

/* Variables and functions */
int /*<<< orphan*/ strcpy(char *, char const *);
struct passwd *getpwnam(const char *name) {
  static struct passwd pw;
  static char namebuf[100];
  pw.pw_name = strcpy(namebuf, name);
  pw.pw_passwd = "*";
  pw.pw_uid = 100;
  pw.pw_gid = 100;
  pw.pw_gecos = "";
  pw.pw_dir = "/";
  pw.pw_shell = "/bin/sh";
  return &pw;
}


x86 assembly (clang, -O0):
<getpwnam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2f49(%rip),%rdi
call   1030 <strcpy@plt>
mov    %eax,0x2f36(%rip)
lea    0xec7(%rip),%rax
mov    %rax,0x2f00(%rip)
movl   $0x64,0x2efe(%rip)
movl   $0x64,0x2ef8(%rip)
lea    0xea6(%rip),%rax
mov    %rax,0x2eee(%rip)
lea    0xe99(%rip),%rax
mov    %rax,0x2ee8(%rip)
lea    0xe8d(%rip),%rax
mov    %rax,0x2ee2(%rip)
lea    0x2ebb(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getpwnam>:
push   %rax
mov    %rdi,%rsi
lea    0x2f55(%rip),%rdi
call   1030 <strcpy@plt>
mov    %eax,0x2f42(%rip)
lea    0x2f13(%rip),%rax
lea    0xecc(%rip),%rcx
mov    %rcx,0x2f05(%rip)
movabs $0x6400000064,%rcx
mov    %rcx,0x2efc(%rip)
lea    0xeae(%rip),%rcx
mov    %rcx,0x2ef6(%rip)
lea    0xea1(%rip),%rcx
mov    %rcx,0x2ef0(%rip)
lea    0xe95(%rip),%rcx
mov    %rcx,0x2eea(%rip)
pop    %rcx
ret

LLVM IR (-O0):
%struct.passwd = type { i8*, i32, i32, i8*, i8*, i8*, i32 }
@getpwnam.pw = internal global %struct.passwd zeroinitializer
@getpwnam.namebuf = internal global [100 x i8] zeroinitializer
@.str = [2 x i8] c"*\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [8 x i8] c"/bin/sh\00"
define %struct.passwd* @getpwnam(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @strcpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @getpwnam.namebuf, i64 0, i64 0), i8* %3)
store i32 %4, i32* getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i32 0, i32 6)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i32 0, i32 0)
store i32 100, i32* getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i32 0, i32 1)
store i32 100, i32* getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i32 0, i32 2)
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i32 0, i32 3)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i32 0, i32 4)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i32 0, i32 5)
ret %struct.passwd* @getpwnam.pw
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i32, i32, i8*, i8*, i8*, i32 }
@getpwnam.pw = internal global %struct.passwd zeroinitializer
@getpwnam.namebuf = internal global [100 x i8] zeroinitializer
@.str = [2 x i8] c"*\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [8 x i8] c"/bin/sh\00"
define %struct.passwd* @getpwnam(i8* %0) {
%2 = tail call i32 @strcpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @getpwnam.namebuf, i64 0, i64 0), i8* %0)
store i32 %2, i32* getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i64 0, i32 6)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i64 0, i32 0)
store i32 100, i32* getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i64 0, i32 1)
store i32 100, i32* getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i64 0, i32 2)
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i64 0, i32 3)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i64 0, i32 4)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** getelementptr inbounds (%struct.passwd, %struct.passwd* @getpwnam.pw, i64 0, i32 5)
ret %struct.passwd* @getpwnam.pw
}