#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 */
typedef int /*<<< orphan*/ flag_list;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_flags(int flags) {
  static char *flag_list[] = {
      "MOVE",
      "CASE",
      "CTRL",
      "KEEP",
  };
  unsigned int i;
  for (i = 0; i < (sizeof(flag_list) / sizeof(*flag_list)); i++) {
    if (i > 0)
      printf(", ");
    if (!(flags & (1 << i)))
      printf("NO");
    printf("%s(%d)", flag_list[i], 1 << i);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    $0x4,%rax
jae    11a5 <print_flags+0x95>
cmpl   $0x0,-0x8(%rbp)
jbe    1147 <print_flags+0x37>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
jne    116f <print_flags+0x5f>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
lea    0x2eb5(%rip),%rax
mov    (%rax,%rcx,8),%rsi
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <print_flags+0x12>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_flags>:
push   %rbx
mov    %edi,%ebx
test   $0x1,%bl
jne    1136 <print_flags+0x16>
lea    0xee8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xedd(%rip),%rdi
lea    0xebc(%rip),%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x2,%bl
jne    1171 <print_flags+0x51>
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea2(%rip),%rdi
lea    0xe86(%rip),%rsi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x4,%bl
jne    11ac <print_flags+0x8c>
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe67(%rip),%rdi
lea    0xe50(%rip),%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe47(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x8,%bl
jne    11e7 <print_flags+0xc7>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe2c(%rip),%rdi
lea    0xe1a(%rip),%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@print_flags.flag_list = internal global [4 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0)]
@.str = [5 x i8] c"MOVE\00"
@.str.1 = [5 x i8] c"CASE\00"
@.str.2 = [5 x i8] c"CTRL\00"
@.str.3 = [5 x i8] c"KEEP\00"
@.str.4 = [3 x i8] c", \00"
@.str.5 = [3 x i8] c"NO\00"
@.str.6 = [7 x i8] c"%s(%d)\00"
@.str.7 = [2 x i8] c"\0A\00"
define void @print_flags(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %29, %1
%5 = load i32, i32* %3
%6 = zext i32 %5 to i64
%7 = icmp ult i64 %6, 4
br i1 %7, label %8, label %32
8: ; preds = %4
%9 = load i32, i32* %3
%10 = icmp ugt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = shl i32 1, %15
%17 = and i32 %14, %16
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %21
21: ; preds = %19, %13
%22 = load i32, i32* %3
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds [4 x i8*], [4 x i8*]* @print_flags.flag_list, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = load i32, i32* %3
%27 = shl i32 1, %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %25, i32 %27)
br label %29
29: ; preds = %21
%30 = load i32, i32* %3
%31 = add i32 %30, 1
store i32 %31, i32* %3
br label %4
32: ; preds = %4
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"MOVE\00"
@.str.1 = [5 x i8] c"CASE\00"
@.str.2 = [5 x i8] c"CTRL\00"
@.str.3 = [5 x i8] c"KEEP\00"
@.str.4 = [3 x i8] c", \00"
@.str.5 = [3 x i8] c"NO\00"
@.str.6 = [7 x i8] c"%s(%d)\00"
define void @print_flags(i32 %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 1)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%9 = and i32 %0, 2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 2)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%16 = and i32 %0, 4
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %20
20: ; preds = %18, %13
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%23 = and i32 %0, 8
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %27
27: ; preds = %25, %20
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 8)
%29 = tail call i32 @putchar(i32 10)
ret void
}