#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*/ check(int volatile, int);
int main(void) {
  volatile signed char a = -2;
  volatile signed char b = 0x7f;
  volatile signed char c = a * b;
  check(c, 2);
  volatile short d = 0x7fff;
  volatile short e = 2;
  volatile short f = d * e;
  check(f, -2);
  volatile int m = 0x7fffffff;
  volatile int n = 1;
  volatile int o = m * n;
  check(o, 0x7fffffff);
  m = (-0x7fffffff - 1);
  o = m * n;
  check(o, (-0x7fffffff - 1));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0xfe,-0x5(%rbp)
movb   $0x7f,-0x6(%rbp)
mov    -0x5(%rbp),%al
movsbl %al,%eax
mov    -0x6(%rbp),%cl
movsbl %cl,%ecx
imul   %ecx,%eax
mov    %al,-0x7(%rbp)
mov    -0x7(%rbp),%al
movsbl %al,%edi
mov    $0x2,%esi
call   1030 <check@plt>
movw   $0x7fff,-0xa(%rbp)
movw   $0x2,-0xc(%rbp)
mov    -0xa(%rbp),%ax
cwtl
mov    -0xc(%rbp),%cx
movswl %cx,%ecx
imul   %ecx,%eax
mov    %ax,-0xe(%rbp)
mov    -0xe(%rbp),%ax
movswl %ax,%edi
mov    $0xfffffffe,%esi
call   1030 <check@plt>
movl   $0x7fffffff,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x7fffffff,%esi
call   1030 <check@plt>
movl   $0x80000000,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x80000000,%esi
call   1030 <check@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movb   $0xfe,0x3(%rsp)
movb   $0x7f,0x2(%rsp)
mov    0x3(%rsp),%cl
mov    0x2(%rsp),%al
mul    %cl
mov    %al,0x1(%rsp)
movsbl 0x1(%rsp),%edi
mov    $0x2,%esi
call   1030 <check@plt>
movw   $0x7fff,0x12(%rsp)
movw   $0x2,0x10(%rsp)
movzwl 0x12(%rsp),%eax
imul   0x10(%rsp),%ax
mov    %ax,0xe(%rsp)
movswl 0xe(%rsp),%edi
mov    $0xfffffffe,%esi
call   1030 <check@plt>
movl   $0x7fffffff,0x8(%rsp)
7f
movl   $0x1,0x14(%rsp)
mov    0x8(%rsp),%eax
imul   0x14(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x4(%rsp),%edi
mov    $0x7fffffff,%esi
call   1030 <check@plt>
movl   $0x80000000,0x8(%rsp)
80
mov    0x8(%rsp),%eax
imul   0x14(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x4(%rsp),%edi
mov    $0x80000000,%esi
call   1030 <check@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store volatile i8 -2, i8* %2
store volatile i8 127, i8* %3
%11 = load volatile i8, i8* %2
%12 = sext i8 %11 to i32
%13 = load volatile i8, i8* %3
%14 = sext i8 %13 to i32
%15 = mul nsw i32 %12, %14
%16 = trunc i32 %15 to i8
store volatile i8 %16, i8* %4
%17 = load volatile i8, i8* %4
%18 = sext i8 %17 to i32
%19 = call i32 @check(i32 %18, i32 2)
store volatile i16 32767, i16* %5
store volatile i16 2, i16* %6
%20 = load volatile i16, i16* %5
%21 = sext i16 %20 to i32
%22 = load volatile i16, i16* %6
%23 = sext i16 %22 to i32
%24 = mul nsw i32 %21, %23
%25 = trunc i32 %24 to i16
store volatile i16 %25, i16* %7
%26 = load volatile i16, i16* %7
%27 = sext i16 %26 to i32
%28 = call i32 @check(i32 %27, i32 -2)
store volatile i32 2147483647, i32* %8
store volatile i32 1, i32* %9
%29 = load volatile i32, i32* %8
%30 = load volatile i32, i32* %9
%31 = mul nsw i32 %29, %30
store volatile i32 %31, i32* %10
%32 = load volatile i32, i32* %10
%33 = call i32 @check(i32 %32, i32 2147483647)
store volatile i32 -2147483648, i32* %8
%34 = load volatile i32, i32* %8
%35 = load volatile i32, i32* %9
%36 = mul nsw i32 %34, %35
store volatile i32 %36, i32* %10
%37 = load volatile i32, i32* %10
%38 = call i32 @check(i32 %37, i32 -2147483648)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store volatile i8 -2, i8* %1
store volatile i8 127, i8* %2
%10 = load volatile i8, i8* %1
%11 = load volatile i8, i8* %2
%12 = mul i8 %11, %10
store volatile i8 %12, i8* %3
%13 = load volatile i8, i8* %3
%14 = sext i8 %13 to i32
%15 = tail call i32 @check(i32 %14, i32 2)
%16 = bitcast i16* %4 to i8*
store volatile i16 32767, i16* %4
%17 = bitcast i16* %5 to i8*
store volatile i16 2, i16* %5
%18 = bitcast i16* %6 to i8*
%19 = load volatile i16, i16* %4
%20 = load volatile i16, i16* %5
%21 = mul i16 %20, %19
store volatile i16 %21, i16* %6
%22 = load volatile i16, i16* %6
%23 = sext i16 %22 to i32
%24 = tail call i32 @check(i32 %23, i32 -2)
%25 = bitcast i32* %7 to i8*
store volatile i32 2147483647, i32* %7
%26 = bitcast i32* %8 to i8*
store volatile i32 1, i32* %8
%27 = bitcast i32* %9 to i8*
%28 = load volatile i32, i32* %7
%29 = load volatile i32, i32* %8
%30 = mul nsw i32 %29, %28
store volatile i32 %30, i32* %9
%31 = load volatile i32, i32* %9
%32 = tail call i32 @check(i32 %31, i32 2147483647)
store volatile i32 -2147483648, i32* %7
%33 = load volatile i32, i32* %7
%34 = load volatile i32, i32* %8
%35 = mul nsw i32 %34, %33
store volatile i32 %35, i32* %9
%36 = load volatile i32, i32* %9
%37 = tail call i32 @check(i32 %36, i32 -2147483648)
ret i32 0
}