#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*/ log_fatal(char *);
void extractShiftMaxFromMask(unsigned long mask, unsigned *resMax,
                             unsigned *resShift) {
  unsigned shift = 0;
  if (mask == 0)
    log_fatal("your display is not true-color one");
  while ((mask & 1) == 0) {
    mask >>= 1;
    ++shift;
  }
  *resMax = mask;
  *resShift = shift;
}


x86 assembly (clang, -O0):
<extractShiftMaxFromMask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1142 <extractShiftMaxFromMask+0x32>
lea    0xec3(%rip),%rdi
call   1030 <log_fatal@plt>
jmp    1147 <extractShiftMaxFromMask+0x37>
mov    -0x8(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    1173 <extractShiftMaxFromMask+0x63>
mov    -0x8(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1147 <extractShiftMaxFromMask+0x37>
mov    -0x8(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractShiftMaxFromMask>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
test   %rdi,%rdi
je     112f <extractShiftMaxFromMask+0x1f>
xor    %eax,%eax
test   $0x1,%bl
je     113b <extractShiftMaxFromMask+0x2b>
mov    %rbx,%rcx
jmp    114e <extractShiftMaxFromMask+0x3e>
lea    0xeca(%rip),%rdi
call   1030 <log_fatal@plt>
xor    %eax,%eax
mov    %rbx,%rcx
shr    %rcx
add    $0x1,%eax
test   $0x2,%bl
mov    %rcx,%rbx
je     1140 <extractShiftMaxFromMask+0x30>
mov    %ecx,(%r15)
mov    %eax,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"your display is not true-color one\00"
define void @extractShiftMaxFromMask(i64 %0, i32* %1, i32* %2) {
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i64 %0, i64* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %7
%8 = load i64, i64* %4
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 @log_fatal(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %3
br label %13
13: ; preds = %17, %12
%14 = load i64, i64* %4
%15 = and i64 %14, 1
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i64, i64* %4
%19 = lshr i64 %18, 1
store i64 %19, i64* %4
%20 = load i32, i32* %7
%21 = add i32 %20, 1
store i32 %21, i32* %7
br label %13
22: ; preds = %13
%23 = load i64, i64* %4
%24 = trunc i64 %23 to i32
%25 = load i32*, i32** %5
store i32 %24, i32* %25
%26 = load i32, i32* %7
%27 = load i32*, i32** %6
store i32 %26, i32* %27
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"your display is not true-color one\00"
define void @extractShiftMaxFromMask(i64 %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = icmp eq i64 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @log_fatal(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %10
7: ; preds = %3
%8 = and i64 %0, 1
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %5, %7
br label %11
11: ; preds = %10, %11
%12 = phi i32 [ %15, %11 ], [ 0, %10 ]
%13 = phi i64 [ %14, %11 ], [ %0, %10 ]
%14 = lshr i64 %13, 1
%15 = add i32 %12, 1
%16 = and i64 %13, 2
%17 = icmp eq i64 %16, 0
br i1 %17, label %11, label %18
18: ; preds = %11, %7
%19 = phi i64 [ %0, %7 ], [ %14, %11 ]
%20 = phi i32 [ 0, %7 ], [ %15, %11 ]
%21 = trunc i64 %19 to i32
store i32 %21, i32* %1
store i32 %20, i32* %2
ret void
}