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

/* Variables and functions */
int /*<<< orphan*/ getcwd(char *, int);
char *getenv(char *);
int /*<<< orphan*/ gethostname(char *, int);
int /*<<< orphan*/ printf(char *, char *, char *, char *);
int strlen(char *);
char *strrep(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ *strstr(char *, char *);
void shellInfo() {
  char hostn[1024] = "";
  char currentDirectory[1024] = "";
  gethostname(hostn, sizeof(hostn));
  if (strstr(hostn, "local") != NULL) {
    hostn[strlen(hostn) - 6] = '\0';
  }
  printf("\x1b[1m\x1B[32m%s@%s\x1b[0m:\x1b[1m\x1B[34m%s \x1b[0m$ ",
         getenv("LOGNAME"), hostn,
         strrep(getcwd(currentDirectory, 1024), getenv("HOME"), "~"));
}


x86 assembly (clang, -O0):
<shellInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
lea    -0x400(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x800(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
call   1090 <gethostname@plt>
lea    -0x400(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
je     11f8 <shellInfo+0x78>
lea    -0x400(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x6,%eax
cltq
movb   $0x0,-0x400(%rbp,%rax,1)
lea    0xe2d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x810(%rbp)
lea    -0x400(%rbp),%rax
mov    %rax,-0x808(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
call   1070 <getcwd@plt>
mov    %eax,-0x814(%rbp)
lea    0xdfd(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x814(%rbp),%edi
mov    %rax,%rsi
lea    0xded(%rip),%rdx
call   1080 <strrep@plt>
mov    -0x810(%rbp),%rsi
mov    -0x808(%rbp),%rdx
mov    %rax,%rcx
lea    0xd9d(%rip),%rdi
call   1050 <printf@plt>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shellInfo>:
push   %rbp
push   %rbx
sub    $0x808,%rsp
lea    0x400(%rsp),%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %rsp,%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1090 <gethostname@plt>
lea    0xe3d(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strstr@plt>
test   %rax,%rax
je     11df <shellInfo+0x5f>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x6(%rax,%rbx,1)
lea    0xe46(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1070 <getcwd@plt>
mov    %eax,%ebp
lea    0xe30(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe29(%rip),%rdx
mov    %ebp,%edi
mov    %rax,%rsi
call   1080 <strrep@plt>
lea    0xde5(%rip),%rdi
lea    0x400(%rsp),%rdx
mov    %rbx,%rsi
mov    %rax,%rcx
call   1050 <printf@plt>
add    $0x808,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"local\00"
@.str.1 = [38 x i8] c"\1B[1m\1B[32m%s@%s\1B[0m:\1B[1m\1B[34m%s \1B[0m$ \00"
@.str.2 = [8 x i8] c"LOGNAME\00"
@.str.3 = [5 x i8] c"HOME\00"
@.str.4 = [2 x i8] c"~\00"
define void @shellInfo() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = bitcast [1024 x i8]* %1 to i8*
%4 = bitcast [1024 x i8]* %2 to i8*
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%6 = call i32 @gethostname(i8* %5, i32 1024)
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%8 = call i32* @strstr(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %16
10: ; preds = %0
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
%13 = sub nsw i32 %12, 6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %14
store i8 0, i8* %15
br label %16
16: ; preds = %10, %0
%17 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%20 = call i32 @getcwd(i8* %19, i32 1024)
%21 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%22 = call i8* @strrep(i32 %20, i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %18, i8* %22)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"local\00"
@.str.1 = [38 x i8] c"\1B[1m\1B[32m%s@%s\1B[0m:\1B[1m\1B[34m%s \1B[0m$ \00"
@.str.2 = [8 x i8] c"LOGNAME\00"
@.str.3 = [5 x i8] c"HOME\00"
@.str.4 = [2 x i8] c"~\00"
define void @shellInfo() {
%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 = call i32 @gethostname(i8* %3, i32 1024)
%6 = call i32* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %13, label %8
8: ; preds = %0
%9 = call i32 @strlen(i8* %3)
%10 = add nsw i32 %9, -6
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %11
store i8 0, i8* %12
br label %13
13: ; preds = %8, %0
%14 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @getcwd(i8* %4, i32 1024)
%16 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%17 = call i8* @strrep(i32 %15, i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %3, i8* %17)
ret void
}