#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*/ assert(int);
int /*<<< orphan*/ printf(char *, char);
int main() {
  char a;
  if (a == 127)
    return 42;
  char b = a + 1;
  printf("b: %d\n", b);
  assert(b != -128);
  int c;
  if (c == -128)
    return 42;
  c = (char)c;
  assert(c != -128);
  int top;
  unsigned long ul = 77777777;
  if (top) {
    ul = 255;
  }
  if (ul != 511) {
    unsigned char uc = (unsigned char)ul;
    assert(uc != 255);
    ul = 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x7f,%eax
jne    1148 <main+0x28>
movl   $0x2a,-0x4(%rbp)
jmp    11f3 <main+0xd3>
movsbl -0x5(%rbp),%eax
add    $0x1,%eax
mov    %al,-0x6(%rbp)
lea    0xea7(%rip),%rdi
movsbl -0x6(%rbp),%esi
call   1030 <printf@plt>
movsbl -0x6(%rbp),%eax
cmp    $0xffffff80,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0xffffff80,-0xc(%rbp)
jne    118c <main+0x6c>
movl   $0x2a,-0x4(%rbp)
jmp    11f3 <main+0xd3>
mov    -0xc(%rbp),%eax
movsbl %al,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xffffff80,-0xc(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movq   $0x4a2cb71,-0x18(%rbp)
04
cmpl   $0x0,-0x10(%rbp)
je     11c0 <main+0xa0>
movq   $0xff,-0x18(%rbp)
cmpq   $0x1ff,-0x18(%rbp)
je     11f3 <main+0xd3>
mov    -0x18(%rbp),%rax
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0xff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movq   $0x1,-0x18(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <assert@plt>
mov    $0x1,%edi
call   1040 <assert@plt>
mov    $0x1,%edi
call   1040 <assert@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"b: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca i8
store i32 0, i32* %1
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 127
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 42, i32* %1
br label %49
12: ; preds = %0
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = add nsw i32 %14, 1
%16 = trunc i32 %15 to i8
store i8 %16, i8* %3
%17 = load i8, i8* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %17)
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, -128
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, -128
br i1 %25, label %26, label %27
26: ; preds = %12
store i32 42, i32* %1
br label %49
27: ; preds = %12
%28 = load i32, i32* %4
%29 = trunc i32 %28 to i8
%30 = sext i8 %29 to i32
store i32 %30, i32* %4
%31 = load i32, i32* %4
%32 = icmp ne i32 %31, -128
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
store i64 77777777, i64* %6
%35 = load i32, i32* %5
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %27
store i64 255, i64* %6
br label %38
38: ; preds = %37, %27
%39 = load i64, i64* %6
%40 = icmp ne i64 %39, 511
br i1 %40, label %41, label %49
41: ; preds = %38
%42 = load i64, i64* %6
%43 = trunc i64 %42 to i8
store i8 %43, i8* %7
%44 = load i8, i8* %7
%45 = zext i8 %44 to i32
%46 = icmp ne i32 %45, 255
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
store i64 1, i64* %6
br label %49
49: ; preds = %11, %26, %41, %38
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
@.str = [7 x i8] c"b: %d\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext 1)
%2 = tail call i32 @assert(i32 1)
%3 = tail call i32 @assert(i32 1)
%4 = tail call i32 @assert(i32 1)
ret i32 0
}