#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*/ ERR_R_MALLOC_FAILURE;
int /*<<< orphan*/ OCSP_R_ERROR_PARSING_URL;
int /*<<< orphan*/ OCSPerror(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *strchr(char *, char);
char *strdup(char const *);
scalar_t__ strncmp(char const *, char *, int);
int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
                   int *pssl) {
  char *host, *path, *port, *tmp;
  *phost = *pport = *ppath = NULL;
  *pssl = 0;
  if (strncmp(url, "https://", 8) == 0) {
    *pssl = 1;
    host = strdup(url + 8);
  } else if (strncmp(url, "http://", 7) == 0)
    host = strdup(url + 7);
  else {
    OCSPerror(OCSP_R_ERROR_PARSING_URL);
    return 0;
  }
  if (host == NULL) {
    OCSPerror(ERR_R_MALLOC_FAILURE);
    return 0;
  }
  if ((tmp = strchr(host, '/')) != NULL) {
    path = strdup(tmp);
    *tmp = '\0';
  } else
    path = strdup("/");
  if ((tmp = strchr(host, ':')) != NULL) {
    port = strdup(tmp + 1);
    *tmp = '\0';
  } else {
    if (*pssl)
      port = strdup("443");
    else
      port = strdup("80");
  }
  if (path == NULL || port == NULL) {
    free(host);
    free(path);
    free(port);
    OCSPerror(ERR_R_MALLOC_FAILURE);
    return 0;
  }
  *phost = host;
  *ppath = path;
  *pport = port;
  return 1;
}


