#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 INT_MAX;
int INT_MIN;
int /*<<< orphan*/ assert(int);
int saturating_add(int, int);
int main(int argc, char *argv[]) {
  assert(INT_MAX == saturating_add(INT_MAX, 0x1234));
  assert(INT_MIN == saturating_add(INT_MIN, -0x1234));
  assert(0x11 + 0x22 == saturating_add(0x11, 0x22));
  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)
mov    0x2eab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e9f(%rip),%rax
mov    (%rax),%edi
mov    $0x1234,%esi
call   1040 <saturating_add@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    $0xffffedcc,%esi
call   1040 <saturating_add@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0x11,%edi
mov    $0x22,%esi
call   1040 <saturating_add@plt>
mov    %eax,%ecx
mov    $0x33,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ec0(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
mov    $0x1234,%esi
call   1040 <saturating_add@plt>
xor    %edi,%edi
cmp    %eax,%ebx
sete   %dil
call   1030 <assert@plt>
mov    0x2e96(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
mov    $0xffffedcc,%esi
call   1040 <saturating_add@plt>
xor    %edi,%edi
cmp    %eax,%ebx
sete   %dil
call   1030 <assert@plt>
mov    $0x11,%edi
mov    $0x22,%esi
call   1040 <saturating_add@plt>
xor    %edi,%edi
cmp    $0x33,%eax
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
@INT_MIN = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @INT_MAX
%7 = load i32, i32* @INT_MAX
%8 = call i32 @saturating_add(i32 %7, i32 4660)
%9 = icmp eq i32 %6, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i32, i32* @INT_MIN
%13 = load i32, i32* @INT_MIN
%14 = call i32 @saturating_add(i32 %13, i32 -4660)
%15 = icmp eq i32 %12, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32 @saturating_add(i32 17, i32 34)
%19 = icmp eq i32 51, %18
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
ret i32 0
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@INT_MIN = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @INT_MAX
%4 = tail call i32 @saturating_add(i32 %3, i32 4660)
%5 = icmp eq i32 %3, %4
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = load i32, i32* @INT_MIN
%9 = tail call i32 @saturating_add(i32 %8, i32 -4660)
%10 = icmp eq i32 %8, %9
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32 @saturating_add(i32 17, i32 34)
%14 = icmp eq i32 %13, 51
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
ret i32 0
}