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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ getcwd(char *, int);
int /*<<< orphan*/ getenv(char *);
int /*<<< orphan*/ gethostname(char *, int);
int /*<<< orphan*/ replaceHomeDir(char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
void typePrompt() {
  fprintf(stdout, "[MySh] ");
  char username[50] = "";
  strcpy(username, getenv("USER"));
  char hostname[50] = "";
  gethostname(hostname, sizeof(hostname));
  fprintf(stdout, "%s@%s:", username, hostname);
  char currDir[255] = "";
  getcwd(currDir, sizeof(currDir));
  replaceHomeDir(currDir);
  fprintf(stdout, "%s$ ", currDir);
}


x86 assembly (clang, -O0):
<typePrompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x188(%rbp)
lea    0xe54(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x188(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
lea    -0x80(%rbp),%rdi
mov    $0x32,%esi
call   1090 <gethostname@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rdx
lea    -0x80(%rbp),%rcx
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    -0x180(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1050 <memset@plt>
lea    -0x180(%rbp),%rdi
mov    $0xff,%esi
call   1060 <getcwd@plt>
lea    -0x180(%rbp),%rdi
call   1070 <replaceHomeDir@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
lea    -0x180(%rbp),%rdx
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<typePrompt>:
push   %r15
push   %r14
push   %rbx
sub    $0x180,%rsp
mov    0x2e6d(%rip),%r15
mov    (%r15),%edi
lea    0xe83(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movw   $0x0,0x70(%rsp)
lea    0xe64(%rip),%rdi
call   1030 <getenv@plt>
lea    0x40(%rsp),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movw   $0x0,0x30(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1080 <gethostname@plt>
mov    (%r15),%edi
lea    0xe23(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
xorps  %xmm0,%xmm0
movups %xmm0,0x16f(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1050 <getcwd@plt>
mov    %rbx,%rdi
call   1060 <replaceHomeDir@plt>
mov    (%r15),%edi
lea    0xd73(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x180,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [8 x i8] c"[MySh] \00"
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [7 x i8] c"%s@%s:\00"
@.str.3 = [5 x i8] c"%s$ \00"
define void @typePrompt() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = alloca [255 x i8]
%4 = load i32, i32* @stdout
%5 = call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = bitcast [50 x i8]* %1 to i8*
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%8 = call i32 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @strcpy(i8* %7, i32 %8)
%10 = bitcast [50 x i8]* %2 to i8*
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%12 = call i32 @gethostname(i8* %11, i32 50)
%13 = load i32, i32* @stdout
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %14, i8* %15)
%17 = bitcast [255 x i8]* %3 to i8*
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%19 = call i32 @getcwd(i8* %18, i32 255)
%20 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%21 = call i32 @replaceHomeDir(i8* %20)
%22 = load i32, i32* @stdout
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %23)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [8 x i8] c"[MySh] \00"
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [7 x i8] c"%s@%s:\00"
@.str.3 = [5 x i8] c"%s$ \00"
define void @typePrompt() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = alloca [255 x i8]
%4 = load i32, i32* @stdout
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%7 = tail call i32 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @strcpy(i8* %6, i32 %7)
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%10 = call i32 @gethostname(i8* %9, i32 50)
%11 = load i32, i32* @stdout
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* %9)
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%14 = call i32 @getcwd(i8* %13, i32 255)
%15 = call i32 @replaceHomeDir(i8* %13)
%16 = load i32, i32* @stdout
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %13)
ret void
}