#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;

/* Variables and functions */
char *ctime(int *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int time(int /*<<< orphan*/ *);
void MakeCookieHeadEx(char *szHead, char *szName, char *szValue, char *szPath,
                      char *szDomain, int bSecure, int nAfterHour) {
  time_t curtime;
  strcpy(szHead, "Set-Cookie: ");
  strcat(szHead, szName);
  strcat(szHead, "=");
  strcat(szHead, szValue);
  strcat(szHead, ";");
  curtime = time(NULL);
  curtime += (nAfterHour * 3600);
  strcat(szHead, " expires=");
  strcat(szHead, ctime(&curtime));
  szHead[strlen(szHead) - 1] = '\0';
  strcat(szHead, ";");
  if (szPath && *szPath) {
    strcat(szHead, " path=");
    strcat(szHead, szPath);
    strcat(szHead, ";");
  }
  if (szDomain && *szDomain) {
    strcat(szHead, " domain=");
    strcat(szHead, szDomain);
    strcat(szHead, ";");
  }
  if (bSecure) {
    strcat(szHead, " secure");
  }
}


x86 assembly (clang, -O0):
<MakeCookieHeadEx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1070 <strcat@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x30(%rbp)
imul   $0xe10,0x10(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <ctime@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1070 <strcat@plt>
cmpq   $0x0,-0x20(%rbp)
je     127c <MakeCookieHeadEx+0x12c>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     127c <MakeCookieHeadEx+0x12c>
mov    -0x8(%rbp),%rdi
lea    0xdbf(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xd96(%rip),%rsi
call   1070 <strcat@plt>
cmpq   $0x0,-0x28(%rbp)
je     12c4 <MakeCookieHeadEx+0x174>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12c4 <MakeCookieHeadEx+0x174>
mov    -0x8(%rbp),%rdi
lea    0xd7e(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xd4e(%rip),%rsi
call   1070 <strcat@plt>
cmpl   $0x0,-0x2c(%rbp)
je     12de <MakeCookieHeadEx+0x18e>
mov    -0x8(%rbp),%rdi
lea    0xd50(%rip),%rsi
call   1070 <strcat@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MakeCookieHeadEx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8,%r15
mov    %rcx,%r13
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xe8c(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
lea    0xe93(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
lea    0xe68(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
xor    %edi,%edi
call   1060 <time@plt>
imul   $0xe10,0x40(%rsp),%ecx
add    %eax,%ecx
mov    %ecx,0x4(%rsp)
lea    0xe43(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0x4(%rsp),%rdi
call   1040 <ctime@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
test   %r13,%r13
je     1238 <MakeCookieHeadEx+0xe8>
cmpb   $0x0,0x0(%r13)
je     1238 <MakeCookieHeadEx+0xe8>
lea    0xe03(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <strcat@plt>
lea    0xddd(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
test   %r15,%r15
je     126c <MakeCookieHeadEx+0x11c>
cmpb   $0x0,(%r15)
je     126c <MakeCookieHeadEx+0x11c>
lea    0xdd6(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
lea    0xda9(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
test   %r14d,%r14d
je     1280 <MakeCookieHeadEx+0x130>
lea    0xdb1(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Set-Cookie: \00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [2 x i8] c";\00"
@.str.3 = [10 x i8] c" expires=\00"
@.str.4 = [7 x i8] c" path=\00"
@.str.5 = [9 x i8] c" domain=\00"
@.str.6 = [8 x i8] c" secure\00"
define void @MakeCookieHeadEx(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%16 = load i8*, i8** %8
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%18 = load i8*, i8** %8
%19 = load i8*, i8** %9
%20 = call i32 @strcat(i8* %18, i8* %19)
%21 = load i8*, i8** %8
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = load i8*, i8** %8
%24 = load i8*, i8** %10
%25 = call i32 @strcat(i8* %23, i8* %24)
%26 = load i8*, i8** %8
%27 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @time(i32* null)
store i32 %28, i32* %15
%29 = load i32, i32* %14
%30 = mul nsw i32 %29, 3600
%31 = load i32, i32* %15
%32 = add nsw i32 %31, %30
store i32 %32, i32* %15
%33 = load i8*, i8** %8
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%35 = load i8*, i8** %8
%36 = call i8* @ctime(i32* %15)
%37 = call i32 @strcat(i8* %35, i8* %36)
%38 = load i8*, i8** %8
%39 = load i8*, i8** %8
%40 = call i32 @strlen(i8* %39)
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %38, i64 %42
store i8 0, i8* %43
%44 = load i8*, i8** %8
%45 = call i32 @strcat(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%46 = load i8*, i8** %11
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %61
48: ; preds = %7
%49 = load i8*, i8** %11
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %61
53: ; preds = %48
%54 = load i8*, i8** %8
%55 = call i32 @strcat(i8* %54, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%56 = load i8*, i8** %8
%57 = load i8*, i8** %11
%58 = call i32 @strcat(i8* %56, i8* %57)
%59 = load i8*, i8** %8
%60 = call i32 @strcat(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %61
61: ; preds = %53, %48, %7
%62 = load i8*, i8** %12
%63 = icmp ne i8* %62, null
br i1 %63, label %64, label %77
64: ; preds = %61
%65 = load i8*, i8** %12
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %77
69: ; preds = %64
%70 = load i8*, i8** %8
%71 = call i32 @strcat(i8* %70, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%72 = load i8*, i8** %8
%73 = load i8*, i8** %12
%74 = call i32 @strcat(i8* %72, i8* %73)
%75 = load i8*, i8** %8
%76 = call i32 @strcat(i8* %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %77
77: ; preds = %69, %64, %61
%78 = load i32, i32* %13
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %77
%81 = load i8*, i8** %8
%82 = call i32 @strcat(i8* %81, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %83
83: ; preds = %80, %77
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"Set-Cookie: \00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [2 x i8] c";\00"
@.str.3 = [10 x i8] c" expires=\00"
@.str.4 = [7 x i8] c" path=\00"
@.str.5 = [9 x i8] c" domain=\00"
@.str.6 = [8 x i8] c" secure\00"
define void @MakeCookieHeadEx(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i32 %5, i32 %6) {
%8 = alloca i32
%9 = bitcast i32* %8 to i8*
%10 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @strcat(i8* %0, i8* %1)
%12 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @strcat(i8* %0, i8* %2)
%14 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @time(i32* null)
%16 = mul nsw i32 %6, 3600
%17 = add nsw i32 %15, %16
store i32 %17, i32* %8
%18 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%19 = call i8* @ctime(i32* %8)
%20 = call i32 @strcat(i8* %0, i8* %19)
%21 = call i32 @strlen(i8* %0)
%22 = add nsw i32 %21, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
store i8 0, i8* %24
%25 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i8* %3, null
br i1 %26, label %34, label %27
27: ; preds = %7
%28 = load i8, i8* %3
%29 = icmp eq i8 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%32 = call i32 @strcat(i8* %0, i8* %3)
%33 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %30, %27, %7
%35 = icmp eq i8* %4, null
br i1 %35, label %43, label %36
36: ; preds = %34
%37 = load i8, i8* %4
%38 = icmp eq i8 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %36
%40 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%41 = call i32 @strcat(i8* %0, i8* %4)
%42 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %39, %36, %34
%44 = icmp eq i32 %5, 0
br i1 %44, label %47, label %45
45: ; preds = %43
%46 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %47
47: ; preds = %45, %43
ret void
}