x86 assembly (clang, -O0):
<OCSP_parse_url>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    11d6 <OCSP_parse_url+0x86>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
call   1070 <strdup@plt>
mov    %rax,-0x38(%rbp)
jmp    122a <OCSP_parse_url+0xda>
mov    -0x10(%rbp),%rdi
lea    0xe28(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    120b <OCSP_parse_url+0xbb>
mov    -0x10(%rbp),%rdi
add    $0x7,%rdi
call   1070 <strdup@plt>
mov    %rax,-0x38(%rbp)
jmp    1225 <OCSP_parse_url+0xd5>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1060 <OCSPerror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1377 <OCSP_parse_url+0x227>
jmp    122a <OCSP_parse_url+0xda>
cmpq   $0x0,-0x38(%rbp)
jne    124f <OCSP_parse_url+0xff>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   1060 <OCSPerror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1377 <OCSP_parse_url+0x227>
mov    -0x38(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     1284 <OCSP_parse_url+0x134>
mov    -0x50(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x40(%rbp)
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
jmp    1294 <OCSP_parse_url+0x144>
lea    0xd84(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     12cd <OCSP_parse_url+0x17d>
mov    -0x50(%rbp),%rdi
add    $0x1,%rdi
call   1070 <strdup@plt>
mov    %rax,-0x48(%rbp)
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
jmp    1304 <OCSP_parse_url+0x1b4>
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
je     12ef <OCSP_parse_url+0x19f>
lea    0xd30(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x48(%rbp)
jmp    12ff <OCSP_parse_url+0x1af>
lea    0xd1f(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x48(%rbp)
jmp    1304 <OCSP_parse_url+0x1b4>
cmpq   $0x0,-0x40(%rbp)
je     131a <OCSP_parse_url+0x1ca>
cmpq   $0x0,-0x48(%rbp)
jne    134f <OCSP_parse_url+0x1ff>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    0x2cac(%rip),%rax
mov    (%rax),%edi
call   1060 <OCSPerror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1377 <OCSP_parse_url+0x227>
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x48(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OCSP_parse_url>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbp
movq   $0x0,(%rcx)
movq   $0x0,(%rdx)
movq   $0x0,(%rsi)
movl   $0x0,(%r8)
lea    0xe73(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     11c1 <OCSP_parse_url+0x71>
lea    0xe66(%rip),%rsi
mov    %rbp,%rdi
mov    $0x7,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     11ce <OCSP_parse_url+0x7e>
mov    0x2e24(%rip),%rax
jmp    12a6 <OCSP_parse_url+0x156>
movl   $0x1,(%rbx)
mov    $0x8,%eax
jmp    11d3 <OCSP_parse_url+0x83>
mov    $0x7,%eax
add    %rax,%rbp
mov    %rbp,%rdi
call   1070 <strdup@plt>
test   %rax,%rax
je     129f <OCSP_parse_url+0x14f>
mov    %rax,%r13
mov    %rax,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1211 <OCSP_parse_url+0xc1>
mov    %rax,%rbp
mov    %rax,%rdi
call   1070 <strdup@plt>
mov    %rax,(%rsp)
movb   $0x0,0x0(%rbp)
jmp    1221 <OCSP_parse_url+0xd1>
lea    0xdf7(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,(%rsp)
mov    %r13,%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     124b <OCSP_parse_url+0xfb>
mov    %rax,%rbp
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <strdup@plt>
mov    %rax,%rbx
movb   $0x0,0x0(%rbp)
jmp    1268 <OCSP_parse_url+0x118>
cmpl   $0x0,(%rbx)
je     1259 <OCSP_parse_url+0x109>
lea    0xdba(%rip),%rdi
jmp    1260 <OCSP_parse_url+0x110>
lea    0xdb5(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,%rbx
mov    (%rsp),%rbp
test   %rbp,%rbp
je     1287 <OCSP_parse_url+0x137>
test   %rbx,%rbx
je     1287 <OCSP_parse_url+0x137>
mov    %r13,(%r12)
mov    %rbp,(%r14)
mov    %rbx,(%r15)
mov    $0x1,%eax
jmp    12af <OCSP_parse_url+0x15f>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
call   1060 <OCSPerror@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"https://\00"
@.str.1 = [8 x i8] c"http://\00"
@OCSP_R_ERROR_PARSING_URL = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [4 x i8] c"443\00"
@.str.4 = [3 x i8] c"80\00"
define i32 @OCSP_parse_url(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2, i8** nocapture writeonly %3, i32* nocapture %4) {
store i8* null, i8** %3
store i8* null, i8** %2
store i8* null, i8** %1
store i32 0, i32* %4
%6 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %5
store i32 1, i32* %4
br label %15
9: ; preds = %5
%10 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* @OCSP_R_ERROR_PARSING_URL
%14 = tail call i32 @OCSPerror(i32 %13)
br label %56
15: ; preds = %9, %8
%16 = phi i64 [ 8, %8 ], [ 7, %9 ]
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = tail call i8* @strdup(i8* %17)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* @ERR_R_MALLOC_FAILURE
%22 = tail call i32 @OCSPerror(i32 %21)
br label %56
23: ; preds = %15
%24 = tail call i8* @strchr(i8* %18, i8 signext 47)
%25 = icmp eq i8* %24, null
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = tail call i8* @strdup(i8* %24)
store i8 0, i8* %24
br label %30
28: ; preds = %23
%29 = tail call dereferenceable_or_null(2) i8* @strdup(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %28, %26
%31 = phi i8* [ %27, %26 ], [ %29, %28 ]
%32 = tail call i8* @strchr(i8* %18, i8 signext 58)
%33 = icmp eq i8* %32, null
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = getelementptr inbounds i8, i8* %32, i64 1
%36 = tail call i8* @strdup(i8* %35)
store i8 0, i8* %32
br label %44
37: ; preds = %30
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = tail call dereferenceable_or_null(4) i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %44
42: ; preds = %37
%43 = tail call dereferenceable_or_null(3) i8* @strdup(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %40, %42, %34
%45 = phi i8* [ %36, %34 ], [ %41, %40 ], [ %43, %42 ]
%46 = icmp eq i8* %31, null
%47 = icmp eq i8* %45, null
%48 = select i1 %46, i1 true, i1 %47
br i1 %48, label %49, label %55
49: ; preds = %44
%50 = tail call i32 @free(i8* %18)
%51 = tail call i32 @free(i8* %31)
%52 = tail call i32 @free(i8* %45)
%53 = load i32, i32* @ERR_R_MALLOC_FAILURE
%54 = tail call i32 @OCSPerror(i32 %53)
br label %56
55: ; preds = %44
store i8* %18, i8** %1
store i8* %31, i8** %3
store i8* %45, i8** %2
br label %56
56: ; preds = %55, %49, %20, %12
%57 = phi i32 [ 0, %20 ], [ 0, %49 ], [ 1, %55 ], [ 0, %12 ]
ret i32 %57
}