#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*/ printf(char *, int, int, int);
int saturating_add(int, int);
int main(void) {
  int a = 0;
  int b = 0;
  a = INT_MAX;
  b = 10;
  printf("%d + %d = %d\n", a, b, saturating_add(a, b));
  a = INT_MIN;
  b = -10;
  printf("%d + %d = %d\n", a, b, saturating_add(a, b));
  a = 1024;
  b = 2048;
  printf("%d + %d = %d\n", a, b, saturating_add(a, b));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2ea4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <saturating_add@plt>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    %eax,%ecx
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movl   $0xfffffff6,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <saturating_add@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x400,-0x8(%rbp)
movl   $0x800,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <saturating_add@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    %eax,%ecx
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x2ebe(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
mov    $0xa,%esi
call   1040 <saturating_add@plt>
lea    0xec1(%rip),%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0xa,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
mov    $0xfffffff6,%esi
call   1040 <saturating_add@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0xfffffff6,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    $0x400,%edi
mov    $0x800,%esi
call   1040 <saturating_add@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    $0x800,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
@.str = [14 x i8] c"%d + %d = %d\0A\00"
@INT_MIN = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* @INT_MAX
store i32 %4, i32* %2
store i32 10, i32* %3
%5 = load i32, i32* %2
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = call i32 @saturating_add(i32 %7, i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6, i32 %9)
%11 = load i32, i32* @INT_MIN
store i32 %11, i32* %2
store i32 -10, i32* %3
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call i32 @saturating_add(i32 %14, i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13, i32 %16)
store i32 1024, i32* %2
store i32 2048, i32* %3
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = call i32 @saturating_add(i32 %20, i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19, i32 %22)
ret i32 0
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@.str = [14 x i8] c"%d + %d = %d\0A\00"
@INT_MIN = global i32 0
define i32 @main() {
%1 = load i32, i32* @INT_MAX
%2 = tail call i32 @saturating_add(i32 %1, i32 10)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %1, i32 10, i32 %2)
%4 = load i32, i32* @INT_MIN
%5 = tail call i32 @saturating_add(i32 %4, i32 -10)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %4, i32 -10, i32 %5)
%7 = tail call i32 @saturating_add(i32 1024, i32 2048)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 1024, i32 2048, i32 %7)
ret i32 0
}