#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*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
void print_flags(int f) {
  int i;
  static char fn[] = "CDZSBOIU";
  printf("%d.", (f >> 12) & 7);
  for (i = 7; i >= 0; i--)
    if (f & (1 << i))
      putchar(fn[i]);
}


x86 assembly (clang, -O0):
<print_flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
sar    $0xc,%esi
and    $0x7,%esi
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
movl   $0x7,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1192 <print_flags+0x72>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     117f <print_flags+0x5f>
movslq -0x8(%rbp),%rcx
lea    0x2eba(%rip),%rax
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
jmp    1184 <print_flags+0x64>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1147 <print_flags+0x27>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_flags>:
push   %rbx
mov    %edi,%ebx
mov    %edi,%esi
shr    $0xc,%esi
and    $0x7,%esi
lea    0xece(%rip),%rdi
call   1040 <printf@plt>
test   $0x80,%bl
jne    1161 <print_flags+0x41>
test   $0x40,%bl
jne    1170 <print_flags+0x50>
test   $0x20,%bl
jne    117f <print_flags+0x5f>
test   $0x10,%bl
jne    118e <print_flags+0x6e>
test   $0x8,%bl
jne    119d <print_flags+0x7d>
test   $0x4,%bl
jne    11ac <print_flags+0x8c>
test   $0x2,%bl
jne    11bb <print_flags+0x9b>
test   $0x1,%bl
jne    11ca <print_flags+0xaa>
pop    %rbx
ret
mov    $0x55,%edi
call   1030 <putchar@plt>
test   $0x40,%bl
je     1141 <print_flags+0x21>
mov    $0x49,%edi
call   1030 <putchar@plt>
test   $0x20,%bl
je     1146 <print_flags+0x26>
mov    $0x4f,%edi
call   1030 <putchar@plt>
test   $0x10,%bl
je     114b <print_flags+0x2b>
mov    $0x42,%edi
call   1030 <putchar@plt>
test   $0x8,%bl
je     1150 <print_flags+0x30>
mov    $0x53,%edi
call   1030 <putchar@plt>
test   $0x4,%bl
je     1155 <print_flags+0x35>
mov    $0x5a,%edi
call   1030 <putchar@plt>
test   $0x2,%bl
je     115a <print_flags+0x3a>
mov    $0x44,%edi
call   1030 <putchar@plt>
test   $0x1,%bl
je     115f <print_flags+0x3f>
mov    $0x43,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@print_flags.fn = internal global [9 x i8] c"CDZSBOIU\00"
@.str = [4 x i8] c"%d.\00"
define void @print_flags(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = ashr i32 %4, 12
%6 = and i32 %5, 7
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 7, i32* %3
br label %8
8: ; preds = %24, %1
%9 = load i32, i32* %3
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %8
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = shl i32 1, %13
%15 = and i32 %12, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [9 x i8], [9 x i8]* @print_flags.fn, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @putchar(i8 signext %21)
br label %23
23: ; preds = %17, %11
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = add nsw i32 %25, -1
store i32 %26, i32* %3
br label %8
27: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d.\00"
define void @print_flags(i32 %0) {
%2 = lshr i32 %0, 12
%3 = and i32 %2, 7
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = and i32 %0, 128
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = tail call i32 @putchar(i8 signext 85)
br label %9
9: ; preds = %1, %7
%10 = and i32 %0, 64
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @putchar(i8 signext 73)
br label %14
14: ; preds = %12, %9
%15 = and i32 %0, 32
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 @putchar(i8 signext 79)
br label %19
19: ; preds = %17, %14
%20 = and i32 %0, 16
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @putchar(i8 signext 66)
br label %24
24: ; preds = %22, %19
%25 = and i32 %0, 8
%26 = icmp eq i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = tail call i32 @putchar(i8 signext 83)
br label %29
29: ; preds = %27, %24
%30 = and i32 %0, 4
%31 = icmp eq i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = tail call i32 @putchar(i8 signext 90)
br label %34
34: ; preds = %32, %29
%35 = and i32 %0, 2
%36 = icmp eq i32 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = tail call i32 @putchar(i8 signext 68)
br label %39
39: ; preds = %37, %34
%40 = and i32 %0, 1
%41 = icmp eq i32 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = tail call i32 @putchar(i8 signext 67)
br label %44
44: ; preds = %42, %39
ret void
}