#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*/ drp_set(int, int);
unsigned long drp_value(int);
int drp_explain() {
  unsigned long val = drp_value(6);
  drp_set(0x0, 6);
  if (val & 0x01) {
    return 0;
  } else if (val & 0x02) {
    return 1;
  } else if (val & 0x04) {
    return 2;
  } else if (val & 0x08) {
    return 3;
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<drp_explain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x6,%edi
call   1030 <drp_value@plt>
mov    %rax,-0x10(%rbp)
xor    %edi,%edi
mov    $0x6,%esi
call   1040 <drp_set@plt>
mov    -0x10(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1160 <drp_explain+0x40>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <drp_explain+0xa1>
mov    -0x10(%rbp),%rax
and    $0x2,%rax
cmp    $0x0,%rax
je     117e <drp_explain+0x5e>
movl   $0x1,-0x4(%rbp)
jmp    11c1 <drp_explain+0xa1>
mov    -0x10(%rbp),%rax
and    $0x4,%rax
cmp    $0x0,%rax
je     119c <drp_explain+0x7c>
movl   $0x2,-0x4(%rbp)
jmp    11c1 <drp_explain+0xa1>
mov    -0x10(%rbp),%rax
and    $0x8,%rax
cmp    $0x0,%rax
je     11ba <drp_explain+0x9a>
movl   $0x3,-0x4(%rbp)
jmp    11c1 <drp_explain+0xa1>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drp_explain>:
push   %rbp
push   %rbx
push   %rax
mov    $0x6,%edi
call   1030 <drp_value@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
xor    %edi,%edi
mov    $0x6,%esi
call   1040 <drp_set@plt>
test   $0x1,%bl
jne    1163 <drp_explain+0x43>
mov    $0x1,%ebp
test   $0x2,%bl
jne    1163 <drp_explain+0x43>
mov    $0x2,%ebp
test   $0x4,%bl
jne    1163 <drp_explain+0x43>
and    $0x8,%ebx
cmp    $0x1,%rbx
sbb    %ebp,%ebp
or     $0x3,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @drp_explain() {
%1 = alloca i32
%2 = alloca i64
%3 = call i64 @drp_value(i32 6)
store i64 %3, i64* %2
%4 = call i32 @drp_set(i32 0, i32 6)
%5 = load i64, i64* %2
%6 = and i64 %5, 1
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 0, i32* %1
br label %25
9: ; preds = %0
%10 = load i64, i64* %2
%11 = and i64 %10, 2
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 1, i32* %1
br label %25
14: ; preds = %9
%15 = load i64, i64* %2
%16 = and i64 %15, 4
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 2, i32* %1
br label %25
19: ; preds = %14
%20 = load i64, i64* %2
%21 = and i64 %20, 8
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 3, i32* %1
br label %25
24: ; preds = %19
store i32 -1, i32* %1
br label %25
25: ; preds = %24, %23, %18, %13, %8
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
define i32 @drp_explain() {
%1 = tail call i64 @drp_value(i32 6)
%2 = tail call i32 @drp_set(i32 0, i32 6)
%3 = and i64 %1, 1
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %0
%6 = and i64 %1, 2
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = and i64 %1, 4
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = and i64 %1, 8
%13 = icmp eq i64 %12, 0
%14 = select i1 %13, i32 -1, i32 3
br label %15
15: ; preds = %11, %8, %5, %0
%16 = phi i32 [ 0, %0 ], [ 1, %5 ], [ 2, %8 ], [ %14, %11 ]
ret i32 %16
}