#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 *, int);
int /*<<< orphan*/ gethostname(char *, int);
char *getlogin();
int /*<<< orphan*/ my_char(char);
int /*<<< orphan*/ my_str(char *);
void writePrompt(char *hostname, char *cwd) {
  getcwd(cwd, 256);
  gethostname(hostname, 256);
  my_str("\033[32;1m");
  my_str(getlogin());
  my_char('@');
  my_str(hostname);
  my_str("\033[37;1m");
  my_char(':');
  my_str("\033[34;1m");
  my_str(cwd);
  my_str(" $ ");
  my_str("\033[00m");
}


x86 assembly (clang, -O0):
<writePrompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x100,%esi
call   1030 <getcwd@plt>
mov    -0x8(%rbp),%rdi
mov    $0x100,%esi
call   1070 <gethostname@plt>
lea    0xe7d(%rip),%rdi
call   1060 <my_str@plt>
mov    $0x0,%al
call   1040 <getlogin@plt>
mov    %rax,%rdi
call   1060 <my_str@plt>
mov    $0x40,%edi
call   1050 <my_char@plt>
mov    -0x8(%rbp),%rdi
call   1060 <my_str@plt>
lea    0xe57(%rip),%rdi
call   1060 <my_str@plt>
mov    $0x3a,%edi
call   1050 <my_char@plt>
lea    0xe49(%rip),%rdi
call   1060 <my_str@plt>
mov    -0x10(%rbp),%rdi
call   1060 <my_str@plt>
lea    0xe3c(%rip),%rdi
call   1060 <my_str@plt>
lea    0xe34(%rip),%rdi
call   1060 <my_str@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writePrompt>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    $0x100,%esi
call   1030 <getcwd@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
call   1070 <gethostname@plt>
lea    0xe85(%rip),%rdi
call   1060 <my_str@plt>
xor    %eax,%eax
call   1040 <getlogin@plt>
mov    %rax,%rdi
call   1060 <my_str@plt>
mov    $0x40,%edi
call   1050 <my_char@plt>
mov    %rbx,%rdi
call   1060 <my_str@plt>
lea    0xe60(%rip),%rdi
call   1060 <my_str@plt>
mov    $0x3a,%edi
call   1050 <my_char@plt>
lea    0xe52(%rip),%rdi
call   1060 <my_str@plt>
mov    %r14,%rdi
call   1060 <my_str@plt>
lea    0xe46(%rip),%rdi
call   1060 <my_str@plt>
lea    0xe3e(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <my_str@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"\1B[32;1m\00"
@.str.1 = [8 x i8] c"\1B[37;1m\00"
@.str.2 = [8 x i8] c"\1B[34;1m\00"
@.str.3 = [4 x i8] c" $ \00"
@.str.4 = [6 x i8] c"\1B[00m\00"
define void @writePrompt(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = call i32 @getcwd(i8* %5, i32 256)
%7 = load i8*, i8** %3
%8 = call i32 @gethostname(i8* %7, i32 256)
%9 = call i32 @my_str(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = call i8* (...) @getlogin()
%11 = call i32 @my_str(i8* %10)
%12 = call i32 @my_char(i8 signext 64)
%13 = load i8*, i8** %3
%14 = call i32 @my_str(i8* %13)
%15 = call i32 @my_str(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @my_char(i8 signext 58)
%17 = call i32 @my_str(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%18 = load i8*, i8** %4
%19 = call i32 @my_str(i8* %18)
%20 = call i32 @my_str(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @my_str(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"\1B[32;1m\00"
@.str.1 = [8 x i8] c"\1B[37;1m\00"
@.str.2 = [8 x i8] c"\1B[34;1m\00"
@.str.3 = [4 x i8] c" $ \00"
@.str.4 = [6 x i8] c"\1B[00m\00"
define void @writePrompt(i8* %0, i8* %1) {
%3 = tail call i32 @getcwd(i8* %1, i32 256)
%4 = tail call i32 @gethostname(i8* %0, i32 256)
%5 = tail call i32 @my_str(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = tail call i8* (...) @getlogin()
%7 = tail call i32 @my_str(i8* %6)
%8 = tail call i32 @my_char(i8 signext 64)
%9 = tail call i32 @my_str(i8* %0)
%10 = tail call i32 @my_str(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @my_char(i8 signext 58)
%12 = tail call i32 @my_str(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @my_str(i8* %1)
%14 = tail call i32 @my_str(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%15 = tail call i32 @my_str(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret void
}