#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
char *strdup(char const *);
char *get_host_from_url(const char *url) {
  char *p = strdup(url);
  while (*p != ':' && *p != '\0')
    p++;
  if (p[0] == '\0' || p[1] != '/' || p[2] != '/') {
    fprintf(stderr, "pactester.c: Not a proper URL\n");
    return NULL;
  }
  p = p + 3;
  char *host = p;
  if (*p == '\0' || *p == '/' || *p == ':') {
    fprintf(stderr, "pactester.c: Not a proper URL\n");
    return NULL;
  }
  while (*p != '/' && *p != ':' && *p != '\0')
    p++;
  *p = '\0';
  return host;
}


x86 assembly (clang, -O0):
<get_host_from_url>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3a,%ecx
mov    %al,-0x21(%rbp)
je     115e <get_host_from_url+0x3e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    116e <get_host_from_url+0x4e>
jmp    117f <get_host_from_url+0x5f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1139 <get_host_from_url+0x19>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b1 <get_host_from_url+0x91>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    11b1 <get_host_from_url+0x91>
mov    -0x18(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x2f,%eax
je     11d3 <get_host_from_url+0xb3>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    12a8 <get_host_from_url+0x188>
mov    -0x18(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1217 <get_host_from_url+0xf7>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1217 <get_host_from_url+0xf7>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1239 <get_host_from_url+0x119>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    12a8 <get_host_from_url+0x188>
jmp    123e <get_host_from_url+0x11e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0x22(%rbp)
je     1278 <get_host_from_url+0x158>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3a,%ecx
mov    %al,-0x22(%rbp)
je     1278 <get_host_from_url+0x158>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
test   $0x1,%al
jne    1288 <get_host_from_url+0x168>
jmp    1299 <get_host_from_url+0x179>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    123e <get_host_from_url+0x11e>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_host_from_url>:
push   %rax
call   1040 <strdup@plt>
add    $0x3,%rax
nopw   0x0(%rax,%rax,1)
movzbl -0x3(%rax),%ecx
test   %cl,%cl
je     116c <get_host_from_url+0x4c>
cmp    $0x3a,%cl
je     1143 <get_host_from_url+0x23>
add    $0x1,%rax
jmp    1130 <get_host_from_url+0x10>
cmpb   $0x2f,-0x2(%rax)
jne    116c <get_host_from_url+0x4c>
cmpb   $0x2f,-0x1(%rax)
jne    116c <get_host_from_url+0x4c>
lea    0x1(%rax),%rcx
movzbl (%rax),%esi
movabs $0x400800000000001,%rdx
cmp    $0x3a,%rsi
ja     1197 <get_host_from_url+0x77>
bt     %rsi,%rdx
jae    1197 <get_host_from_url+0x77>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rcx),%esi
add    $0x1,%rcx
cmp    $0x3a,%sil
ja     1190 <get_host_from_url+0x70>
movzbl %sil,%esi
bt     %rsi,%rdx
jae    1190 <get_host_from_url+0x70>
movb   $0x0,-0x1(%rcx)
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"pactester.c: Not a proper URL\0A\00"
define i8* @get_host_from_url(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @strdup(i8* %6)
store i8* %7, i8** %4
br label %8
8: ; preds = %20, %1
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 58
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br label %18
18: ; preds = %13, %8
%19 = phi i1 [ false, %8 ], [ %17, %13 ]
br i1 %19, label %20, label %23
20: ; preds = %18
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
br label %8
23: ; preds = %18
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 0
br i1 %28, label %41, label %29
29: ; preds = %23
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 47
br i1 %34, label %41, label %35
35: ; preds = %29
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 2
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 47
br i1 %40, label %41, label %44
41: ; preds = %35, %29, %23
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %2
br label %89
44: ; preds = %35
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i64 3
store i8* %46, i8** %4
%47 = load i8*, i8** %4
store i8* %47, i8** %5
%48 = load i8*, i8** %4
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 0
br i1 %51, label %62, label %52
52: ; preds = %44
%53 = load i8*, i8** %4
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 47
br i1 %56, label %62, label %57
57: ; preds = %52
%58 = load i8*, i8** %4
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 58
br i1 %61, label %62, label %65
62: ; preds = %57, %52, %44
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %2
br label %89
65: ; preds = %57
br label %66
66: ; preds = %83, %65
%67 = load i8*, i8** %4
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 47
br i1 %70, label %71, label %81
71: ; preds = %66
%72 = load i8*, i8** %4
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %74, 58
br i1 %75, label %76, label %81
76: ; preds = %71
%77 = load i8*, i8** %4
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp ne i32 %79, 0
br label %81
81: ; preds = %76, %71, %66
%82 = phi i1 [ false, %71 ], [ false, %66 ], [ %80, %76 ]
br i1 %82, label %83, label %86
83: ; preds = %81
%84 = load i8*, i8** %4
%85 = getelementptr inbounds i8, i8* %84, i32 1
store i8* %85, i8** %4
br label %66
86: ; preds = %81
%87 = load i8*, i8** %4
store i8 0, i8* %87
%88 = load i8*, i8** %5
store i8* %88, i8** %2
br label %89
89: ; preds = %86, %62, %41
%90 = load i8*, i8** %2
ret i8* %90
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"pactester.c: Not a proper URL\0A\00"
define noalias i8* @get_host_from_url(i8* nocapture %0) {
%2 = tail call i8* @strdup(i8* %0)
br label %3
3: ; preds = %6, %1
%4 = phi i8* [ %2, %1 ], [ %7, %6 ]
%5 = load i8, i8* %4
switch i8 %5, label %6 [
i8 0, label %16
i8 58, label %8
]
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
8: ; preds = %3
%9 = getelementptr inbounds i8, i8* %4, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 47
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %4, i64 2
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 47
br i1 %15, label %19, label %16
16: ; preds = %3, %12, %8
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %32
19: ; preds = %12
%20 = getelementptr inbounds i8, i8* %4, i64 3
%21 = load i8, i8* %20
switch i8 %21, label %25 [
i8 0, label %22
i8 47, label %22
i8 58, label %22
]
22: ; preds = %19, %19, %19
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %32
25: ; preds = %19, %28
%26 = phi i8 [ %30, %28 ], [ %21, %19 ]
%27 = phi i8* [ %29, %28 ], [ %20, %19 ]
switch i8 %26, label %28 [
i8 47, label %31
i8 58, label %31
i8 0, label %31
]
28: ; preds = %25
%29 = getelementptr inbounds i8, i8* %27, i64 1
%30 = load i8, i8* %29
br label %25
31: ; preds = %25, %25, %25
store i8 0, i8* %27
br label %32
32: ; preds = %22, %31, %16
%33 = phi i8* [ null, %16 ], [ null, %22 ], [ %20, %31 ]
ret i8* %33
}