#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 time_t;
typedef int /*<<< orphan*/ bufHora;

/* Variables and functions */
int /*<<< orphan*/ gmtime(int *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int strlen(char *);
int time(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, char *, int);
void httpHeader(int client_socket, char *mimeType, int tamanho, time_t ultAtu,
                int request_check, char *check_type) {
  time_t agora;
  char bufHora[128];
  char buffer[100];
  sprintf(buffer, "%s %d %s\r\n", "HTTP/1.1", request_check, check_type);
  write(client_socket, buffer, strlen(buffer));
  sprintf(buffer, "Server: %s\r\n", "Fernando & Audemar WebServer");
  write(client_socket, buffer, strlen(buffer));
  agora = time(NULL);
  strftime(bufHora, sizeof(bufHora), "%a, %d %b %Y %H:%M:%S GMT",
           gmtime(&agora));
  sprintf(buffer, "Date: %s\r\n", bufHora);
  write(client_socket, buffer, strlen(buffer));
  sprintf(buffer, "Content-Type: %s\r\n", mimeType);
  write(client_socket, buffer, strlen(buffer));
  if (tamanho >= 0) {
    sprintf(buffer, "Content-Length: %d\r\n", tamanho);
    write(client_socket, buffer, strlen(buffer));
  }
  if (ultAtu != -1) {
    strftime(bufHora, sizeof(bufHora), "%a, %d %b %Y %H:%M:%S GMT",
             gmtime(&ultAtu));
    sprintf(buffer, "Last-Modified: %s\r\n", bufHora);
    write(client_socket, buffer, strlen(buffer));
  }
  write(client_socket, "\r\n", 2);
}


x86 assembly (clang, -O0):
<httpHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
lea    0xe6b(%rip),%rsi
lea    0xe6f(%rip),%rdx
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x164(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x160(%rbp)
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x164(%rbp),%edi
mov    -0x160(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    -0x120(%rbp),%rdi
lea    0xe2c(%rip),%rsi
lea    0xe32(%rip),%rdx
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x154(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x150(%rbp)
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x154(%rbp),%edi
mov    -0x150(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x2c(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0x148(%rbp)
lea    -0x2c(%rbp),%rdi
call   1070 <gmtime@plt>
mov    -0x148(%rbp),%rdi
mov    %eax,%ecx
mov    $0x80,%esi
lea    0xdd9(%rip),%rdx
call   1060 <strftime@plt>
lea    -0x120(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x13c(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x138(%rbp)
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x13c(%rbp),%edi
mov    -0x138(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x12c(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x12c(%rbp),%edi
mov    -0x128(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmpl   $0x0,-0x14(%rbp)
jl     1366 <httpHeader+0x206>
lea    -0x120(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xd4e(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x174(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x170(%rbp)
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x174(%rbp),%edi
mov    -0x170(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmpl   $0xffffffff,-0x18(%rbp)
je     13f4 <httpHeader+0x294>
lea    -0xb0(%rbp),%rax
mov    %rax,-0x190(%rbp)
lea    -0x18(%rbp),%rdi
call   1070 <gmtime@plt>
mov    -0x190(%rbp),%rdi
mov    %eax,%ecx
mov    $0x80,%esi
lea    0xca2(%rip),%rdx
call   1060 <strftime@plt>
lea    -0x120(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    0xcd5(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x184(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x180(%rbp)
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x184(%rbp),%edi
mov    -0x180(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
lea    0xc8a(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<httpHeader>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %rsi,%r12
mov    %edi,%r13d
mov    %ecx,0xc(%rsp)
lea    0xe78(%rip),%rsi
lea    0xe7c(%rip),%rdx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r8d,%ecx
mov    %r9,%r8
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe54(%rip),%rsi
lea    0xe5a(%rip),%rdx
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1070 <gmtime@plt>
lea    0xe3c(%rip),%rdx
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %eax,%ecx
call   1060 <strftime@plt>
lea    0xe38(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe1a(%rip),%rsi
mov    %rbp,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %r14d,%r14d
js     129e <httpHeader+0x13e>
lea    0xdff(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%r15d
je     12fa <httpHeader+0x19a>
lea    0xc(%rsp),%rdi
call   1070 <gmtime@plt>
lea    0xd89(%rip),%rdx
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %eax,%ecx
call   1060 <strftime@plt>
lea    0xdb8(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xd87(%rip),%rsi
mov    %r13d,%edi
mov    $0x2,%edx
call   1030 <write@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s %d %s\0D\0A\00"
@.str.1 = [9 x i8] c"HTTP/1.1\00"
@.str.2 = [13 x i8] c"Server: %s\0D\0A\00"
@.str.3 = [29 x i8] c"Fernando & Audemar WebServer\00"
@.str.4 = [26 x i8] c"%a, %d %b %Y %H:%M:%S GMT\00"
@.str.5 = [11 x i8] c"Date: %s\0D\0A\00"
@.str.6 = [19 x i8] c"Content-Type: %s\0D\0A\00"
@.str.7 = [21 x i8] c"Content-Length: %d\0D\0A\00"
@.str.8 = [20 x i8] c"Last-Modified: %s\0D\0A\00"
@.str.9 = [3 x i8] c"\0D\0A\00"
define void @httpHeader(i32 %0, i8* %1, i32 %2, i32 %3, i32 %4, i8* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca [128 x i8]
%15 = alloca [100 x i8]
store i32 %0, i32* %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i8* %5, i8** %12
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%17 = load i32, i32* %11
%18 = load i8*, i8** %12
%19 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17, i8* %18)
%20 = load i32, i32* %7
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = call i32 @write(i32 %20, i8* %21, i32 %23)
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32, i32* %7
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = call i32 @write(i32 %27, i8* %28, i32 %30)
%32 = call i32 @time(i32* null)
store i32 %32, i32* %13
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%34 = call i32 @gmtime(i32* %13)
%35 = call i32 @strftime(i8* %33, i32 128, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%37 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%38 = call i32 (i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %37)
%39 = load i32, i32* %7
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
%43 = call i32 @write(i32 %39, i8* %40, i32 %42)
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%45 = load i8*, i8** %8
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %45)
%47 = load i32, i32* %7
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%50 = call i32 @strlen(i8* %49)
%51 = call i32 @write(i32 %47, i8* %48, i32 %50)
%52 = load i32, i32* %9
%53 = icmp sge i32 %52, 0
br i1 %53, label %54, label %63
54: ; preds = %6
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%56 = load i32, i32* %9
%57 = call i32 (i8*, i8*, ...) @sprintf(i8* %55, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %7
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%61 = call i32 @strlen(i8* %60)
%62 = call i32 @write(i32 %58, i8* %59, i32 %61)
br label %63
63: ; preds = %54, %6
%64 = load i32, i32* %10
%65 = icmp ne i32 %64, -1
br i1 %65, label %66, label %78
66: ; preds = %63
%67 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%68 = call i32 @gmtime(i32* %10)
%69 = call i32 @strftime(i8* %67, i32 128, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %68)
%70 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%71 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%72 = call i32 (i8*, i8*, ...) @sprintf(i8* %70, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %71)
%73 = load i32, i32* %7
%74 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%75 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%76 = call i32 @strlen(i8* %75)
%77 = call i32 @write(i32 %73, i8* %74, i32 %76)
br label %78
78: ; preds = %66, %63
%79 = load i32, i32* %7
%80 = call i32 @write(i32 %79, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s %d %s\0D\0A\00"
@.str.1 = [9 x i8] c"HTTP/1.1\00"
@.str.2 = [13 x i8] c"Server: %s\0D\0A\00"
@.str.3 = [29 x i8] c"Fernando & Audemar WebServer\00"
@.str.4 = [26 x i8] c"%a, %d %b %Y %H:%M:%S GMT\00"
@.str.5 = [11 x i8] c"Date: %s\0D\0A\00"
@.str.6 = [19 x i8] c"Content-Type: %s\0D\0A\00"
@.str.7 = [21 x i8] c"Content-Length: %d\0D\0A\00"
@.str.8 = [20 x i8] c"Last-Modified: %s\0D\0A\00"
@.str.9 = [3 x i8] c"\0D\0A\00"
define void @httpHeader(i32 %0, i8* %1, i32 %2, i32 %3, i32 %4, i8* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca [128 x i8]
%10 = alloca [100 x i8]
store i32 %3, i32* %7
%11 = bitcast i32* %8 to i8*
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %4, i8* %5)
%15 = call i32 @strlen(i8* %13)
%16 = call i32 @write(i32 %0, i8* %13, i32 %15)
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @strlen(i8* %13)
%19 = call i32 @write(i32 %0, i8* %13, i32 %18)
%20 = call i32 @time(i32* null)
store i32 %20, i32* %8
%21 = call i32 @gmtime(i32* %8)
%22 = call i32 @strftime(i8* %12, i32 128, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%24 = call i32 @strlen(i8* %13)
%25 = call i32 @write(i32 %0, i8* %13, i32 %24)
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %1)
%27 = call i32 @strlen(i8* %13)
%28 = call i32 @write(i32 %0, i8* %13, i32 %27)
%29 = icmp sgt i32 %2, -1
br i1 %29, label %30, label %34
30: ; preds = %6
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %2)
%32 = call i32 @strlen(i8* %13)
%33 = call i32 @write(i32 %0, i8* %13, i32 %32)
br label %34
34: ; preds = %30, %6
%35 = icmp eq i32 %3, -1
br i1 %35, label %42, label %36
36: ; preds = %34
%37 = call i32 @gmtime(i32* %7)
%38 = call i32 @strftime(i8* %12, i32 128, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %12)
%40 = call i32 @strlen(i8* %13)
%41 = call i32 @write(i32 %0, i8* %13, i32 %40)
br label %42
42: ; preds = %36, %34
%43 = call i32 @write(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2)
ret void
}