#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 test(int flag) {
  if (flag & 1)
    printf("UP\n");
  if (flag & (1 << 1))
    printf("DOWN\n");
  if (flag & (1 << 2))
    printf("LEFT\n");
  if (flag & (1 << 3))
    printf("RIGHT\n");
  printf("%d\n-----\n", flag);
  return (flag);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1138 <test+0x28>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1155 <test+0x45>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1172 <test+0x62>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     118f <test+0x7f>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbx
mov    %edi,%ebx
test   $0x1,%bl
jne    1157 <test+0x37>
test   $0x2,%bl
jne    1168 <test+0x48>
test   $0x4,%bl
jne    1179 <test+0x59>
test   $0x8,%bl
je     1143 <test+0x23>
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb6(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
test   $0x2,%bl
je     112d <test+0xd>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
test   $0x4,%bl
je     1132 <test+0x12>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
test   $0x8,%bl
jne    1137 <test+0x17>
jmp    1143 <test+0x23>

LLVM IR (-O0):
@.str = [4 x i8] c"UP\0A\00"
@.str.1 = [6 x i8] c"DOWN\0A\00"
@.str.2 = [6 x i8] c"LEFT\0A\00"
@.str.3 = [7 x i8] c"RIGHT\0A\00"
@.str.4 = [10 x i8] c"%d\0A-----\0A\00"
define i32 @test(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = and i32 %3, 1
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = load i32, i32* %2
%10 = and i32 %9, 2
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %8
%15 = load i32, i32* %2
%16 = and i32 %15, 4
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = load i32, i32* %2
%22 = and i32 %21, 8
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
%27 = load i32, i32* %2
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str.4 = [10 x i8] c"%d\0A-----\0A\00"
@str = [6 x i8] c"RIGHT\00"
@str.5 = [5 x i8] c"LEFT\00"
@str.6 = [5 x i8] c"DOWN\00"
@str.7 = [3 x i8] c"UP\00"
define i32 @test(i32 returned %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.7, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = and i32 %0, 2
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.6, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = and i32 %0, 4
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.5, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = and i32 %0, 8
%18 = icmp eq i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %0)
ret i32 %0
}