#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 EXIT_SUCCESS;
int atoi(char *);
char *cgi_cookie_get(char *);
scalar_t__ cgi_cookie_isset(char *);
int /*<<< orphan*/ cgi_cookie_set(char *, char *);
int /*<<< orphan*/ cgi_exit();
scalar_t__ cgi_get_isset(char *);
char *cgi_get_value(char *);
int /*<<< orphan*/ cgi_init();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char *cookie_filename;
  char buf[255];
  int cpt;
  printf("Content-type: text/html\n");
  cgi_init();
  printf("<html><head><title>Cookies</title></head><body>\n");
  printf("<h1>Cookie</h1>\n");
  if (cgi_cookie_isset("cpt")) {
    cpt = atoi(cgi_cookie_get("cpt"));
    cpt++;
  } else {
    cpt = 1;
  }
  if (cgi_get_isset("message")) {
    strcpy(buf, cgi_get_value("message"));
    cgi_cookie_set("message", buf);
  } else {
    if (cgi_cookie_isset("message")) {
      strcpy(buf, cgi_cookie_get("message"));
    } else {
      strcpy(buf, "aucun message");
    }
  }
  printf("<p>Ceci est votre %i eme visite.</p>\n", cpt);
  printf("<p>Message : %s</p>\n", buf);
  if (!cgi_cookie_isset("data")) {
    cgi_cookie_set("data", "Ceci est une ligne avec un\n backslash n");
  }
  printf("<p>%s</p>", cgi_cookie_get("data"));
  printf("</body></html>\n");
  sprintf(buf, "%i", cpt);
  cgi_cookie_set("cpt", buf);
  cgi_exit();
  fflush(stdout);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <cgi_init@plt>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe51(%rip),%rdi
