#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 is_add_overflow(int, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int a, b;
  if (argc == 3) {
    a = atoi(argv[1]);
    b = atoi(argv[2]);
    printf("is_add_overflow(a, b)"
           "is: %d\n",
           (is_add_overflow(a, b)));
  } else {
    printf("is_add_overflow(2147483647, 1)"
           "is: %d\n",
           (is_add_overflow(2147483647, 1)));
    printf("is_add_overflow(2147483646, 1)"
           "is: %d\n",
           (is_add_overflow(2147483646, 1)));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    118e <main+0x5e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <is_add_overflow@plt>
mov    %eax,%esi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
jmp    11c8 <main+0x98>
mov    $0x7fffffff,%edi
mov    $0x1,%esi
call   1040 <is_add_overflow@plt>
mov    %eax,%esi
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
mov    $0x7ffffffe,%edi
mov    $0x1,%esi
call   1040 <is_add_overflow@plt>
mov    %eax,%esi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    1161 <main+0x31>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <is_add_overflow@plt>
lea    0xea1(%rip),%rdi
jmp    1194 <main+0x64>
mov    $0x7fffffff,%edi
mov    $0x1,%esi
call   1040 <is_add_overflow@plt>
lea    0xea6(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x7ffffffe,%edi
mov    $0x1,%esi
call   1040 <is_add_overflow@plt>
lea    0xeaf(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"is_add_overflow(a, b)is: %d\0A\00"
@.str.1 = [38 x i8] c"is_add_overflow(2147483647, 1)is: %d\0A\00"
@.str.2 = [38 x i8] c"is_add_overflow(2147483646, 1)is: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 3
br i1 %9, label %10, label %23
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %6
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %7
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = call i32 @is_add_overflow(i32 %19, i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %28
23: ; preds = %2
%24 = call i32 @is_add_overflow(i32 2147483647, i32 1)
%25 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = call i32 @is_add_overflow(i32 2147483646, i32 1)
%27 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %23, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"is_add_overflow(a, b)is: %d\0A\00"
@.str.1 = [38 x i8] c"is_add_overflow(2147483647, 1)is: %d\0A\00"
@.str.2 = [38 x i8] c"is_add_overflow(2147483646, 1)is: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = tail call i32 @is_add_overflow(i32 %7, i32 %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %18
13: ; preds = %2
%14 = tail call i32 @is_add_overflow(i32 2147483647, i32 1)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = tail call i32 @is_add_overflow(i32 2147483646, i32 1)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %13, %4
ret i32 0
}