#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 */
typedef int /*<<< orphan*/ hostname;
typedef int /*<<< orphan*/ cwd;

/* Variables and functions */
int /*<<< orphan*/ getcwd(char *, int);
char *getenv(char *);
int /*<<< orphan*/ gethostname(char *, int);
int /*<<< orphan*/ printf(char *, char *, char *, char *);
void print_prompt() {
  char cwd[1024];
  char hostname[1024];
  char *username;
  username = getenv("USER");
  getcwd(cwd, sizeof(cwd));
  gethostname(hostname, sizeof(hostname));
  printf("%s@%s:%s$ ", username, hostname, cwd);
}


x86 assembly (clang, -O0):
<print_prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
lea    0xeae(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x808(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
call   1050 <getcwd@plt>
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
call   1060 <gethostname@plt>
mov    -0x808(%rbp),%rsi
lea    -0x800(%rbp),%rdx
lea    -0x400(%rbp),%rcx
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_prompt>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
lea    0xead(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0x400(%rsp),%r14
mov    %r14,%rdi
mov    $0x400,%esi
call   1050 <getcwd@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x400,%esi
call   1060 <gethostname@plt>
lea    0xe7e(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <printf@plt>
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"USER\00"
@.str.1 = [11 x i8] c"%s@%s:%s$ \00"
define void @print_prompt() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = alloca i8*
%4 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %3
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%6 = call i32 @getcwd(i8* %5, i32 1024)
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = call i32 @gethostname(i8* %7, i32 1024)
%9 = load i8*, i8** %3
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %10, i8* %11)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"USER\00"
@.str.1 = [11 x i8] c"%s@%s:%s$ \00"
define void @print_prompt() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @getcwd(i8* %3, i32 1024)
%7 = call i32 @gethostname(i8* %4, i32 1024)
%8 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %4, i8* %3)
ret void
}