#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*/ uint32_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ htonl(int);
int /*<<< orphan*/ htons(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int send(int, void *, int, int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *);
void cache_expire_url(int sock, char *url) {
  char *buf;
  if (sock < 0) {
    return;
  }
  int idx = 0;
  int url_len;
  url_len = strlen(url);
  buf = (char *)malloc(12 + 22 + url_len);
  if (!buf) {
    return;
  }
  idx = 0;
  *((uint16_t *)(&buf[idx])) = htons(12 + 22 + url_len);
  idx += 2;
  buf[idx++] = 0;
  buf[idx++] = 0;
  *((uint16_t *)(&buf[idx])) = htons(8 + 22 + url_len);
  idx += 2;
  buf[idx++] = 4;
  buf[idx++] = 0;
  *((uint32_t *)(&buf[idx])) = htonl(255);
  idx += 4;
  buf[idx++] = 0;
  buf[idx++] = 0;
  *((uint16_t *)(&buf[idx])) = htons(4);
  idx += 2;
  memcpy(&buf[idx], "HEAD", 4);
  idx += 4;
  *((uint16_t *)(&buf[idx])) = htons(url_len);
  idx += 2;
  memcpy(&buf[idx], url, url_len);
  idx += url_len;
  *((uint16_t *)(&buf[idx])) = htons(8);
  idx += 2;
  memcpy(&buf[idx], "HTTP/1.1", 8);
  idx += 8;
  *((uint16_t *)(&buf[idx])) = htons(0);
  if (send(sock, (void *)buf, (12 + 22 + url_len), 0) < (12 + 22 + url_len)) {
    syslog(LOG_ERR, "Failed to send HTCP purge for %s\n", url);
  };
  free(buf);
}


x86 assembly (clang, -O0):
<cache_expire_url>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    119e <cache_expire_url+0x1e>
jmp    13dd <cache_expire_url+0x25d>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
add    $0x22,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d0 <cache_expire_url+0x50>
jmp    13dd <cache_expire_url+0x25d>
movl   $0x0,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
add    $0x22,%edi
call   1050 <htons@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%edi
add    $0x1e,%edi
call   1050 <htons@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movb   $0x4,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    $0xff,%edi
call   1070 <htonl@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    $0x4,%edi
call   1050 <htons@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
lea    0xd11(%rip),%rsi
mov    $0x4,%edx
call   1080 <memcpy@plt>
mov    -0x1c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1080 <memcpy@plt>
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x8,%edi
call   1050 <htons@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
lea    0xc93(%rip),%rsi
mov    $0x8,%edx
call   1080 <memcpy@plt>
mov    -0x1c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x1c(%rbp)
xor    %edi,%edi
call   1050 <htons@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,1)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
add    $0x22,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    -0x20(%rbp),%ecx
add    $0x22,%ecx
cmp    %ecx,%eax
jge    13d4 <cache_expire_url+0x254>
mov    0x2c16(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xc3f(%rip),%rsi
call   10a0 <syslog@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cache_expire_url>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
js     1298 <cache_expire_url+0x118>
mov    %rsi,%r14
mov    %edi,%r15d
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0x22(%rbp),%r12d
mov    %r12d,%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     1298 <cache_expire_url+0x118>
mov    %rax,%rbx
mov    %r12d,%edi
call   1050 <htons@plt>
mov    %eax,(%rbx)
movw   $0x0,0x2(%rbx)
lea    0x1e(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,0x4(%rbx)
movw   $0x4,0x6(%rbx)
mov    $0xff,%edi
call   1070 <htonl@plt>
mov    %eax,0x8(%rbx)
movw   $0x0,0xc(%rbx)
mov    $0x4,%edi
call   1050 <htons@plt>
mov    %eax,0xe(%rbx)
lea    0x10(%rbx),%rdi
lea    0xdfc(%rip),%rsi
mov    $0x4,%edx
call   1080 <memcpy@plt>
mov    %ebp,%edi
call   1050 <htons@plt>
mov    %eax,0x14(%rbx)
lea    0x16(%rbx),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1080 <memcpy@plt>
movslq %ebp,%rbp
mov    $0x8,%edi
call   1050 <htons@plt>
mov    %eax,0x16(%rbp,%rbx,1)
lea    (%rbx,%rbp,1),%rdi
add    $0x18,%rdi
lea    0xdbf(%rip),%rsi
mov    $0x8,%edx
call   1080 <memcpy@plt>
xor    %edi,%edi
call   1050 <htons@plt>
mov    %eax,0x20(%rbp,%rbx,1)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r12d,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    %r12d,%eax
jge    1288 <cache_expire_url+0x108>
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
lea    0xd8e(%rip),%rsi
mov    %r14,%rdx
call   10a0 <syslog@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HEAD\00"
@.str.1 = [9 x i8] c"HTTP/1.1\00"
@LOG_ERR = global i32 0
@.str.2 = [34 x i8] c"Failed to send HTCP purge for %s\0A\00"
define void @cache_expire_url(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
br label %150
11: ; preds = %2
store i32 0, i32* %6
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = add nsw i32 34, %14
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %11
br label %150
21: ; preds = %11
store i32 0, i32* %6
%22 = load i32, i32* %7
%23 = add nsw i32 34, %22
%24 = call i32 @htons(i32 %23)
%25 = load i8*, i8** %5
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = bitcast i8* %28 to i32*
store i32 %24, i32* %29
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 2
store i32 %31, i32* %6
%32 = load i8*, i8** %5
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
%35 = sext i32 %33 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
store i8 0, i8* %36
%37 = load i8*, i8** %5
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
store i8 0, i8* %41
%42 = load i32, i32* %7
%43 = add nsw i32 30, %42
%44 = call i32 @htons(i32 %43)
%45 = load i8*, i8** %5
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = bitcast i8* %48 to i32*
store i32 %44, i32* %49
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 2
store i32 %51, i32* %6
%52 = load i8*, i8** %5
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds i8, i8* %52, i64 %55
store i8 4, i8* %56
%57 = load i8*, i8** %5
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds i8, i8* %57, i64 %60
store i8 0, i8* %61
%62 = call i32 @htonl(i32 255)
%63 = load i8*, i8** %5
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = bitcast i8* %66 to i32*
store i32 %62, i32* %67
%68 = load i32, i32* %6
%69 = add nsw i32 %68, 4
store i32 %69, i32* %6
%70 = load i8*, i8** %5
%71 = load i32, i32* %6
%72 = add nsw i32 %71, 1
store i32 %72, i32* %6
%73 = sext i32 %71 to i64
%74 = getelementptr inbounds i8, i8* %70, i64 %73
store i8 0, i8* %74
%75 = load i8*, i8** %5
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
%78 = sext i32 %76 to i64
%79 = getelementptr inbounds i8, i8* %75, i64 %78
store i8 0, i8* %79
%80 = call i32 @htons(i32 4)
%81 = load i8*, i8** %5
%82 = load i32, i32* %6
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
%85 = bitcast i8* %84 to i32*
store i32 %80, i32* %85
%86 = load i32, i32* %6
%87 = add nsw i32 %86, 2
store i32 %87, i32* %6
%88 = load i8*, i8** %5
%89 = load i32, i32* %6
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %88, i64 %90
%92 = call i32 @memcpy(i8* %91, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%93 = load i32, i32* %6
%94 = add nsw i32 %93, 4
store i32 %94, i32* %6
%95 = load i32, i32* %7
%96 = call i32 @htons(i32 %95)
%97 = load i8*, i8** %5
%98 = load i32, i32* %6
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8, i8* %97, i64 %99
%101 = bitcast i8* %100 to i32*
store i32 %96, i32* %101
%102 = load i32, i32* %6
%103 = add nsw i32 %102, 2
store i32 %103, i32* %6
%104 = load i8*, i8** %5
%105 = load i32, i32* %6
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8, i8* %104, i64 %106
%108 = load i8*, i8** %4
%109 = load i32, i32* %7
%110 = call i32 @memcpy(i8* %107, i8* %108, i32 %109)
%111 = load i32, i32* %7
%112 = load i32, i32* %6
%113 = add nsw i32 %112, %111
store i32 %113, i32* %6
%114 = call i32 @htons(i32 8)
%115 = load i8*, i8** %5
%116 = load i32, i32* %6
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8, i8* %115, i64 %117
%119 = bitcast i8* %118 to i32*
store i32 %114, i32* %119
%120 = load i32, i32* %6
%121 = add nsw i32 %120, 2
store i32 %121, i32* %6
%122 = load i8*, i8** %5
%123 = load i32, i32* %6
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8, i8* %122, i64 %124
%126 = call i32 @memcpy(i8* %125, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%127 = load i32, i32* %6
%128 = add nsw i32 %127, 8
store i32 %128, i32* %6
%129 = call i32 @htons(i32 0)
%130 = load i8*, i8** %5
%131 = load i32, i32* %6
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i8, i8* %130, i64 %132
%134 = bitcast i8* %133 to i32*
store i32 %129, i32* %134
%135 = load i32, i32* %3
%136 = load i8*, i8** %5
%137 = load i32, i32* %7
%138 = add nsw i32 34, %137
%139 = call i32 @send(i32 %135, i8* %136, i32 %138, i32 0)
%140 = load i32, i32* %7
%141 = add nsw i32 34, %140
%142 = icmp slt i32 %139, %141
br i1 %142, label %143, label %147
143: ; preds = %21
%144 = load i32, i32* @LOG_ERR
%145 = load i8*, i8** %4
%146 = call i32 @syslog(i32 %144, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %145)
br label %147
147: ; preds = %143, %21
%148 = load i8*, i8** %5
%149 = call i32 @free(i8* %148)
br label %150
150: ; preds = %147, %20, %10
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"HEAD\00"
@.str.1 = [9 x i8] c"HTTP/1.1\00"
@LOG_ERR = global i32 0
@.str.2 = [34 x i8] c"Failed to send HTCP purge for %s\0A\00"
define void @cache_expire_url(i32 %0, i8* %1) {
%3 = icmp slt i32 %0, 0
br i1 %3, label %57, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %1)
%6 = add nsw i32 %5, 34
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i64 %7, 0
br i1 %9, label %57, label %10
10: ; preds = %4
%11 = tail call i32 @htons(i32 %6)
%12 = inttoptr i64 %7 to i32*
store i32 %11, i32* %12
%13 = getelementptr inbounds i8, i8* %8, i64 2
store i8 0, i8* %13
%14 = getelementptr inbounds i8, i8* %8, i64 3
store i8 0, i8* %14
%15 = add nsw i32 %5, 30
%16 = tail call i32 @htons(i32 %15)
%17 = getelementptr inbounds i8, i8* %8, i64 4
%18 = bitcast i8* %17 to i32*
store i32 %16, i32* %18
%19 = getelementptr inbounds i8, i8* %8, i64 6
store i8 4, i8* %19
%20 = getelementptr inbounds i8, i8* %8, i64 7
store i8 0, i8* %20
%21 = tail call i32 @htonl(i32 255)
%22 = getelementptr inbounds i8, i8* %8, i64 8
%23 = bitcast i8* %22 to i32*
store i32 %21, i32* %23
%24 = getelementptr inbounds i8, i8* %8, i64 12
store i8 0, i8* %24
%25 = getelementptr inbounds i8, i8* %8, i64 13
store i8 0, i8* %25
%26 = tail call i32 @htons(i32 4)
%27 = getelementptr inbounds i8, i8* %8, i64 14
%28 = bitcast i8* %27 to i32*
store i32 %26, i32* %28
%29 = getelementptr inbounds i8, i8* %8, i64 16
%30 = tail call i32 @memcpy(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%31 = tail call i32 @htons(i32 %5)
%32 = getelementptr inbounds i8, i8* %8, i64 20
%33 = bitcast i8* %32 to i32*
store i32 %31, i32* %33
%34 = getelementptr inbounds i8, i8* %8, i64 22
%35 = tail call i32 @memcpy(i8* %34, i8* %1, i32 %5)
%36 = add nsw i32 %5, 22
%37 = tail call i32 @htons(i32 8)
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds i8, i8* %8, i64 %38
%40 = bitcast i8* %39 to i32*
store i32 %37, i32* %40
%41 = add nsw i32 %5, 24
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %8, i64 %42
%44 = tail call i32 @memcpy(i8* %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%45 = add nsw i32 %5, 32
%46 = tail call i32 @htons(i32 0)
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds i8, i8* %8, i64 %47
%49 = bitcast i8* %48 to i32*
store i32 %46, i32* %49
%50 = tail call i32 @send(i32 %0, i8* %8, i32 %6, i32 0)
%51 = icmp slt i32 %50, %6
br i1 %51, label %52, label %55
52: ; preds = %10
%53 = load i32, i32* @LOG_ERR
%54 = tail call i32 @syslog(i32 %53, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %55
55: ; preds = %52, %10
%56 = tail call i32 @free(i8* %8)
br label %57
57: ; preds = %55, %4, %2
ret void
}