#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 */
unsigned long LONG_MAX;
long LONG_MIN;
unsigned long ULONG_MAX;
int /*<<< orphan*/ printf(char *, ...);
void range_long(void) {
  unsigned long max, umax;
  long min;
  int BITS = 64;
  min = LONG_MIN;
  max = LONG_MAX;
  umax = ULONG_MAX;
  printf("limit.h: long\n");
  printf("%19ld\tmin\n%20ld\tmax\n%20lu\tumax\n", min, max, umax);
  min = ~0 << (BITS - 1);
  max = ~(~0 << (BITS - 1));
  umax = ~0;
  printf("bitshift: long\n");
  printf(" %19ld\tmin\n%20ld\tmax\n%20lu\tumax\n", min, max, umax);
  return;
}


x86 assembly (clang, -O0):
<range_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x40,-0x1c(%rbp)
mov    0x2ec2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2ea4(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
cltq
mov    %rax,-0x8(%rbp)
movq   $0xffffffffffffffff,-0x10(%rbp)
ff
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<range_long>:
push   %r15
push   %r14
push   %rbx
mov    0x2ebc(%rip),%rax
mov    (%rax),%r14
mov    0x2ea2(%rip),%rax
mov    (%rax),%r15
mov    0x2e88(%rip),%rax
mov    (%rax),%rbx
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe87(%rip),%rdi
mov    $0xffffffffffffffff,%rcx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@LONG_MIN = global i64 0
@LONG_MAX = global i64 0
@ULONG_MAX = global i64 0
@.str = [15 x i8] c"limit.h: long\0A\00"
@.str.1 = [32 x i8] c"%19ld\09min\0A%20ld\09max\0A%20lu\09umax\0A\00"
@.str.2 = [16 x i8] c"bitshift: long\0A\00"
@.str.3 = [33 x i8] c" %19ld\09min\0A%20ld\09max\0A%20lu\09umax\0A\00"
define void @range_long() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
store i32 64, i32* %4
%5 = load i64, i64* @LONG_MIN
store i64 %5, i64* %3
%6 = load i64, i64* @LONG_MAX
store i64 %6, i64* %1
%7 = load i64, i64* @ULONG_MAX
store i64 %7, i64* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = load i64, i64* %3
%10 = load i64, i64* %1
%11 = load i64, i64* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i64 %9, i64 %10, i64 %11)
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = shl i32 -1, %14
%16 = sext i32 %15 to i64
store i64 %16, i64* %3
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 1
%19 = shl i32 -1, %18
%20 = xor i32 %19, -1
%21 = sext i32 %20 to i64
store i64 %21, i64* %1
store i64 -1, i64* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%23 = load i64, i64* %3
%24 = load i64, i64* %1
%25 = load i64, i64* %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i64 %23, i64 %24, i64 %25)
ret void
}

LLVM IR (-O2):
@LONG_MIN = global i64 0
@LONG_MAX = global i64 0
@ULONG_MAX = global i64 0
@.str.1 = [32 x i8] c"%19ld\09min\0A%20ld\09max\0A%20lu\09umax\0A\00"
@.str.3 = [33 x i8] c" %19ld\09min\0A%20ld\09max\0A%20lu\09umax\0A\00"
@str = [14 x i8] c"limit.h: long\00"
@str.4 = [15 x i8] c"bitshift: long\00"
define void @range_long() {
%1 = load i64, i64* @LONG_MIN
%2 = load i64, i64* @LONG_MAX
%3 = load i64, i64* @ULONG_MAX
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i64 %1, i64 %2, i64 %3)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i64 poison, i64 poison, i64 -1)
ret void
}