#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 */
char *getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, long *, long *);
int main() {
  char *data;
  long m, n;
  printf("Content-Type:text/html\n\n");
  printf("<title>multiplication results</title>\n");
  printf("<h3>multiplication results</h3>\n");
  data = getenv("QUERY_STRING");
  if (data == NULL)
    printf("error");
  else if (sscanf(data, "m=%ld&n=%ld", &m, &n) != 2)
    printf("error args !=2");
  else
    printf("the product of %d and %d is %d \n", m, n, m * n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1197 <main+0x67>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ef <main+0xbf>
mov    -0x10(%rbp),%rdi
lea    0xed2(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     11cb <main+0x9b>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ea <main+0xba>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
imul   -0x20(%rbp),%rcx
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ef <main+0xbf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf04(%rip),%rdi
call   1040 <puts@plt>
lea    0xf10(%rip),%rdi
call   1040 <puts@plt>
lea    0xf2a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe91(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11b8 <main+0x78>
lea    0xe93(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rax,%rdi
call   1060 <sscanf@plt>
cmp    $0x2,%eax
jne    11c1 <main+0x81>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %rdx,%rcx
imul   %rsi,%rcx
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11cf <main+0x8f>
lea    0xe4e(%rip),%rdi
jmp    11c8 <main+0x88>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Content-Type:text/html\0A\0A\00"
@.str.1 = [39 x i8] c"<title>multiplication results</title>\0A\00"
@.str.2 = [33 x i8] c"<h3>multiplication results</h3>\0A\00"
@.str.3 = [13 x i8] c"QUERY_STRING\00"
@.str.4 = [6 x i8] c"error\00"
@.str.5 = [12 x i8] c"m=%ld&n=%ld\00"
@.str.6 = [15 x i8] c"error args !=2\00"
@.str.7 = [33 x i8] c"the product of %d and %d is %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
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 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%8 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i8* %8, i8** %2
%9 = load i8*, i8** %2
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %27
13: ; preds = %0
%14 = load i8*, i8** %2
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64* %3, i64* %4)
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %26
19: ; preds = %13
%20 = load i64, i64* %3
%21 = load i64, i64* %4
%22 = load i64, i64* %3
%23 = load i64, i64* %4
%24 = mul nsw i64 %22, %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i64 %20, i64 %21, i64 %24)
br label %26
26: ; preds = %19, %17
br label %27
27: ; preds = %26, %11
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [13 x i8] c"QUERY_STRING\00"
@.str.4 = [6 x i8] c"error\00"
@.str.5 = [12 x i8] c"m=%ld&n=%ld\00"
@.str.6 = [15 x i8] c"error args !=2\00"
@.str.7 = [33 x i8] c"the product of %d and %d is %d \0A\00"
@str = [24 x i8] c"Content-Type:text/html\0A\00"
@str.8 = [38 x i8] c"<title>multiplication results</title>\00"
@str.9 = [32 x i8] c"<h3>multiplication results</h3>\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.8, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%8 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %22
12: ; preds = %0
%13 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64* %1, i64* %2)
%14 = icmp eq i32 %13, 2
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %22
17: ; preds = %12
%18 = load i64, i64* %1
%19 = load i64, i64* %2
%20 = mul nsw i64 %19, %18
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i64 %18, i64 %19, i64 %20)
br label %22
22: ; preds = %15, %17, %10
ret i32 0
}