#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 SCHAR_MAX;
int UCHAR_MAX;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int main(void) {
  int i;
  signed char j;
  unsigned char k;
  i = SCHAR_MAX;
  j = ((signed char)(i << 1)) / 2;
  if (j != -1)
    abort();
  j = ((signed char)(i * 2)) / 2;
  if (j != -1)
    abort();
  i = UCHAR_MAX;
  k = ((unsigned char)(i << 1)) / 2;
  if (k != UCHAR_MAX / 2)
    abort();
  k = ((unsigned char)(i * 2)) / 2;
  if (k != UCHAR_MAX / 2)
    abort();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
movsbl %al,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xffffffff,%eax
je     1163 <main+0x43>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
movsbl %al,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xffffffff,%eax
je     118b <main+0x6b>
mov    $0x0,%al
call   1030 <abort@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
movzbl %al,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %al,-0xa(%rbp)
movzbl -0xa(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e37(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
je     11d7 <main+0xb7>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
movzbl %al,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %al,-0xa(%rbp)
movzbl -0xa(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    0x2df7(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
je     1217 <main+0xf7>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%eax
not    %eax
test   $0x7f,%al
jne    1150 <main+0x30>
mov    0x2eb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0x7f,%eax
sar    %ecx
cmp    %ecx,%eax
jne    1150 <main+0x30>
xor    %edi,%edi
call   1040 <exit@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@SCHAR_MAX = global i32 0
@UCHAR_MAX = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
store i32 0, i32* %1
%5 = load i32, i32* @SCHAR_MAX
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = shl i32 %6, 1
%8 = trunc i32 %7 to i8
%9 = sext i8 %8 to i32
%10 = sdiv i32 %9, 2
%11 = trunc i32 %10 to i8
store i8 %11, i8* %3
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 (...) @abort()
unreachable
17: ; preds = %0
%18 = load i32, i32* %2
%19 = mul nsw i32 %18, 2
%20 = trunc i32 %19 to i8
%21 = sext i8 %20 to i32
%22 = sdiv i32 %21, 2
%23 = trunc i32 %22 to i8
store i8 %23, i8* %3
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, -1
br i1 %26, label %27, label %29
27: ; preds = %17
%28 = call i32 (...) @abort()
unreachable
29: ; preds = %17
%30 = load i32, i32* @UCHAR_MAX
store i32 %30, i32* %2
%31 = load i32, i32* %2
%32 = shl i32 %31, 1
%33 = trunc i32 %32 to i8
%34 = zext i8 %33 to i32
%35 = sdiv i32 %34, 2
%36 = trunc i32 %35 to i8
store i8 %36, i8* %4
%37 = load i8, i8* %4
%38 = zext i8 %37 to i32
%39 = load i32, i32* @UCHAR_MAX
%40 = sdiv i32 %39, 2
%41 = icmp ne i32 %38, %40
br i1 %41, label %42, label %44
42: ; preds = %29
%43 = call i32 (...) @abort()
unreachable
44: ; preds = %29
%45 = load i32, i32* %2
%46 = mul nsw i32 %45, 2
%47 = trunc i32 %46 to i8
%48 = zext i8 %47 to i32
%49 = sdiv i32 %48, 2
%50 = trunc i32 %49 to i8
store i8 %50, i8* %4
%51 = load i8, i8* %4
%52 = zext i8 %51 to i32
%53 = load i32, i32* @UCHAR_MAX
%54 = sdiv i32 %53, 2
%55 = icmp ne i32 %52, %54
br i1 %55, label %56, label %58
56: ; preds = %44
%57 = call i32 (...) @abort()
unreachable
58: ; preds = %44
%59 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@SCHAR_MAX = global i32 0
@UCHAR_MAX = global i32 0
define i32 @main() {
%1 = load i32, i32* @SCHAR_MAX
%2 = and i32 %1, 127
%3 = icmp eq i32 %2, 127
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 (...) @abort()
unreachable
6: ; preds = %0
%7 = load i32, i32* @UCHAR_MAX
%8 = and i32 %7, 127
%9 = sdiv i32 %7, 2
%10 = icmp eq i32 %8, %9
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = tail call i32 (...) @abort()
unreachable
13: ; preds = %6
%14 = tail call i32 @exit(i32 0)
unreachable
}