#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 */
char *do_nofail(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ strdup(char const *);
int strlen(char *);
char *normalize_domain(const char *dom) {
  char *p, *ret;
  ret = do_nofail((strdup(dom)),
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/mrash/psad/refs/heads/"
                  "master/deps/whois/whois.c",
                  1163);
  p = ret + strlen(ret) - 1;
  while (p > ret) {
    if (!(*p == '.' || *p == ' ' || *p == '\t'))
      break;
    *p = '\0';
    p--;
  }
  return ret;
}


x86 assembly (clang, -O0):
<normalize_domain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strdup@plt>
mov    %eax,%edi
lea    0xeb2(%rip),%rsi
mov    $0x48b,%edx
call   1040 <do_nofail@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    11dc <normalize_domain+0xac>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     11c4 <normalize_domain+0x94>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     11c4 <normalize_domain+0x94>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
je     11c4 <normalize_domain+0x94>
jmp    11dc <normalize_domain+0xac>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1181 <normalize_domain+0x51>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize_domain>:
push   %rbx
call   1050 <strdup@plt>
lea    0xec3(%rip),%rsi
mov    %eax,%edi
mov    $0x48b,%edx
call   1040 <do_nofail@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
jbe    118b <normalize_domain+0x5b>
movabs $0x400100000200,%rcx
nopl   0x0(%rax)
movzbl (%rax),%edx
cmp    $0x2e,%rdx
ja     118b <normalize_domain+0x5b>
bt     %rdx,%rcx
jae    118b <normalize_domain+0x5b>
movb   $0x0,(%rax)
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
ja     1170 <normalize_domain+0x40>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mrash/psad/refs/heads/master/deps/whois/whois.c\00"
define i8* @normalize_domain(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strdup(i8* %5)
%7 = call i8* @do_nofail(i32 %6, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 1163)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
%13 = getelementptr inbounds i8, i8* %12, i64 -1
store i8* %13, i8** %3
br label %14
14: ; preds = %34, %1
%15 = load i8*, i8** %3
%16 = load i8*, i8** %4
%17 = icmp ugt i8* %15, %16
br i1 %17, label %18, label %38
18: ; preds = %14
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 46
br i1 %22, label %34, label %23
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 32
br i1 %27, label %34, label %28
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 9
br i1 %32, label %34, label %33
33: ; preds = %28
br label %38
34: ; preds = %28, %23, %18
%35 = load i8*, i8** %3
store i8 0, i8* %35
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i32 -1
store i8* %37, i8** %3
br label %14
38: ; preds = %33, %14
%39 = load i8*, i8** %4
ret i8* %39
}

LLVM IR (-O2):
@.str = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mrash/psad/refs/heads/master/deps/whois/whois.c\00"
define i8* @normalize_domain(i8* %0) {
%2 = tail call i32 @strdup(i8* %0)
%3 = tail call i8* @do_nofail(i32 %2, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 1163)
%4 = tail call i32 @strlen(i8* %3)
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %3, i64 %5
%7 = getelementptr inbounds i8, i8* %6, i64 -1
%8 = icmp ugt i8* %7, %3
br i1 %8, label %9, label %15
9: ; preds = %1, %12
%10 = phi i8* [ %13, %12 ], [ %7, %1 ]
%11 = load i8, i8* %10
switch i8 %11, label %15 [
i8 46, label %12
i8 32, label %12
i8 9, label %12
]
12: ; preds = %9, %9, %9
store i8 0, i8* %10
%13 = getelementptr inbounds i8, i8* %10, i64 -1
%14 = icmp ugt i8* %13, %3
br i1 %14, label %9, label %15
15: ; preds = %12, %9, %1
ret i8* %3
}