#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 */
struct passwd {
  char *pw_name;
};
typedef int /*<<< orphan*/ cwd;

/* Variables and functions */
int /*<<< orphan*/ getcwd(char *, int);
int /*<<< orphan*/ gethostname(char *, int);
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
int /*<<< orphan*/ printf(char *, char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char const *);
void display_info() {
  struct passwd *p;
  char hostname[128] = {'\0'};
  char cwd[256] = {'\0'};
  char *token;
  const char delimiter[2] = "/";
  getcwd(cwd, sizeof(cwd));
  token = strtok(cwd, delimiter);
  while (token != NULL) {
    token = strtok(NULL, delimiter);
    if (token != NULL)
      strcpy(cwd, token);
  }
  p = getpwuid(getuid());
  gethostname(hostname, 128);
  printf("[%s@%s %s]# ", p->pw_name, hostname, cwd);
}


x86 assembly (clang, -O0):
<display_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
lea    -0x190(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
mov    0xe48(%rip),%ax
mov    %ax,-0x19a(%rbp)
lea    -0x190(%rbp),%rdi
mov    $0x100,%esi
call   1080 <getcwd@plt>
lea    -0x190(%rbp),%rdi
lea    -0x19a(%rbp),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x198(%rbp)
cmpq   $0x0,-0x198(%rbp)
je     1235 <display_info+0xb5>
lea    -0x19a(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1090 <strtok@plt>
mov    %rax,-0x198(%rbp)
cmpq   $0x0,-0x198(%rbp)
je     1230 <display_info+0xb0>
lea    -0x190(%rbp),%rdi
mov    -0x198(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11ea <display_info+0x6a>
mov    $0x0,%al
call   1050 <getuid@plt>
mov    %eax,%edi
call   1040 <getpwuid@plt>
mov    %rax,-0x8(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
call   10a0 <gethostname@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    -0x90(%rbp),%rdx
lea    -0x190(%rbp),%rcx
lea    0xd8e(%rip),%rdi
call   1060 <printf@plt>
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_info>:
push   %r14
push   %rbx
sub    $0x198,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%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)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movw   $0x2f,0xe(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1070 <getcwd@plt>
lea    0xe(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <strtok@plt>
test   %rax,%rax
je     128a <display_info+0x11a>
lea    0xe(%rsp),%rsi
xor    %edi,%edi
call   1080 <strtok@plt>
test   %rax,%rax
je     128a <display_info+0x11a>
lea    0x10(%rsp),%r14
lea    0xe(%rsp),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
jne    1270 <display_info+0x100>
xor    %eax,%eax
call   1050 <getuid@plt>
mov    %eax,%edi
call   1040 <getpwuid@plt>
mov    %rax,%rbx
lea    0x110(%rsp),%r14
mov    %r14,%rdi
mov    $0x80,%esi
call   1090 <gethostname@plt>
mov    (%rbx),%rsi
lea    0xd46(%rip),%rdi
lea    0x10(%rsp),%rcx
mov    %r14,%rdx
call   1060 <printf@plt>
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.passwd = type { i8* }
@__const.display_info.delimiter = [2 x i8] c"/\00"
@.str = [13 x i8] c"[%s@%s %s]# \00"
define void @display_info() {
%1 = alloca %struct.passwd*
%2 = alloca [128 x i8]
%3 = alloca [256 x i8]
%4 = alloca i8*
%5 = alloca [2 x i8]
%6 = bitcast [128 x i8]* %2 to i8*
%7 = bitcast [256 x i8]* %3 to i8*
%8 = bitcast [2 x i8]* %5 to i8*
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%10 = call i32 @getcwd(i8* %9, i32 256)
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%13 = call i8* @strtok(i8* %11, i8* %12)
store i8* %13, i8** %4
br label %14
14: ; preds = %26, %0
%15 = load i8*, i8** %4
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%19 = call i8* @strtok(i8* null, i8* %18)
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%24 = load i8*, i8** %4
%25 = call i32 @strcpy(i8* %23, i8* %24)
br label %26
26: ; preds = %22, %17
br label %14
27: ; preds = %14
%28 = call i32 (...) @getuid()
%29 = call %struct.passwd* @getpwuid(i32 %28)
store %struct.passwd* %29, %struct.passwd** %1
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%31 = call i32 @gethostname(i8* %30, i32 128)
%32 = load %struct.passwd*, %struct.passwd** %1
%33 = getelementptr inbounds %struct.passwd, %struct.passwd* %32, i32 0, i32 0
%34 = load i8*, i8** %33
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%37 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %34, i8* %35, i8* %36)
ret void
}

LLVM IR (-O2):
%struct.passwd = type { i8* }
@.str = [13 x i8] c"[%s@%s %s]# \00"
define void @display_info() {
%1 = alloca [128 x i8]
%2 = alloca [256 x i8]
%3 = alloca i16
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = bitcast i16* %3 to i8*
store i16 47, i16* %3
%7 = call i32 @getcwd(i8* %5, i32 256)
%8 = call i8* @strtok(i8* %5, i8* %6)
%9 = icmp eq i8* %8, null
br i1 %9, label %18, label %10
10: ; preds = %0
%11 = call i8* @strtok(i8* null, i8* %6)
%12 = icmp eq i8* %11, null
br i1 %12, label %18, label %13
13: ; preds = %10, %13
%14 = phi i8* [ %16, %13 ], [ %11, %10 ]
%15 = call i32 @strcpy(i8* %5, i8* %14)
%16 = call i8* @strtok(i8* null, i8* %6)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %13
18: ; preds = %13, %10, %0
%19 = call i32 (...) @getuid()
%20 = call %struct.passwd* @getpwuid(i32 %19)
%21 = call i32 @gethostname(i8* %4, i32 128)
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %20, i64 0, i32 0
%23 = load i8*, i8** %22
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %4, i8* %5)
ret void
}