#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 /*<<< orphan*/ printf(char *, long, long);
int main(int argc, char *argv[]) {
  int x = 0x7fffffff;
  printf("x=%d x+x=%d\n", x, x + x);
  signed short y = 0x7fff;
  signed short yy = y + y;
  printf("y=%d y+y=%d\n", y, yy);
  long z = 0x7fffffffffffffffL;
  printf("z=%ld z+z=%ld\n", z, z + z);
  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)
movl   $0x7fffffff,-0x14(%rbp)
movslq -0x14(%rbp),%rsi
mov    -0x14(%rbp),%eax
add    -0x14(%rbp),%eax
movslq %eax,%rdx
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
movw   $0x7fff,-0x16(%rbp)
movswl -0x16(%rbp),%eax
movswl -0x16(%rbp),%ecx
add    %ecx,%eax
mov    %ax,-0x18(%rbp)
movswq -0x16(%rbp),%rsi
movswq -0x18(%rbp),%rdx
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
movabs $0x7fffffffffffffff,%rax
ff ff 7f
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x20(%rbp),%rdx
add    -0x20(%rbp),%rdx
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x7fffffff,%esi
mov    $0xfffffffffffffffe,%rdx
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
mov    $0x7fff,%esi
mov    $0xfffffffffffffffe,%rdx
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
movabs $0x7fffffffffffffff,%rsi
ff ff 7f
mov    $0xfffffffffffffffe,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"x=%d x+x=%d\0A\00"
@.str.1 = [13 x i8] c"y=%d y+y=%d\0A\00"
@.str.2 = [15 x i8] c"z=%ld z+z=%ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i16
%8 = alloca i16
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 2147483647, i32* %6
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = load i32, i32* %6
%13 = load i32, i32* %6
%14 = add nsw i32 %12, %13
%15 = sext i32 %14 to i64
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 %11, i64 %15)
store i16 32767, i16* %7
%17 = load i16, i16* %7
%18 = sext i16 %17 to i32
%19 = load i16, i16* %7
%20 = sext i16 %19 to i32
%21 = add nsw i32 %18, %20
%22 = trunc i32 %21 to i16
store i16 %22, i16* %8
%23 = load i16, i16* %7
%24 = sext i16 %23 to i64
%25 = load i16, i16* %8
%26 = sext i16 %25 to i64
%27 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 %24, i64 %26)
store i64 9223372036854775807, i64* %9
%28 = load i64, i64* %9
%29 = load i64, i64* %9
%30 = load i64, i64* %9
%31 = add nsw i64 %29, %30
%32 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i64 %28, i64 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"x=%d x+x=%d\0A\00"
@.str.1 = [13 x i8] c"y=%d y+y=%d\0A\00"
@.str.2 = [15 x i8] c"z=%ld z+z=%ld\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 2147483647, i64 -2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 32767, i64 -2)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i64 9223372036854775807, i64 -2)
ret i32 0
}