#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 atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ stdout;
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int main(void) {
  char *buf, *p;
  char arg1[8192], arg2[8192], content[8192];
  int n1 = 0, n2 = 0;
  if ((buf = getenv("QUERY_STRING")) != NULL) {
    p = strchr(buf, '&');
    *p = '\0';
    strcpy(arg1, buf);
    strcpy(arg2, p + 1);
    n1 = atoi(arg1);
    n2 = atoi(arg2);
  }
  sprintf(content, "Welcome to add.com: ");
  sprintf(content, "%sTHE Internet addition portal.\r\n<p>", content);
  sprintf(content, "%sThe answer is: %d + %d = %d\r\n<p>", content, n1, n2,
          n1 + n2);
  sprintf(content, "%sThanks for visiting!\r\n", content);
  printf("Connection: close\r\n");
  printf("Content-length: %d\r\n", (int)strlen(content));
  printf("Content-type: text/html\r\n\r\n");
  printf("%s", content);
  fflush(stdout);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6030,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x6024(%rbp)
movl   $0x0,-0x6028(%rbp)
lea    0xe43(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1231 <main+0xa1>
mov    -0x10(%rbp),%rdi
mov    $0x26,%esi
call   1060 <strchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x2020(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x4020(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
call   1040 <strcpy@plt>
lea    -0x2020(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x6024(%rbp)
lea    -0x4020(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x6028(%rbp)
lea    -0x6020(%rbp),%rdi
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x6020(%rbp),%rdi
lea    -0x6020(%rbp),%rdx
lea    0xdc7(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x6020(%rbp),%rdi
lea    -0x6020(%rbp),%rdx
mov    -0x6024(%rbp),%ecx
mov    -0x6028(%rbp),%r8d
mov    -0x6024(%rbp),%r9d
add    -0x6028(%rbp),%r9d
lea    0xdb5(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x6020(%rbp),%rdi
lea    -0x6020(%rbp),%rdx
lea    0xdbc(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x6020(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%esi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x6020(%rbp),%rsi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2cd7(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x6008,%rsp
lea    0xe4b(%rip),%rdi
call   1030 <getenv@plt>
xor    %r14d,%r14d
mov    $0x0,%r12d
test   %rax,%rax
je     121e <main+0x7e>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x26,%esi
call   1070 <strchr@plt>
mov    %rax,%r14
movb   $0x0,(%rax)
lea    0x4000(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
add    $0x1,%r14
lea    0x2000(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   10a0 <atoi@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %eax,%r12d
movups 0xde8(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x203a6d6f632e64,%rax
mov    %rax,0xd(%rsp)
lea    0xde3(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   10b0 <sprintf@plt>
lea    (%r12,%r14,1),%r9d
lea    0xded(%rip),%rsi
mov    %r15,%rdi
mov    %r15,%rdx
mov    %r14d,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
call   10b0 <sprintf@plt>
lea    0xdf6(%rip),%rsi
mov    %r15,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   10b0 <sprintf@plt>
lea    0xe13(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
lea    0xde7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe02(%rip),%rdi
call   1050 <puts@plt>
lea    0xde0(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"QUERY_STRING\00"
@.str.1 = [21 x i8] c"Welcome to add.com: \00"
@.str.2 = [37 x i8] c"%sTHE Internet addition portal.\0D\0A<p>\00"
@.str.3 = [35 x i8] c"%sThe answer is: %d + %d = %d\0D\0A<p>\00"
@.str.4 = [25 x i8] c"%sThanks for visiting!\0D\0A\00"
@.str.5 = [20 x i8] c"Connection: close\0D\0A\00"
@.str.6 = [21 x i8] c"Content-length: %d\0D\0A\00"
@.str.7 = [28 x i8] c"Content-type: text/html\0D\0A\0D\0A\00"
@.str.8 = [3 x i8] c"%s\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [8192 x i8]
%5 = alloca [8192 x i8]
%6 = alloca [8192 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %7
store i32 0, i32* %8
%9 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %2
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %26
11: ; preds = %0
%12 = load i8*, i8** %2
%13 = call i8* @strchr(i8* %12, i8 signext 38)
store i8* %13, i8** %3
%14 = load i8*, i8** %3
store i8 0, i8* %14
%15 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%16 = load i8*, i8** %2
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = call i32 @strcpy(i8* %18, i8* %20)
%22 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %7
%24 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %8
br label %26
26: ; preds = %11, %0
%27 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%28 = call i32 (i8*, i8*, ...) @sprintf(i8* %27, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%29 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%30 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%33 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = add nsw i32 %36, %37
%39 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %33, i32 %34, i32 %35, i32 %38)
%40 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%41 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%42 = call i32 (i8*, i8*, ...) @sprintf(i8* %40, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%44 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%45 = call i64 @strlen(i8* %44)
%46 = trunc i64 %45 to i32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%49 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %49)
%51 = load i32, i32* @stdout
%52 = call i32 @fflush(i32 %51)
%53 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [13 x i8] c"QUERY_STRING\00"
@.str.1 = [21 x i8] c"Welcome to add.com: \00"
@.str.2 = [37 x i8] c"%sTHE Internet addition portal.\0D\0A<p>\00"
@.str.3 = [35 x i8] c"%sThe answer is: %d + %d = %d\0D\0A<p>\00"
@.str.4 = [25 x i8] c"%sThanks for visiting!\0D\0A\00"
@.str.6 = [21 x i8] c"Content-length: %d\0D\0A\00"
@.str.8 = [3 x i8] c"%s\00"
@stdout = global i32 0
@str = [19 x i8] c"Connection: close\0D\00"
@str.9 = [27 x i8] c"Content-type: text/html\0D\0A\0D\00"
define i32 @main() {
%1 = alloca [8192 x i8]
%2 = alloca [8192 x i8]
%3 = alloca [8192 x i8]
%4 = getelementptr inbounds [8192 x i8], [8192 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%7 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %16, label %9
9: ; preds = %0
%10 = tail call i8* @strchr(i8* %7, i8 signext 38)
store i8 0, i8* %10
%11 = call i32 @strcpy(i8* %4, i8* %7)
%12 = getelementptr inbounds i8, i8* %10, i64 1
%13 = call i32 @strcpy(i8* %5, i8* %12)
%14 = call i32 @atoi(i8* %4)
%15 = call i32 @atoi(i8* %5)
br label %16
16: ; preds = %9, %0
%17 = phi i32 [ %14, %9 ], [ 0, %0 ]
%18 = phi i32 [ %15, %9 ], [ 0, %0 ]
%19 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%20 = add nsw i32 %18, %17
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %6, i32 %17, i32 %18, i32 %20)
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%24 = call i64 @strlen(i8* %6)
%25 = trunc i64 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %25)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %6)
%29 = load i32, i32* @stdout
%30 = call i32 @fflush(i32 %29)
%31 = call i32 @exit(i32 0)
unreachable
}