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

/* Variables and functions */
int /*<<< orphan*/ getcwd(char *, int);
int /*<<< orphan*/ gethostname(char *, int);
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
int /*<<< orphan*/ printf(char *, char *, char *, char *);
void print_prompt() {
  struct passwd *ppa;
  char hn[32], cwd[64];
  ppa = getpwuid(getuid());
  gethostname(hn, 32);
  getcwd(cwd, 64);
  printf("[%s@%s %s]# ", ppa->pw_name, hn, cwd);
}


x86 assembly (clang, -O0):
<print_prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    $0x0,%al
call   1040 <getuid@plt>
mov    %eax,%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   1070 <gethostname@plt>
lea    -0x70(%rbp),%rdi
mov    $0x40,%esi
call   1060 <getcwd@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x70(%rbp),%rcx
lea    0xe64(%rip),%rdi
call   1050 <printf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_prompt>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
xor    %eax,%eax
call   1040 <getuid@plt>
mov    %eax,%edi
call   1030 <getpwuid@plt>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x20,%esi
call   1070 <gethostname@plt>
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    $0x40,%esi
call   1060 <getcwd@plt>
mov    (%rbx),%rsi
lea    0xe6a(%rip),%rdi
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <printf@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.passwd = type { i8* }
@.str = [13 x i8] c"[%s@%s %s]# \00"
define void @print_prompt() {
%1 = alloca %struct.passwd*
%2 = alloca [32 x i8]
%3 = alloca [64 x i8]
%4 = call i32 (...) @getuid()
%5 = call %struct.passwd* @getpwuid(i32 %4)
store %struct.passwd* %5, %struct.passwd** %1
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%7 = call i32 @gethostname(i8* %6, i32 32)
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%9 = call i32 @getcwd(i8* %8, i32 64)
%10 = load %struct.passwd*, %struct.passwd** %1
%11 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i32 0, i32 0
%12 = load i8*, i8** %11
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %13, i8* %14)
ret void
}

LLVM IR (-O2):
%struct.passwd = type { i8* }
@.str = [13 x i8] c"[%s@%s %s]# \00"
define void @print_prompt() {
%1 = alloca [32 x i8]
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @getuid()
%6 = tail call %struct.passwd* @getpwuid(i32 %5)
%7 = call i32 @gethostname(i8* %3, i32 32)
%8 = call i32 @getcwd(i8* %4, i32 64)
%9 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 0
%10 = load i8*, i8** %9
%11 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %3, i8* %4)
ret void
}