#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*/ BUFSIZ;
int /*<<< orphan*/ clearerr(int /*<<< orphan*/);
scalar_t__ feof(int /*<<< orphan*/);
char *getcwd(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
void printPrompt() {
  char buf[BUFSIZ + sizeof(char)];
  if (feof(stdin)) {
    clearerr(stdin);
    printf("\n");
  }
  printf("[3150 shell:%s]$ ", getcwd(buf, BUFSIZ));
}


x86 assembly (clang, -O0):
<printPrompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e89(%rip),%rax
movslq (%rax),%rdx
mov    %rdx,%rax
add    $0x1,%rax
mov    %rsp,%rcx
mov    %rcx,-0x8(%rbp)
add    $0x10,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x10(%rbp)
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     11ad <printPrompt+0x6d>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
call   1060 <clearerr@plt>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
call   1040 <getcwd@plt>
mov    %rax,%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printPrompt>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e77(%rip),%r14
movslq (%r14),%rax
mov    %rsp,%rbx
add    $0x10,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x2e6c(%rip),%r15
mov    (%r15),%edi
call   1060 <feof@plt>
test   %rax,%rax
je     119b <printPrompt+0x4b>
mov    (%r15),%edi
call   1070 <clearerr@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%r14),%esi
mov    %rbx,%rdi
call   1050 <getcwd@plt>
lea    0xe53(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@stdin = global i32 0
@.str = [2 x i8] c"\0A\00"
@.str.1 = [18 x i8] c"[3150 shell:%s]$ \00"
define void @printPrompt() {
%1 = alloca i8*
%2 = alloca i64
%3 = load i32, i32* @BUFSIZ
%4 = sext i32 %3 to i64
%5 = add i64 %4, 1
%6 = call i8* @llvm.stacksave()
store i8* %6, i8** %1
%7 = alloca i8, i64 %5
store i64 %5, i64* %2
%8 = load i32, i32* @stdin
%9 = call i64 @feof(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = load i32, i32* @stdin
%13 = call i32 @clearerr(i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %11, %0
%16 = load i32, i32* @BUFSIZ
%17 = call i8* @getcwd(i8* %7, i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %1
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@stdin = global i32 0
@.str.1 = [18 x i8] c"[3150 shell:%s]$ \00"
define void @printPrompt() {
%1 = load i32, i32* @BUFSIZ
%2 = sext i32 %1 to i64
%3 = add nsw i64 %2, 1
%4 = alloca i8, i64 %3
%5 = load i32, i32* @stdin
%6 = tail call i64 @feof(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = load i32, i32* @stdin
%10 = tail call i32 @clearerr(i32 %9)
%11 = tail call i32 @putchar(i32 10)
br label %12
12: ; preds = %8, %0
%13 = load i32, i32* @BUFSIZ
%14 = call i8* @getcwd(i8* %4, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %14)
ret void
}