#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 */
scalar_t__ basename(char *);
int countupper(char const *);
char *getcwd(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcat(char *, char *);
scalar_t__ strcmp(int /*<<< orphan*/, char const *);
char *strrchr(char const *, char);
char *strremovelower(char const *);
char *strreplace(char const *, char *, char *);
int main(int argc, const char *argv[]) {
  const char *fullDirectory = getcwd(NULL, 1024);
  if (argc >= 2)
    fullDirectory = argv[1];
  const char *directory = (const char *)basename((char *)fullDirectory);
  int numberUpper = countupper(directory);
  if (strcmp(getenv("HOME"), fullDirectory) == 0) {
    printf("scratch");
  } else if (numberUpper <= 1) {
    directory = strreplace(directory, "joshuaoldenburg", "jo");
    directory = strreplace(directory, ".github.io", ".gh.io");
    directory = strreplace(directory, ".github.com", ".gh.com");
    printf("%s", directory);
  } else {
    char *suffix = strrchr(directory, '-');
    if (suffix)
      directory = strreplace(directory, suffix, "");
    directory = strremovelower(directory);
    if (suffix)
      directory = (const char *)strcat((char *)directory, suffix);
    printf("%s", directory);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
mov    $0x400,%esi
call   1060 <getcwd@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11de <main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   10a0 <basename@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   10b0 <countupper@plt>
mov    %eax,-0x24(%rbp)
lea    0xe02(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    122b <main+0x8b>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1312 <main+0x172>
cmpl   $0x1,-0x24(%rbp)
jg     129d <main+0xfd>
mov    -0x20(%rbp),%rdi
lea    0xdcd(%rip),%rsi
lea    0xdd6(%rip),%rdx
call   1080 <strreplace@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdc5(%rip),%rsi
lea    0xdc9(%rip),%rdx
call   1080 <strreplace@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdbc(%rip),%rsi
lea    0xdc1(%rip),%rdx
call   1080 <strreplace@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    130d <main+0x16d>
mov    -0x20(%rbp),%rdi
mov    $0x2d,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12d2 <main+0x132>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
lea    0xd3b(%rip),%rdx
call   1080 <strreplace@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <strremovelower@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12fb <main+0x15b>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10c0 <strcat@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1312 <main+0x172>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
xor    %edi,%edi
mov    $0x400,%esi
call   1060 <getcwd@plt>
cmp    $0x2,%ebp
jl     11c0 <main+0x20>
mov    0x8(%r14),%rbx
jmp    11c3 <main+0x23>
mov    %rax,%rbx
mov    %rbx,%rdi
call   10a0 <basename@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   10b0 <countupper@plt>
mov    %eax,%ebp
lea    0xe21(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     123c <main+0x9c>
cmp    $0x1,%ebp
jg     124c <main+0xac>
lea    0xe0e(%rip),%rsi
lea    0xe17(%rip),%rdx
mov    %r14,%rdi
call   1080 <strreplace@plt>
lea    0xe0b(%rip),%rsi
lea    0xe0f(%rip),%rdx
mov    %rax,%rdi
call   1080 <strreplace@plt>
lea    0xe07(%rip),%rsi
lea    0xe0c(%rip),%rdx
mov    %rax,%rdi
call   1080 <strreplace@plt>
jmp    1290 <main+0xf0>
lea    0xdc2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12a1 <main+0x101>
mov    %r14,%rdi
mov    $0x2d,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     1288 <main+0xe8>
mov    %rax,%rbx
lea    0xd9c(%rip),%rdx
mov    %r14,%rdi
mov    %rax,%rsi
call   1080 <strreplace@plt>
mov    %rax,%rdi
call   1070 <strremovelower@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   10c0 <strcat@plt>
jmp    1290 <main+0xf0>
mov    %r14,%rdi
call   1070 <strremovelower@plt>
lea    0xdaf(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [8 x i8] c"scratch\00"
@.str.2 = [16 x i8] c"joshuaoldenburg\00"
@.str.3 = [3 x i8] c"jo\00"
@.str.4 = [11 x i8] c".github.io\00"
@.str.5 = [7 x i8] c".gh.io\00"
@.str.6 = [12 x i8] c".github.com\00"
@.str.7 = [8 x i8] c".gh.com\00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i8* @getcwd(i32* null, i32 1024)
store i8* %10, i8** %6
%11 = load i32, i32* %4
%12 = icmp sge i32 %11, 2
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
store i8* %16, i8** %6
br label %17
17: ; preds = %13, %2
%18 = load i8*, i8** %6
%19 = call i64 @basename(i8* %18)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = call i32 @countupper(i8* %21)
store i32 %22, i32* %8
%23 = call i32 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%24 = load i8*, i8** %6
%25 = call i64 @strcmp(i32 %23, i8* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %17
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %64
29: ; preds = %17
%30 = load i32, i32* %8
%31 = icmp sle i32 %30, 1
br i1 %31, label %32, label %41
32: ; preds = %29
%33 = load i8*, i8** %7
%34 = call i8* @strreplace(i8* %33, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i8* %34, i8** %7
%35 = load i8*, i8** %7
%36 = call i8* @strreplace(i8* %35, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i8* %36, i8** %7
%37 = load i8*, i8** %7
%38 = call i8* @strreplace(i8* %37, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
store i8* %38, i8** %7
%39 = load i8*, i8** %7
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %39)
br label %63
41: ; preds = %29
%42 = load i8*, i8** %7
%43 = call i8* @strrchr(i8* %42, i8 signext 45)
store i8* %43, i8** %9
%44 = load i8*, i8** %9
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %50
46: ; preds = %41
%47 = load i8*, i8** %7
%48 = load i8*, i8** %9
%49 = call i8* @strreplace(i8* %47, i8* %48, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.9, i64 0, i64 0))
store i8* %49, i8** %7
br label %50
50: ; preds = %46, %41
%51 = load i8*, i8** %7
%52 = call i8* @strremovelower(i8* %51)
store i8* %52, i8** %7
%53 = load i8*, i8** %9
%54 = icmp ne i8* %53, null
br i1 %54, label %55, label %60
55: ; preds = %50
%56 = load i8*, i8** %7
%57 = load i8*, i8** %9
%58 = call i64 @strcat(i8* %56, i8* %57)
%59 = inttoptr i64 %58 to i8*
store i8* %59, i8** %7
br label %60
60: ; preds = %55, %50
%61 = load i8*, i8** %7
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %61)
br label %63
63: ; preds = %60, %32
br label %64
64: ; preds = %63, %27
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [8 x i8] c"scratch\00"
@.str.2 = [16 x i8] c"joshuaoldenburg\00"
@.str.3 = [3 x i8] c"jo\00"
@.str.4 = [11 x i8] c".github.io\00"
@.str.5 = [7 x i8] c".gh.io\00"
@.str.6 = [12 x i8] c".github.com\00"
@.str.7 = [8 x i8] c".gh.com\00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i8* @getcwd(i32* null, i32 1024)
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
br label %8
8: ; preds = %5, %2
%9 = phi i8* [ %7, %5 ], [ %3, %2 ]
%10 = tail call i64 @basename(i8* %9)
%11 = inttoptr i64 %10 to i8*
%12 = tail call i32 @countupper(i8* %11)
%13 = tail call i32 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = tail call i64 @strcmp(i32 %13, i8* %9)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %38
18: ; preds = %8
%19 = icmp slt i32 %12, 2
br i1 %19, label %20, label %25
20: ; preds = %18
%21 = tail call i8* @strreplace(i8* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%22 = tail call i8* @strreplace(i8* %21, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%23 = tail call i8* @strreplace(i8* %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %23)
br label %38
25: ; preds = %18
%26 = tail call i8* @strrchr(i8* dereferenceable(1) %11, i8 signext 45)
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = tail call i8* @strremovelower(i8* %11)
br label %35
30: ; preds = %25
%31 = tail call i8* @strreplace(i8* %11, i8* %26, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.9, i64 0, i64 0))
%32 = tail call i8* @strremovelower(i8* %31)
%33 = tail call i64 @strcat(i8* %32, i8* %26)
%34 = inttoptr i64 %33 to i8*
br label %35
35: ; preds = %28, %30
%36 = phi i8* [ %34, %30 ], [ %29, %28 ]
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %20, %35, %16
ret i32 0
}