#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 */

/* Variables and functions */
int /*<<< orphan*/ getcwd(char *, size_t);
char *getenv(char *);
int /*<<< orphan*/ gethostname(char *, size_t);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ printf(char *, ...);
void draw_prompt(void) {
  size_t len = 1024;
  char cwd[len];
  char hostname[len];
  memset(cwd, 0, len);
  memset(hostname, 0, len);
  getcwd(cwd, len);
  gethostname(hostname, len);
  printf("%s", getenv("USER"));
  printf("@");
  printf("%s:", hostname);
  printf("%s$ ", cwd);
}


x86 assembly (clang, -O0):
<draw_prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x400,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x28(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rdx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <getcwd@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <gethostname@plt>
lea    0xe21(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_prompt>:
push   %r14
push   %rbx
sub    $0x808,%rsp
lea    0x400(%rsp),%r14
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %rsp,%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    $0x400,%esi
mov    %r14,%rdi
call   1070 <getcwd@plt>
mov    $0x400,%esi
mov    %rbx,%rdi
call   1080 <gethostname@plt>
lea    0xe4f(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe40(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x40,%edi
call   1040 <putchar@plt>
lea    0xe2d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe20(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [2 x i8] c"@\00"
@.str.3 = [4 x i8] c"%s:\00"
@.str.4 = [5 x i8] c"%s$ \00"
define void @draw_prompt() {
%1 = alloca i64
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
store i64 1024, i64* %1
%5 = load i64, i64* %1
%6 = call i8* @llvm.stacksave()
store i8* %6, i8** %2
%7 = alloca i8, i64 %5
store i64 %5, i64* %3
%8 = load i64, i64* %1
%9 = alloca i8, i64 %8
store i64 %8, i64* %4
%10 = load i64, i64* %1
%11 = call i32 @memset(i8* %7, i32 0, i64 %10)
%12 = load i64, i64* %1
%13 = call i32 @memset(i8* %9, i32 0, i64 %12)
%14 = load i64, i64* %1
%15 = call i32 @getcwd(i8* %7, i64 %14)
%16 = load i64, i64* %1
%17 = call i32 @gethostname(i8* %9, i64 %16)
%18 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%23 = load i8*, i8** %2
ret void
}

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