#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 char int8_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *getcwd(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int8_t *greeting() {
  int8_t wd[256];
  if (getcwd(wd, 255) == NULL) {
    perror("getcwd");
    exit(EXIT_FAILURE);
  }
  printf("\e[0;48;05;11;38;05;16m"
         "%s "
         "\e[0;38;05;11m"
         ""
         "\e[0;01;38;05;11m",
         wd);
  return " ";
}


x86 assembly (clang, -O0):
<greeting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
lea    -0x100(%rbp),%rdi
mov    $0xff,%esi
call   1040 <getcwd@plt>
cmp    $0x0,%rax
jne    1180 <greeting+0x40>
lea    0xe93(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
lea    -0x100(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
lea    0xea7(%rip),%rax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<greeting>:
sub    $0x108,%rsp
mov    %rsp,%rdi
mov    $0xff,%esi
call   1040 <getcwd@plt>
test   %rax,%rax
je     1177 <greeting+0x37>
lea    0xea7(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
lea    0xed2(%rip),%rax
add    $0x108,%rsp
ret
lea    0xe82(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"getcwd\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [58 x i8] c"\1B[0;48;05;11;38;05;16m%s \1B[0;38;05;11m\EE\82\B0\1B[0;01;38;05;11m\00"
@.str.2 = [2 x i8] c" \00"
define i8* @greeting() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32* @getcwd(i8* %2, i32 255)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = call i32 @exit(i32 %7)
unreachable
9: ; preds = %0
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%11 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i8* %10)
ret i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
}

LLVM IR (-O2):
@.str = [7 x i8] c"getcwd\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [58 x i8] c"\1B[0;48;05;11;38;05;16m%s \1B[0;38;05;11m\EE\82\B0\1B[0;01;38;05;11m\00"
@.str.2 = [2 x i8] c" \00"
define i8* @greeting() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32* @getcwd(i8* %2, i32 255)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = call i32 @exit(i32 %7)
unreachable
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
}