#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 *);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char *pa = getenv("a");
  char *pb = getenv("b");
  int a = 0;
  int b = 0;
  int result = 0;
  if (!pa || !pb || !(a = atoi(pa)) || !(b = atoi(pb))) {
    printf("<p>args error</p>\r\n");
    return 0;
  }
  result = a + b;
  printf("<p>%d + %d = %d</p>\r\n", a, b, result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
lea    0xea5(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11bb <main+0x8b>
cmpq   $0x0,-0x20(%rbp)
je     11bb <main+0x8b>
mov    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     11bb <main+0x8b>
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jne    11d5 <main+0xa5>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11fc <main+0xcc>
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbp
lea    0xea9(%rip),%rdi
call   1030 <getenv@plt>
test   %rbp,%rbp
je     119d <main+0x5d>
mov    %rax,%rbx
test   %rax,%rax
je     119d <main+0x5d>
mov    %rbp,%rdi
call   1060 <atoi@plt>
test   %eax,%eax
je     119d <main+0x5d>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <atoi@plt>
test   %eax,%eax
je     119d <main+0x5d>
mov    %eax,%ecx
add    %ebp,%ecx
lea    0xe74(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a9 <main+0x69>
lea    0xe76(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@.str.1 = [2 x i8] c"b\00"
@.str.2 = [20 x i8] c"<p>args error</p>\0D\0A\00"
@.str.3 = [22 x i8] c"<p>%d + %d = %d</p>\0D\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i8* @getenv(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %6
%12 = call i8* @getenv(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %12, i8** %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%13 = load i8*, i8** %6
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %26
15: ; preds = %2
%16 = load i8*, i8** %7
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i8*, i8** %6
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %8
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i8*, i8** %7
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %9
%25 = icmp ne i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22, %18, %15, %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %36
28: ; preds = %22
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = add nsw i32 %29, %30
store i32 %31, i32* %10
%32 = load i32, i32* %8
%33 = load i32, i32* %9
%34 = load i32, i32* %10
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %32, i32 %33, i32 %34)
store i32 0, i32* %3
br label %36
36: ; preds = %28, %26
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@.str.1 = [2 x i8] c"b\00"
@.str.3 = [22 x i8] c"<p>%d + %d = %d</p>\0D\0A\00"
@str = [19 x i8] c"<p>args error</p>\0D\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp ne i8* %3, null
%6 = icmp ne i8* %4, null
%7 = and i1 %5, %6
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = tail call i32 @atoi(i8* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 @atoi(i8* %4)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11, %8, %2
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %19
16: ; preds = %11
%17 = add nsw i32 %12, %9
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 %12, i32 %17)
br label %19
19: ; preds = %16, %14
ret i32 0
}