#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*/ abort();
void bar(int n, int c) {
  static int lastn = -1, lastc = -1;
  if (lastn != n) {
    if (lastc != lastn)
      abort();
    lastc = 0;
    lastn = n;
  }
  if (c != (char)(lastc ^ (n << 3)))
    abort();
  lastc++;
}


x86 assembly (clang, -O0):
<bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2f04(%rip),%eax
cmp    -0x4(%rbp),%eax
je     1159 <bar+0x49>
mov    0x2ef9(%rip),%eax
cmp    0x2eef(%rip),%eax
je     1146 <bar+0x36>
mov    $0x0,%al
call   1030 <abort@plt>
movl   $0x0,0x2edc(%rip)
mov    -0x4(%rbp),%eax
mov    %eax,0x2ecf(%rip)
mov    -0x8(%rbp),%eax
mov    0x2eca(%rip),%ecx
mov    -0x4(%rbp),%edx
shl    $0x3,%edx
xor    %edx,%ecx
movsbl %cl,%ecx
cmp    %ecx,%eax
je     117c <bar+0x6c>
mov    $0x0,%al
call   1030 <abort@plt>
mov    0x2eaa(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ea1(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bar>:
push   %rax
mov    0x2f11(%rip),%ecx
mov    0x2f0f(%rip),%eax
cmp    %edi,%ecx
je     1137 <bar+0x27>
cmp    %ecx,%eax
jne    1153 <bar+0x43>
movl   $0x0,0x2efd(%rip)
mov    %edi,0x2ef3(%rip)
xor    %eax,%eax
shl    $0x1b,%edi
mov    %eax,%ecx
shl    $0x18,%ecx
xor    %edi,%ecx
sar    $0x18,%ecx
cmp    %esi,%ecx
jne    1153 <bar+0x43>
add    $0x1,%eax
mov    %eax,0x2edb(%rip)
pop    %rax
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@bar.lastn = internal global i32 -1
@bar.lastc = internal global i32 -1
define void @bar(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* @bar.lastn
%6 = load i32, i32* %3
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = load i32, i32* @bar.lastc
%10 = load i32, i32* @bar.lastn
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %8
store i32 0, i32* @bar.lastc
%15 = load i32, i32* %3
store i32 %15, i32* @bar.lastn
br label %16
16: ; preds = %14, %2
%17 = load i32, i32* %4
%18 = load i32, i32* @bar.lastc
%19 = load i32, i32* %3
%20 = shl i32 %19, 3
%21 = xor i32 %18, %20
%22 = trunc i32 %21 to i8
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %17, %23
br i1 %24, label %25, label %27
25: ; preds = %16
%26 = call i32 (...) @abort()
unreachable
27: ; preds = %16
%28 = load i32, i32* @bar.lastc
%29 = add nsw i32 %28, 1
store i32 %29, i32* @bar.lastc
ret void
}

LLVM IR (-O2):
@bar.lastn = internal unnamed_addr global i32 -1
@bar.lastc = internal unnamed_addr global i32 -1
define void @bar(i32 %0, i32 %1) {
%3 = load i32, i32* @bar.lastn
%4 = icmp eq i32 %3, %0
%5 = load i32, i32* @bar.lastc
br i1 %4, label %11, label %6
6: ; preds = %2
%7 = icmp eq i32 %5, %3
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %6
store i32 0, i32* @bar.lastc
store i32 %0, i32* @bar.lastn
br label %11
11: ; preds = %2, %10
%12 = phi i32 [ 0, %10 ], [ %5, %2 ]
%13 = shl i32 %0, 27
%14 = shl i32 %12, 24
%15 = xor i32 %14, %13
%16 = ashr exact i32 %15, 24
%17 = icmp eq i32 %16, %1
br i1 %17, label %20, label %18
18: ; preds = %11
%19 = tail call i32 (...) @abort()
unreachable
20: ; preds = %11
%21 = add nsw i32 %12, 1
store i32 %21, i32* @bar.lastc
ret void
}