#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 int /*<<< orphan*/ dest;

/* Variables and functions */
scalar_t__ malloc(int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok_r(char *, char *, char **);
void get_domain(char *address, char **domain, char **destination, char **file) {
  char *dom, *dest, *fl;
  char *temp;
  dom = strtok_r(address, "/", &dest);
  if (strcmp(dest, "") == 0) {
    dest = (char *)malloc(sizeof(char) * 2);
    strcpy(dest, "/");
  }
  fl = (char *)malloc(sizeof(dest));
  temp = dest;
  while (strcmp(temp, "") != 0) {
    strcpy(fl, temp);
    fl = strtok_r(fl, "/", &temp);
  }
  if (fl == NULL) {
    fl = (char *)malloc(sizeof(char) * 4);
    strcpy(fl, "any");
  }
  *domain = dom;
  *destination = dest;
  *file = fl;
}


x86 assembly (clang, -O0):
<get_domain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9d(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11a8 <get_domain+0x68>
mov    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1030 <strcpy@plt>
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1202 <get_domain+0xc2>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
lea    0xe10(%rip),%rsi
lea    -0x40(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x38(%rbp)
jmp    11be <get_domain+0x7e>
cmpq   $0x0,-0x38(%rbp)
jne    122b <get_domain+0xeb>
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_domain>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
lea    0xea2(%rip),%rsi
lea    0x10(%rsp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,%r13
mov    0x10(%rsp),%rdi
lea    0xe8a(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    119f <get_domain+0x5f>
mov    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,0x10(%rsp)
lea    0xe69(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rbp
mov    %rbp,0x8(%rsp)
lea    0xe44(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
mov    %r14,0x20(%rsp)
mov    %r15,0x18(%rsp)
je     1250 <get_domain+0x110>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
lea    0xe1a(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <strtok_r@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rdi
lea    0xdff(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1250 <get_domain+0x110>
lea    0xded(%rip),%rbp
lea    0x8(%rsp),%r14
lea    0xde2(%rip),%r15
nop
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1040 <strtok_r@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1220 <get_domain+0xe0>
test   %rbx,%rbx
jne    1271 <get_domain+0x131>
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xd99(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %r13,(%r12)
mov    0x10(%rsp),%rax
mov    0x18(%rsp),%rcx
mov    %rax,(%rcx)
mov    0x20(%rsp),%rax
mov    %rbx,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [4 x i8] c"any\00"
define void @get_domain(i8* %0, i8** %1, i8** %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i8** %3, i8*** %8
%13 = load i8*, i8** %5
%14 = call i8* @strtok_r(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %10)
store i8* %14, i8** %9
%15 = load i8*, i8** %10
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %4
%19 = call i64 @malloc(i32 2)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %10
%21 = load i8*, i8** %10
%22 = call i32 @strcpy(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %18, %4
%24 = call i64 @malloc(i32 8)
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %11
%26 = load i8*, i8** %10
store i8* %26, i8** %12
br label %27
27: ; preds = %31, %23
%28 = load i8*, i8** %12
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %27
%32 = load i8*, i8** %11
%33 = load i8*, i8** %12
%34 = call i32 @strcpy(i8* %32, i8* %33)
%35 = load i8*, i8** %11
%36 = call i8* @strtok_r(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %12)
store i8* %36, i8** %11
br label %27
37: ; preds = %27
%38 = load i8*, i8** %11
%39 = icmp eq i8* %38, null
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = call i64 @malloc(i32 4)
%42 = inttoptr i64 %41 to i8*
store i8* %42, i8** %11
%43 = load i8*, i8** %11
%44 = call i32 @strcpy(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %40, %37
%46 = load i8*, i8** %9
%47 = load i8**, i8*** %6
store i8* %46, i8** %47
%48 = load i8*, i8** %10
%49 = load i8**, i8*** %7
store i8* %48, i8** %49
%50 = load i8*, i8** %11
%51 = load i8**, i8*** %8
store i8* %50, i8** %51
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [4 x i8] c"any\00"
define void @get_domain(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2, i8** nocapture writeonly %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = bitcast i8** %5 to i8*
%8 = bitcast i8** %6 to i8*
%9 = call i8* @strtok_r(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %5)
%10 = load i8*, i8** %5
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = call i64 @malloc(i32 2)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %5
%16 = call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %13, %4
%18 = call i64 @malloc(i32 8)
%19 = inttoptr i64 %18 to i8*
%20 = load i8*, i8** %5
store i8* %20, i8** %6
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %37, label %23
23: ; preds = %17
%24 = call i32 @strcpy(i8* %19, i8* %20)
%25 = call i8* @strtok_r(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6)
%26 = load i8*, i8** %6
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %23, %29
%30 = phi i8* [ %33, %29 ], [ %25, %23 ]
%31 = load i8*, i8** %6
%32 = call i32 @strcpy(i8* %30, i8* %31)
%33 = call i8* @strtok_r(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6)
%34 = load i8*, i8** %6
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %29
37: ; preds = %29, %23, %17
%38 = phi i8* [ %19, %17 ], [ %25, %23 ], [ %33, %29 ]
%39 = icmp eq i8* %38, null
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = call i64 @malloc(i32 4)
%42 = inttoptr i64 %41 to i8*
%43 = call i32 @strcpy(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %40, %37
%45 = phi i8* [ %42, %40 ], [ %38, %37 ]
store i8* %9, i8** %1
%46 = load i8*, i8** %5
store i8* %46, i8** %2
store i8* %45, i8** %3
ret void
}