#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 */
struct mg_connection {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ mg_write(struct mg_connection *, char const *,
                            int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char const *);
void write_ajax_header(struct mg_connection *conn, int flags) {
  if (flags & 0x02) {
    static const char *header =
        "HTTP/1.1 200 OK\r\n"
        "Expires: Thu, 01-Jan-1970 00:00:01 GMT\r\n"
        "Cache: no-cache\r\n"
        "max-age: 0\r\n"
        "s-maxage: 0\r\n"
        "Cache-Control: no-cache, no-store, must-revalidate\r\n"
        "Content-Length: 0\r\n"
        "Content-Type: application/x-javascript\r\n"
        "\r\n";
    mg_write(conn, header, strlen(header));
  } else {
    static const char *header =
        "HTTP/1.1 200 OK\r\n"
        "Expires: Thu, 01-Jan-1970 00:00:01 GMT\r\n"
        "Cache: no-cache\r\n"
        "max-age: 0\r\n"
        "s-maxage: 0\r\n"
        "Cache-Control: no-cache, no-store, must-revalidate\r\n"
        "Content-Type: application/x-javascript\r\n"
        "\r\n";
    mg_write(conn, header, strlen(header));
  }
}


x86 assembly (clang, -O0):
<write_ajax_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1171 <write_ajax_header+0x51>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2ee3(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2ed8(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1040 <mg_write@plt>
jmp    119f <write_ajax_header+0x7f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2eb8(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2ead(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1040 <mg_write@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_ajax_header>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   $0x2,%sil
lea    0xfa3(%rip),%rax
lea    0xec7(%rip),%rbx
cmove  %rax,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <mg_write@plt>

LLVM IR (-O0):
%struct.mg_connection = type { i32 }
@write_ajax_header.header = internal global i8* getelementptr inbounds ([213 x i8], [213 x i8]* @.str, i32 0, i32 0)
@.str = [213 x i8] c"HTTP/1.1 200 OK\0D\0AExpires: Thu, 01-Jan-1970 00:00:01 GMT\0D\0ACache: no-cache\0D\0Amax-age: 0\0D\0As-maxage: 0\0D\0ACache-Control: no-cache, no-store, must-revalidate\0D\0AContent-Length: 0\0D\0AContent-Type: application/x-javascript\0D\0A\0D\0A\00"
@write_ajax_header.header.1 = internal global i8* getelementptr inbounds ([194 x i8], [194 x i8]* @.str.2, i32 0, i32 0)
@.str.2 = [194 x i8] c"HTTP/1.1 200 OK\0D\0AExpires: Thu, 01-Jan-1970 00:00:01 GMT\0D\0ACache: no-cache\0D\0Amax-age: 0\0D\0As-maxage: 0\0D\0ACache-Control: no-cache, no-store, must-revalidate\0D\0AContent-Type: application/x-javascript\0D\0A\0D\0A\00"
define void @write_ajax_header(%struct.mg_connection* %0, i32 %1) {
%3 = alloca %struct.mg_connection*
%4 = alloca i32
store %struct.mg_connection* %0, %struct.mg_connection** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = and i32 %5, 2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load %struct.mg_connection*, %struct.mg_connection** %3
%10 = load i8*, i8** @write_ajax_header.header
%11 = load i8*, i8** @write_ajax_header.header
%12 = call i32 @strlen(i8* %11)
%13 = call i32 @mg_write(%struct.mg_connection* %9, i8* %10, i32 %12)
br label %20
14: ; preds = %2
%15 = load %struct.mg_connection*, %struct.mg_connection** %3
%16 = load i8*, i8** @write_ajax_header.header.1
%17 = load i8*, i8** @write_ajax_header.header.1
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @mg_write(%struct.mg_connection* %15, i8* %16, i32 %18)
br label %20
20: ; preds = %14, %8
ret void
}

LLVM IR (-O2):
%struct.mg_connection = type { i32 }
@.str = [213 x i8] c"HTTP/1.1 200 OK\0D\0AExpires: Thu, 01-Jan-1970 00:00:01 GMT\0D\0ACache: no-cache\0D\0Amax-age: 0\0D\0As-maxage: 0\0D\0ACache-Control: no-cache, no-store, must-revalidate\0D\0AContent-Length: 0\0D\0AContent-Type: application/x-javascript\0D\0A\0D\0A\00"
@.str.2 = [194 x i8] c"HTTP/1.1 200 OK\0D\0AExpires: Thu, 01-Jan-1970 00:00:01 GMT\0D\0ACache: no-cache\0D\0Amax-age: 0\0D\0As-maxage: 0\0D\0ACache-Control: no-cache, no-store, must-revalidate\0D\0AContent-Type: application/x-javascript\0D\0A\0D\0A\00"
define void @write_ajax_header(%struct.mg_connection* %0, i32 %1) {
%3 = and i32 %1, 2
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i8* getelementptr inbounds ([194 x i8], [194 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([213 x i8], [213 x i8]* @.str, i64 0, i64 0)
%6 = tail call i32 @strlen(i8* %5)
%7 = tail call i32 @mg_write(%struct.mg_connection* %0, i8* %5, i32 %6)
ret void
}