#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__ atoi(char *);
int /*<<< orphan*/ free(char *);
scalar_t__ strcmp(char *, char *);
char *strdup(char const *);
void *strtoul(char *, char **, int /*<<< orphan*/);
int get_host_and_port_and_drive(const char *name, char **hostname,
                                char **display, short *port, int *drive) {
  char *newname = strdup(name);
  char *p;
  char *p2;
  p = newname;
  while (*p != '/' && *p)
    p++;
  p2 = p;
  if (*p)
    p++;
  *p2 = 0;
  *port = 5703;
  if (*p >= '0' && *p <= '9')
    *port = strtoul(p, &p, 0);
  if (*p == '/')
    p++;
  *drive = 0;
  if (*p >= '0' && *p <= '9')
    *drive = strtoul(p, &p, 0);
  *display = strdup(newname);
  p = newname;
  while (*p != ':' && *p)
    p++;
  p2 = p;
  if (*p)
    p++;
  *p2 = 0;
  *port += atoi(p);
  if (!*newname || strcmp(newname, "unix") == 0) {
    free(newname);
    newname = strdup("localhost");
  }
  *hostname = newname;
  return 1;
}


x86 assembly (clang, -O0):
<get_host_and_port_and_drive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0x41(%rbp)
je     11a6 <get_host_and_port_and_drive+0x56>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    11b6 <get_host_and_port_and_drive+0x66>
jmp    11c7 <get_host_and_port_and_drive+0x77>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1181 <get_host_and_port_and_drive+0x31>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e8 <get_host_and_port_and_drive+0x98>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movw   $0x1647,(%rax)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     1231 <get_host_and_port_and_drive+0xe1>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     1231 <get_host_and_port_and_drive+0xe1>
mov    -0x38(%rbp),%rdi
lea    -0x38(%rbp),%rsi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %ax,%cx
mov    -0x20(%rbp),%rax
mov    %cx,(%rax)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    124d <get_host_and_port_and_drive+0xfd>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     128e <get_host_and_port_and_drive+0x13e>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     128e <get_host_and_port_and_drive+0x13e>
mov    -0x38(%rbp),%rdi
lea    -0x38(%rbp),%rsi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3a,%ecx
mov    %al,-0x42(%rbp)
je     12ce <get_host_and_port_and_drive+0x17e>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x42(%rbp)
mov    -0x42(%rbp),%al
test   $0x1,%al
jne    12de <get_host_and_port_and_drive+0x18e>
jmp    12ef <get_host_and_port_and_drive+0x19f>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    12a9 <get_host_and_port_and_drive+0x159>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
cmpb   $0x0,(%rax)
je     1310 <get_host_and_port_and_drive+0x1c0>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x38(%rbp),%rdi
call   1060 <atoi@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movswq (%rax),%rcx
add    %rdx,%rcx
mov    %cx,(%rax)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     1358 <get_host_and_port_and_drive+0x208>
mov    -0x30(%rbp),%rdi
lea    0xcb7(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1371 <get_host_and_port_and_drive+0x221>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
lea    0xc9d(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_host_and_port_and_drive>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r13
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r14
call   1070 <strdup@plt>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
test   %cl,%cl
je     1192 <get_host_and_port_and_drive+0x42>
cmp    $0x2f,%cl
je     1197 <get_host_and_port_and_drive+0x47>
add    $0x1,%rax
jmp    1180 <get_host_and_port_and_drive+0x30>
mov    %rax,%rdi
jmp    119b <get_host_and_port_and_drive+0x4b>
lea    0x1(%rax),%rdi
mov    %rdi,0x8(%rsp)
movb   $0x0,(%rax)
movw   $0x1647,(%r15)
mov    (%rdi),%al
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     11ca <get_host_and_port_and_drive+0x7a>
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %ax,(%r15)
mov    0x8(%rsp),%rdi
mov    (%rdi),%al
cmp    $0x2f,%al
jne    11d7 <get_host_and_port_and_drive+0x87>
add    $0x1,%rdi
mov    %rdi,0x8(%rsp)
movl   $0x0,0x0(%r13)
mov    (%rdi),%al
add    $0xd0,%al
cmp    $0x9,%al
ja     11f7 <get_host_and_port_and_drive+0xa7>
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %eax,0x0(%r13)
mov    %rbx,%rdi
call   1070 <strdup@plt>
mov    %rax,(%r12)
mov    %rbx,%rax
cs nopw 0x0(%rax,%rax,1)
movzbl (%rax),%ecx
test   %cl,%cl
je     1222 <get_host_and_port_and_drive+0xd2>
cmp    $0x3a,%cl
je     1227 <get_host_and_port_and_drive+0xd7>
add    $0x1,%rax
jmp    1210 <get_host_and_port_and_drive+0xc0>
mov    %rax,%rdi
jmp    122b <get_host_and_port_and_drive+0xdb>
lea    0x1(%rax),%rdi
movb   $0x0,(%rax)
call   1060 <atoi@plt>
add    %ax,(%r15)
cmpb   $0x0,(%rbx)
je     1250 <get_host_and_port_and_drive+0x100>
lea    0xdbd(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1267 <get_host_and_port_and_drive+0x117>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xda6(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,%rbx
mov    %rbx,(%r14)
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"unix\00"
@.str.1 = [10 x i8] c"localhost\00"
define i32 @get_host_and_port_and_drive(i8* %0, i8** %1, i8** %2, i16* %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i16*
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i16* %3, i16** %9
store i32* %4, i32** %10
%14 = load i8*, i8** %6
%15 = call i8* @strdup(i8* %14)
store i8* %15, i8** %11
%16 = load i8*, i8** %11
store i8* %16, i8** %12
br label %17
17: ; preds = %29, %5
%18 = load i8*, i8** %12
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 47
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i8*, i8** %12
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br label %27
27: ; preds = %22, %17
%28 = phi i1 [ false, %17 ], [ %26, %22 ]
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = load i8*, i8** %12
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %12
br label %17
32: ; preds = %27
%33 = load i8*, i8** %12
store i8* %33, i8** %13
%34 = load i8*, i8** %12
%35 = load i8, i8* %34
%36 = icmp ne i8 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i8*, i8** %12
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %12
br label %40
40: ; preds = %37, %32
%41 = load i8*, i8** %13
store i8 0, i8* %41
%42 = load i16*, i16** %9
store i16 5703, i16* %42
%43 = load i8*, i8** %12
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp sge i32 %45, 48
br i1 %46, label %47, label %57
47: ; preds = %40
%48 = load i8*, i8** %12
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp sle i32 %50, 57
br i1 %51, label %52, label %57
52: ; preds = %47
%53 = load i8*, i8** %12
%54 = call i8* @strtoul(i8* %53, i8** %12, i32 0)
%55 = ptrtoint i8* %54 to i16
%56 = load i16*, i16** %9
store i16 %55, i16* %56
br label %57
57: ; preds = %52, %47, %40
%58 = load i8*, i8** %12
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 47
br i1 %61, label %62, label %65
62: ; preds = %57
%63 = load i8*, i8** %12
%64 = getelementptr inbounds i8, i8* %63, i32 1
store i8* %64, i8** %12
br label %65
65: ; preds = %62, %57
%66 = load i32*, i32** %10
store i32 0, i32* %66
%67 = load i8*, i8** %12
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp sge i32 %69, 48
br i1 %70, label %71, label %81
71: ; preds = %65
%72 = load i8*, i8** %12
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp sle i32 %74, 57
br i1 %75, label %76, label %81
76: ; preds = %71
%77 = load i8*, i8** %12
%78 = call i8* @strtoul(i8* %77, i8** %12, i32 0)
%79 = ptrtoint i8* %78 to i32
%80 = load i32*, i32** %10
store i32 %79, i32* %80
br label %81
81: ; preds = %76, %71, %65
%82 = load i8*, i8** %11
%83 = call i8* @strdup(i8* %82)
%84 = load i8**, i8*** %8
store i8* %83, i8** %84
%85 = load i8*, i8** %11
store i8* %85, i8** %12
br label %86
86: ; preds = %98, %81
%87 = load i8*, i8** %12
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp ne i32 %89, 58
br i1 %90, label %91, label %96
91: ; preds = %86
%92 = load i8*, i8** %12
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp ne i32 %94, 0
br label %96
96: ; preds = %91, %86
%97 = phi i1 [ false, %86 ], [ %95, %91 ]
br i1 %97, label %98, label %101
98: ; preds = %96
%99 = load i8*, i8** %12
%100 = getelementptr inbounds i8, i8* %99, i32 1
store i8* %100, i8** %12
br label %86
101: ; preds = %96
%102 = load i8*, i8** %12
store i8* %102, i8** %13
%103 = load i8*, i8** %12
%104 = load i8, i8* %103
%105 = icmp ne i8 %104, 0
br i1 %105, label %106, label %109
106: ; preds = %101
%107 = load i8*, i8** %12
%108 = getelementptr inbounds i8, i8* %107, i32 1
store i8* %108, i8** %12
br label %109
109: ; preds = %106, %101
%110 = load i8*, i8** %13
store i8 0, i8* %110
%111 = load i8*, i8** %12
%112 = call i64 @atoi(i8* %111)
%113 = load i16*, i16** %9
%114 = load i16, i16* %113
%115 = sext i16 %114 to i64
%116 = add nsw i64 %115, %112
%117 = trunc i64 %116 to i16
store i16 %117, i16* %113
%118 = load i8*, i8** %11
%119 = load i8, i8* %118
%120 = icmp ne i8 %119, 0
br i1 %120, label %121, label %125
121: ; preds = %109
%122 = load i8*, i8** %11
%123 = call i64 @strcmp(i8* %122, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%124 = icmp eq i64 %123, 0
br i1 %124, label %125, label %129
125: ; preds = %121, %109
%126 = load i8*, i8** %11
%127 = call i32 @free(i8* %126)
%128 = call i8* @strdup(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i8* %128, i8** %11
br label %129
129: ; preds = %125, %121
%130 = load i8*, i8** %11
%131 = load i8**, i8*** %7
store i8* %130, i8** %131
ret i32 1
}

LLVM IR (-O2):
@.str = [5 x i8] c"unix\00"
@.str.1 = [10 x i8] c"localhost\00"
define i32 @get_host_and_port_and_drive(i8* nocapture %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2, i16* nocapture %3, i32* nocapture writeonly %4) {
%6 = alloca i8*
%7 = tail call i8* @strdup(i8* %0)
%8 = bitcast i8** %6 to i8*
br label %9
9: ; preds = %12, %5
%10 = phi i8* [ %7, %5 ], [ %13, %12 ]
%11 = load i8, i8* %10
switch i8 %11, label %12 [
i8 0, label %16
i8 47, label %14
]
12: ; preds = %9
%13 = getelementptr inbounds i8, i8* %10, i64 1
br label %9
14: ; preds = %9
%15 = getelementptr inbounds i8, i8* %10, i64 1
br label %16
16: ; preds = %9, %14
%17 = phi i8* [ %15, %14 ], [ %10, %9 ]
store i8* %17, i8** %6
store i8 0, i8* %10
store i16 5703, i16* %3
%18 = load i8, i8* %17
%19 = add i8 %18, -48
%20 = icmp ult i8 %19, 10
br i1 %20, label %21, label %27
21: ; preds = %16
%22 = call i8* @strtoul(i8* %17, i8** %6, i32 0)
%23 = ptrtoint i8* %22 to i64
%24 = trunc i64 %23 to i16
store i16 %24, i16* %3
%25 = load i8*, i8** %6
%26 = load i8, i8* %25
br label %27
27: ; preds = %21, %16
%28 = phi i8 [ %26, %21 ], [ %18, %16 ]
%29 = phi i8* [ %25, %21 ], [ %17, %16 ]
%30 = icmp eq i8 %28, 47
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = getelementptr inbounds i8, i8* %29, i64 1
store i8* %32, i8** %6
br label %33
33: ; preds = %31, %27
%34 = phi i8* [ %32, %31 ], [ %29, %27 ]
store i32 0, i32* %4
%35 = load i8, i8* %34
%36 = add i8 %35, -48
%37 = icmp ult i8 %36, 10
br i1 %37, label %38, label %42
38: ; preds = %33
%39 = call i8* @strtoul(i8* %34, i8** %6, i32 0)
%40 = ptrtoint i8* %39 to i64
%41 = trunc i64 %40 to i32
store i32 %41, i32* %4
br label %42
42: ; preds = %38, %33
%43 = tail call i8* @strdup(i8* %7)
store i8* %43, i8** %2
br label %44
44: ; preds = %47, %42
%45 = phi i8* [ %7, %42 ], [ %48, %47 ]
%46 = load i8, i8* %45
switch i8 %46, label %47 [
i8 0, label %51
i8 58, label %49
]
47: ; preds = %44
%48 = getelementptr inbounds i8, i8* %45, i64 1
br label %44
49: ; preds = %44
%50 = getelementptr inbounds i8, i8* %45, i64 1
br label %51
51: ; preds = %44, %49
%52 = phi i8* [ %50, %49 ], [ %45, %44 ]
store i8 0, i8* %45
%53 = tail call i64 @atoi(i8* %52)
%54 = load i16, i16* %3
%55 = trunc i64 %53 to i16
%56 = add i16 %54, %55
store i16 %56, i16* %3
%57 = load i8, i8* %7
%58 = icmp eq i8 %57, 0
br i1 %58, label %62, label %59
59: ; preds = %51
%60 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %59, %51
%63 = tail call i32 @free(i8* %7)
%64 = tail call dereferenceable_or_null(10) i8* @strdup(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %65
65: ; preds = %62, %59
%66 = phi i8* [ %64, %62 ], [ %7, %59 ]
store i8* %66, i8** %1
ret i32 1
}