call   1070 <cgi_cookie_isset@plt>
cmp    $0x0,%rax
je     1247 <main+0x87>
lea    0xe3b(%rip),%rdi
call   1080 <cgi_cookie_get@plt>
mov    %rax,%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x114(%rbp)
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1251 <main+0x91>
movl   $0x1,-0x114(%rbp)
lea    0xe0d(%rip),%rdi
call   10d0 <cgi_get_isset@plt>
cmp    $0x0,%rax
je     12a8 <main+0xe8>
lea    -0x110(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    0xde9(%rip),%rdi
call   1060 <cgi_get_value@plt>
mov    -0x120(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rsi
lea    0xdc7(%rip),%rdi
call   1050 <cgi_cookie_set@plt>
jmp    1304 <main+0x144>
lea    0xdb6(%rip),%rdi
call   1070 <cgi_cookie_isset@plt>
cmp    $0x0,%rax
je     12ec <main+0x12c>
lea    -0x110(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    0xd92(%rip),%rdi
call   1080 <cgi_cookie_get@plt>
mov    -0x128(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
jmp    12ff <main+0x13f>
lea    -0x110(%rbp),%rdi
lea    0xd65(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1304 <main+0x144>
mov    -0x114(%rbp),%esi
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd74(%rip),%rdi
call   1070 <cgi_cookie_isset@plt>
cmp    $0x0,%rax
jne    1356 <main+0x196>
lea    0xd5e(%rip),%rdi
lea    0xd5c(%rip),%rsi
call   1050 <cgi_cookie_set@plt>
lea    0xd4b(%rip),%rdi
call   1080 <cgi_cookie_get@plt>
mov    %rax,%rsi
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x114(%rbp),%edx
lea    0xd5a(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0x110(%rbp),%rsi
lea    0xcb3(%rip),%rdi
call   1050 <cgi_cookie_set@plt>
mov    $0x0,%al
call   10e0 <cgi_exit@plt>
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
mov    0x2c0f(%rip),%rax
mov    (%rax),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10b0 <cgi_init@plt>
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
lea    0xece(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf3(%rip),%rdi
call   1080 <cgi_cookie_isset@plt>
test   %rax,%rax
je     1232 <main+0x62>
lea    0xde2(%rip),%rdi
call   1090 <cgi_cookie_get@plt>
mov    %rax,%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebp
add    $0x1,%ebp
jmp    1237 <main+0x67>
mov    $0x1,%ebp
lea    0xdcc(%rip),%rdi
call   10e0 <cgi_get_isset@plt>
test   %rax,%rax
je     1272 <main+0xa2>
lea    0xdbb(%rip),%r14
mov    %r14,%rdi
call   1070 <cgi_get_value@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <cgi_cookie_set@plt>
jmp    12a6 <main+0xd6>
lea    0xd91(%rip),%rdi
call   1080 <cgi_cookie_isset@plt>
test   %rax,%rax
je     1297 <main+0xc7>
lea    0xd80(%rip),%rdi
call   1090 <cgi_cookie_get@plt>
mov    %rsp,%rdi
mov    %rax,%rsi
jmp    12a1 <main+0xd1>
lea    0xd66(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
lea    0xd65(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd7b(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd7f(%rip),%rdi
call   1080 <cgi_cookie_isset@plt>
test   %rax,%rax
jne    12eb <main+0x11b>
lea    0xd6e(%rip),%rdi
lea    0xd6c(%rip),%rsi
call   1060 <cgi_cookie_set@plt>
lea    0xd5b(%rip),%rdi
call   1090 <cgi_cookie_get@plt>
lea    0xd7c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdd0(%rip),%rdi
call   1040 <puts@plt>
lea    0xd69(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
call   10d0 <sprintf@plt>
lea    0xcd1(%rip),%rdi
mov    %rbx,%rsi
call   1060 <cgi_cookie_set@plt>
xor    %eax,%eax
call   10f0 <cgi_exit@plt>
mov    0x2c9b(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    0x2c85(%rip),%rax
mov    (%rax),%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Content-type: text/html\0A\00"
@.str.1 = [49 x i8] c"<html><head><title>Cookies</title></head><body>\0A\00"
@.str.2 = [17 x i8] c"<h1>Cookie</h1>\0A\00"
@.str.3 = [4 x i8] c"cpt\00"
@.str.4 = [8 x i8] c"message\00"
@.str.5 = [14 x i8] c"aucun message\00"
@.str.6 = [38 x i8] c"<p>Ceci est votre %i eme visite.</p>\0A\00"
@.str.7 = [21 x i8] c"<p>Message : %s</p>\0A\00"
@.str.8 = [5 x i8] c"data\00"
@.str.9 = [40 x i8] c"Ceci est une ligne avec un\0A backslash n\00"
@.str.10 = [10 x i8] c"<p>%s</p>\00"
@.str.11 = [16 x i8] c"</body></html>\0A\00"
@.str.12 = [3 x i8] c"%i\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [255 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @cgi_init()
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%9 = call i64 @cgi_cookie_isset(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = call i8* @cgi_cookie_get(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
br label %17
16: ; preds = %0
store i32 1, i32* %4
br label %17
17: ; preds = %16, %11
%18 = call i64 @cgi_get_isset(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%22 = call i8* @cgi_get_value(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @strcpy(i8* %21, i8* %22)
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%25 = call i32 @cgi_cookie_set(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %24)
br label %37
26: ; preds = %17
%27 = call i64 @cgi_cookie_isset(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%31 = call i8* @cgi_cookie_get(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%32 = call i32 @strcpy(i8* %30, i8* %31)
br label %36
33: ; preds = %26
%34 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%35 = call i32 @strcpy(i8* %34, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %33, %29
br label %37
37: ; preds = %36, %20
%38 = load i32, i32* %4
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %40)
%42 = call i64 @cgi_cookie_isset(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%43 = icmp ne i64 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %37
%45 = call i32 @cgi_cookie_set(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0))
br label %46
46: ; preds = %44, %37
%47 = call i8* @cgi_cookie_get(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
%50 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%51 = load i32, i32* %4
%52 = call i32 @sprintf(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32 %51)
%53 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%54 = call i32 @cgi_cookie_set(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %53)
%55 = call i32 (...) @cgi_exit()
%56 = load i32, i32* @stdout
%57 = call i32 @fflush(i32 %56)
%58 = load i32, i32* @EXIT_SUCCESS
ret i32 %58
}

LLVM IR (-O2):
@.str.3 = [4 x i8] c"cpt\00"
@.str.4 = [8 x i8] c"message\00"
@.str.5 = [14 x i8] c"aucun message\00"
@.str.6 = [38 x i8] c"<p>Ceci est votre %i eme visite.</p>\0A\00"
@.str.7 = [21 x i8] c"<p>Message : %s</p>\0A\00"
@.str.8 = [5 x i8] c"data\00"
@.str.9 = [40 x i8] c"Ceci est une ligne avec un\0A backslash n\00"
@.str.10 = [10 x i8] c"<p>%s</p>\00"
@.str.12 = [3 x i8] c"%i\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [24 x i8] c"Content-type: text/html\00"
@str.13 = [48 x i8] c"<html><head><title>Cookies</title></head><body>\00"
@str.14 = [16 x i8] c"<h1>Cookie</h1>\00"
@str.15 = [15 x i8] c"</body></html>\00"
define i32 @main() {
%1 = alloca [255 x i8]
%2 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @cgi_init()
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.13, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.14, i64 0, i64 0))
%7 = tail call i64 @cgi_cookie_isset(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %0
%10 = tail call i8* @cgi_cookie_get(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @atoi(i8* %10)
%12 = add nsw i32 %11, 1
br label %13
13: ; preds = %0, %9
%14 = phi i32 [ %12, %9 ], [ 1, %0 ]
%15 = tail call i64 @cgi_get_isset(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = tail call i8* @cgi_get_value(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @strcpy(i8* %2, i8* %18)
%20 = call i32 @cgi_cookie_set(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %2)
br label %29
21: ; preds = %13
%22 = tail call i64 @cgi_cookie_isset(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = tail call i8* @cgi_cookie_get(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 @strcpy(i8* %2, i8* %25)
br label %29
27: ; preds = %21
%28 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %29
29: ; preds = %24, %27, %17
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 %14)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%32 = call i64 @cgi_cookie_isset(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = call i32 @cgi_cookie_set(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0))
br label %36
36: ; preds = %34, %29
%37 = call i8* @cgi_cookie_get(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %37)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.15, i64 0, i64 0))
%40 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32 %14)
%41 = call i32 @cgi_cookie_set(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%42 = call i32 (...) @cgi_exit()
%43 = load i32, i32* @stdout
%44 = call i32 @fflush(i32 %43)
%45 = load i32, i32* @EXIT_SUCCESS
ret i32 %45
}