#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();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
void check_flags(int actual, int expected) {
  int i;
  for (i = 0; i < (int)(sizeof actual); i++) {
    if (expected & (1 << i)) {
      if (!(actual & (1 << i))) {
        fprintf(stderr, "bit %d not set in special_flags\n", i);
        abort();
      }
    }
  }
}


x86 assembly (clang, -O0):
<check_flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11aa <check_flags+0x8a>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1197 <check_flags+0x77>
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
jne    1192 <check_flags+0x72>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xe7a(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1197 <check_flags+0x77>
jmp    119c <check_flags+0x7c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1135 <check_flags+0x15>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_flags>:
test   $0x1,%sil
je     112d <check_flags+0xd>
mov    %edi,%eax
and    $0x1,%eax
je     1153 <check_flags+0x33>
test   $0x2,%sil
je     113a <check_flags+0x1a>
mov    %edi,%eax
and    $0x2,%eax
je     1157 <check_flags+0x37>
test   $0x4,%sil
je     1147 <check_flags+0x27>
mov    %edi,%eax
and    $0x4,%eax
je     115e <check_flags+0x3e>
test   $0x8,%sil
je     1152 <check_flags+0x32>
and    $0x8,%edi
je     1165 <check_flags+0x45>
ret
xor    %edx,%edx
jmp    116a <check_flags+0x4a>
mov    $0x1,%edx
jmp    116a <check_flags+0x4a>
mov    $0x2,%edx
jmp    116a <check_flags+0x4a>
mov    $0x3,%edx
push   %rax
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"bit %d not set in special_flags\0A\00"
define void @check_flags(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %28, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %31
9: ; preds = %6
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = shl i32 1, %11
%13 = and i32 %10, %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %9
%16 = load i32, i32* %3
%17 = load i32, i32* %5
%18 = shl i32 1, %17
%19 = and i32 %16, %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = load i32, i32* %5
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = call i32 (...) @abort()
unreachable
26: ; preds = %15
br label %27
27: ; preds = %26, %9
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %6
31: ; preds = %6
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"bit %d not set in special_flags\0A\00"
define void @check_flags(i32 %0, i32 %1) {
%3 = and i32 %1, 1
%4 = icmp ne i32 %3, 0
%5 = and i32 %0, 1
%6 = icmp eq i32 %5, 0
%7 = and i1 %4, %6
br i1 %7, label %8, label %13
8: ; preds = %25, %19, %13, %2
%9 = phi i32 [ 0, %2 ], [ 1, %13 ], [ 2, %19 ], [ 3, %25 ]
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %9)
%12 = tail call i32 (...) @abort()
unreachable
13: ; preds = %2
%14 = and i32 %1, 2
%15 = icmp ne i32 %14, 0
%16 = and i32 %0, 2
%17 = icmp eq i32 %16, 0
%18 = and i1 %15, %17
br i1 %18, label %8, label %19
19: ; preds = %13
%20 = and i32 %1, 4
%21 = icmp ne i32 %20, 0
%22 = and i32 %0, 4
%23 = icmp eq i32 %22, 0
%24 = and i1 %21, %23
br i1 %24, label %8, label %25
25: ; preds = %19
%26 = and i32 %1, 8
%27 = icmp ne i32 %26, 0
%28 = and i32 %0, 8
%29 = icmp eq i32 %28, 0
%30 = and i1 %27, %29
br i1 %30, label %8, label %31
31: ; preds = %25
ret void
}