#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(void) {
  char *datos;
  long m, n;
  printf("Content-Type:text/html\n\n");
  printf("<html>\n<head>\n");
  printf("<title>Resultado de la multiplicacion</title>\n");
  printf("</head>\n<h1>Resultado de la multiplicacion:</h1>\n");
  printf("<body>\n");
  datos = getenv("QUERY_STRING");
  if (datos == NULL)
    printf("<p>Error pasando datos desde el formulario al prog. CGI</p>");
  else if (sscanf(datos, "m=%ld&n=%ld", &m, &n) != 2)
    printf("<p>Error: los datos deben ser numericos.</p>");
  else
    printf("<h3>El producto de %ld y %ld es %ld.</h3>", m, n, m * n);
  printf("</body>\n");
  printf("</html>\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    0xec6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf05(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b3 <main+0x83>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120b <main+0xdb>
mov    -0x10(%rbp),%rdi
lea    0xf1c(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     11e7 <main+0xb7>
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1206 <main+0xd6>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
imul   -0x20(%rbp),%rcx
lea    0xf14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120b <main+0xdb>
lea    0xf2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf61(%rip),%rdi
call   1040 <puts@plt>
lea    0xf6d(%rip),%rdi
call   1040 <puts@plt>
lea    0xf6f(%rip),%rdi
call   1040 <puts@plt>
lea    0xf91(%rip),%rdi
call   1040 <puts@plt>
lea    0xfb6(%rip),%rdi
call   1040 <puts@plt>
lea    0xe79(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11d0 <main+0x90>
lea    0xeb1(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rax,%rdi
call   1060 <sscanf@plt>
cmp    $0x2,%eax
jne    11d9 <main+0x99>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %rdx,%rcx
imul   %rsi,%rcx
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e7 <main+0xa7>
lea    0xe36(%rip),%rdi
jmp    11e0 <main+0xa0>
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf4a(%rip),%rdi
call   1040 <puts@plt>
lea    0xf46(%rip),%rdi
call   1040 <puts@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 = [15 x i8] c"<html>\0A<head>\0A\00"
@.str.2 = [47 x i8] c"<title>Resultado de la multiplicacion</title>\0A\00"
@.str.3 = [50 x i8] c"</head>\0A<h1>Resultado de la multiplicacion:</h1>\0A\00"
@.str.4 = [8 x i8] c"<body>\0A\00"
@.str.5 = [13 x i8] c"QUERY_STRING\00"
@.str.6 = [60 x i8] c"<p>Error pasando datos desde el formulario al prog. CGI</p>\00"
@.str.7 = [12 x i8] c"m=%ld&n=%ld\00"
@.str.8 = [45 x i8] c"<p>Error: los datos deben ser numericos.</p>\00"
@.str.9 = [42 x i8] c"<h3>El producto de %ld y %ld es %ld.</h3>\00"
@.str.10 = [9 x i8] c"</body>\0A\00"
@.str.11 = [9 x i8] c"</html>\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 ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%10 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
store i8* %10, i8** %2
%11 = load i8*, i8** %2
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
br label %29
15: ; preds = %0
%16 = load i8*, i8** %2
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i64* %3, i64* %4)
%18 = icmp ne i32 %17, 2
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
br label %28
21: ; preds = %15
%22 = load i64, i64* %3
%23 = load i64, i64* %4
%24 = load i64, i64* %3
%25 = load i64, i64* %4
%26 = mul nsw i64 %24, %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i64 %22, i64 %23, i64 %26)
br label %28
28: ; preds = %21, %19
br label %29
29: ; preds = %28, %13
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [13 x i8] c"QUERY_STRING\00"
@.str.6 = [60 x i8] c"<p>Error pasando datos desde el formulario al prog. CGI</p>\00"
@.str.7 = [12 x i8] c"m=%ld&n=%ld\00"
@.str.8 = [45 x i8] c"<p>Error: los datos deben ser numericos.</p>\00"
@.str.9 = [42 x i8] c"<h3>El producto de %ld y %ld es %ld.</h3>\00"
@str = [24 x i8] c"Content-Type:text/html\0A\00"
@str.12 = [14 x i8] c"<html>\0A<head>\00"
@str.13 = [46 x i8] c"<title>Resultado de la multiplicacion</title>\00"
@str.14 = [49 x i8] c"</head>\0A<h1>Resultado de la multiplicacion:</h1>\00"
@str.15 = [7 x i8] c"<body>\00"
@str.16 = [8 x i8] c"</body>\00"
@str.17 = [8 x i8] c"</html>\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 ([14 x i8], [14 x i8]* @str.12, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.13, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.14, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.15, i64 0, i64 0))
%10 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
br label %24
14: ; preds = %0
%15 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i64* %1, i64* %2)
%16 = icmp eq i32 %15, 2
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
br label %24
19: ; preds = %14
%20 = load i64, i64* %1
%21 = load i64, i64* %2
%22 = mul nsw i64 %21, %20
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i64 %20, i64 %21, i64 %22)
br label %24
24: ; preds = %17, %19, %12
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.16, i64 0, i64 0))
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.17, i64 0, i64 0))
ret i32 0
}