#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*/ STDOUT_FILENO;
int /*<<< orphan*/ getcwd(char *, int);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int /*<<< orphan*/);
void print_prompt() {
  char cwd[256];
  getcwd(cwd, 256);
  write(STDOUT_FILENO, cwd, strlen(cwd));
  char invite[] = " > ";
  write(STDOUT_FILENO, invite, strlen(invite));
}


x86 assembly (clang, -O0):
<print_prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
lea    -0x100(%rbp),%rdi
mov    $0x100,%esi
call   1050 <getcwd@plt>
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x124(%rbp)
lea    -0x100(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    -0x100(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x124(%rbp),%edi
mov    -0x120(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    0xe71(%rip),%eax
mov    %eax,-0x104(%rbp)
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x114(%rbp)
lea    -0x104(%rbp),%rax
mov    %rax,-0x110(%rbp)
lea    -0x104(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x114(%rbp),%edi
mov    -0x110(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_prompt>:
push   %rbp
push   %r14
push   %rbx
sub    $0x110,%rsp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1050 <getcwd@plt>
mov    0x2e9c(%rip),%r14
mov    (%r14),%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
movl   $0x203e20,0xc(%rsp)
mov    (%r14),%ebx
lea    0xc(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@__const.print_prompt.invite = [4 x i8] c" > \00"
define void @print_prompt() {
%1 = alloca [256 x i8]
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = call i32 @getcwd(i8* %3, i32 256)
%5 = load i32, i32* @STDOUT_FILENO
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
%9 = call i32 @write(i32 %5, i8* %6, i32 %8)
%10 = bitcast [4 x i8]* %2 to i8*
%11 = load i32, i32* @STDOUT_FILENO
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = call i32 @write(i32 %11, i8* %12, i32 %14)
ret void
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
define void @print_prompt() {
%1 = alloca [256 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = call i32 @getcwd(i8* %3, i32 256)
%5 = load i32, i32* @STDOUT_FILENO
%6 = call i32 @strlen(i8* %3)
%7 = call i32 @write(i32 %5, i8* %3, i32 %6)
%8 = bitcast i32* %2 to i8*
store i32 2113056, i32* %2
%9 = load i32, i32* @STDOUT_FILENO
%10 = call i32 @strlen(i8* %8)
%11 = call i32 @write(i32 %9, i8* %8, i32 %10)
ret void
}