#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 /*<<< orphan*/ EXIT_SUCCESS;
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ cgi_exit();
scalar_t__ cgi_get_isset(char *);
int /*<<< orphan*/ cgi_get_value(char *);
scalar_t__ cgi_has_get();
int /*<<< orphan*/ cgi_init();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int main(void) {
  int n1 = 0, n2 = 0;
  printf("Content-type: text/plain\n");
  cgi_init();
  printf("Welcome to the Internet addition portal.\n");
  if (cgi_has_get() && cgi_get_isset("arg1") && cgi_get_isset("arg2")) {
    n1 = atoi(cgi_get_value("arg1"));
    n2 = atoi(cgi_get_value("arg2"));
  }
  printf("The answer is: %d + %d = %d\n", n1, n2, n1 + n2);
  printf("Thanks for visiting!\n");
  fflush(stdout);
  cgi_exit();
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1070 <cgi_init@plt>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <cgi_has_get@plt>
cmp    $0x0,%rax
je     1239 <main+0xa9>
lea    0xe5c(%rip),%rdi
call   10a0 <cgi_get_isset@plt>
cmp    $0x0,%rax
je     1239 <main+0xa9>
lea    0xe4b(%rip),%rdi
call   10a0 <cgi_get_isset@plt>
cmp    $0x0,%rax
je     1239 <main+0xa9>
lea    0xe30(%rip),%rdi
call   1050 <cgi_get_value@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %eax,-0x8(%rbp)
lea    0xe1f(%rip),%rdi
call   1050 <cgi_get_value@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
add    -0xc(%rbp),%ecx
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x0,%al
call   10b0 <cgi_exit@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <cgi_init@plt>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <cgi_has_get@plt>
test   %rax,%rax
je     11df <main+0x3f>
lea    0xe2b(%rip),%rdi
call   10b0 <cgi_get_isset@plt>
test   %rax,%rax
jne    1223 <main+0x83>
xor    %edx,%edx
lea    (%rdx,%rbx,1),%ecx
lea    0xe1f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
xor    %eax,%eax
call   10c0 <cgi_exit@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    0xddb(%rip),%rdi
call   10b0 <cgi_get_isset@plt>
mov    $0x0,%edx
test   %rax,%rax
je     11e1 <main+0x41>
lea    0xdc0(%rip),%rdi
call   1060 <cgi_get_value@plt>
mov    %eax,%edi
call   1090 <atoi@plt>
mov    %eax,%ebx
lea    0xdb0(%rip),%rdi
call   1060 <cgi_get_value@plt>
mov    %eax,%edi
call   1090 <atoi@plt>
mov    %eax,%edx
jmp    11e1 <main+0x41>

LLVM IR (-O0):
@.str = [26 x i8] c"Content-type: text/plain\0A\00"
@.str.1 = [42 x i8] c"Welcome to the Internet addition portal.\0A\00"
@.str.2 = [5 x i8] c"arg1\00"
@.str.3 = [5 x i8] c"arg2\00"
@.str.4 = [29 x i8] c"The answer is: %d + %d = %d\0A\00"
@.str.5 = [22 x i8] c"Thanks for visiting!\0A\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @cgi_init()
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%7 = call i64 (...) @cgi_has_get()
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %0
%10 = call i64 @cgi_get_isset(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = call i64 @cgi_get_isset(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = call i32 @cgi_get_value(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @atoi(i32 %16)
store i32 %17, i32* %2
%18 = call i32 @cgi_get_value(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @atoi(i32 %18)
store i32 %19, i32* %3
br label %20
20: ; preds = %15, %12, %9, %0
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = add nsw i32 %23, %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %21, i32 %22, i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%28 = load i32, i32* @stdout
%29 = call i32 @fflush(i32 %28)
%30 = call i32 (...) @cgi_exit()
%31 = load i32, i32* @EXIT_SUCCESS
%32 = call i32 @exit(i32 %31)
unreachable
}

LLVM IR (-O2):
@.str.2 = [5 x i8] c"arg1\00"
@.str.3 = [5 x i8] c"arg2\00"
@.str.4 = [29 x i8] c"The answer is: %d + %d = %d\0A\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [25 x i8] c"Content-type: text/plain\00"
@str.6 = [41 x i8] c"Welcome to the Internet addition portal.\00"
@str.7 = [21 x i8] c"Thanks for visiting!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @cgi_init()
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.6, i64 0, i64 0))
%4 = tail call i64 (...) @cgi_has_get()
%5 = icmp eq i64 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %0
%7 = tail call i64 @cgi_get_isset(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %6
%10 = tail call i64 @cgi_get_isset(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = tail call i32 @cgi_get_value(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @atoi(i32 %13)
%15 = tail call i32 @cgi_get_value(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 @atoi(i32 %15)
br label %17
17: ; preds = %12, %9, %6, %0
%18 = phi i32 [ %14, %12 ], [ 0, %9 ], [ 0, %6 ], [ 0, %0 ]
%19 = phi i32 [ %16, %12 ], [ 0, %9 ], [ 0, %6 ], [ 0, %0 ]
%20 = add nsw i32 %19, %18
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %18, i32 %19, i32 %20)
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
%23 = load i32, i32* @stdout
%24 = tail call i32 @fflush(i32 %23)
%25 = tail call i32 (...) @cgi_exit()
%26 = load i32, i32* @EXIT_SUCCESS
%27 = tail call i32 @exit(i32 %26)
unreachable
}