#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 */
scalar_t__ ina_status(int);
unsigned short ina_scan_status(void) {
  unsigned i;
  for (i = 3; i < 16; i++) {
    if (ina_status(0x01 << i))
      return i;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ina_scan_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x3,-0x8(%rbp)
cmpl   $0x10,-0x8(%rbp)
jae    1161 <ina_scan_status+0x51>
mov    -0x8(%rbp),%ecx
mov    $0x1,%edi
shl    %cl,%edi
call   1030 <ina_status@plt>
cmp    $0x0,%rax
je     114e <ina_scan_status+0x3e>
mov    -0x8(%rbp),%eax
mov    %ax,-0x2(%rbp)
jmp    1167 <ina_scan_status+0x57>
jmp    1153 <ina_scan_status+0x43>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    111f <ina_scan_status+0xf>
movw   $0x0,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ina_scan_status>:
push   %rax
mov    $0x8,%edi
call   1030 <ina_status@plt>
mov    %rax,%rcx
mov    $0x3,%ax
test   %rcx,%rcx
je     1129 <ina_scan_status+0x19>
pop    %rcx
ret
mov    $0x10,%edi
call   1030 <ina_status@plt>
mov    %rax,%rcx
mov    $0x4,%ax
test   %rcx,%rcx
jne    1127 <ina_scan_status+0x17>
mov    $0x20,%edi
call   1030 <ina_status@plt>
mov    %rax,%rcx
mov    $0x5,%ax
test   %rcx,%rcx
jne    1127 <ina_scan_status+0x17>
mov    $0x40,%edi
call   1030 <ina_status@plt>
mov    %rax,%rcx
mov    $0x6,%ax
test   %rcx,%rcx
jne    1127 <ina_scan_status+0x17>
mov    $0x80,%edi
call   1030 <ina_status@plt>
mov    %rax,%rcx
mov    $0x7,%ax
test   %rcx,%rcx
jne    1127 <ina_scan_status+0x17>
mov    $0x100,%edi
call   1030 <ina_status@plt>
mov    %rax,%rcx
mov    $0x8,%ax
test   %rcx,%rcx
jne    1127 <ina_scan_status+0x17>
mov    $0x200,%edi
call   1030 <ina_status@plt>
mov    %rax,%rcx
mov    $0x9,%ax
test   %rcx,%rcx
jne    1127 <ina_scan_status+0x17>
mov    $0x400,%edi
call   1030 <ina_status@plt>
mov    %rax,%rcx
mov    $0xa,%ax
test   %rcx,%rcx
jne    1127 <ina_scan_status+0x17>
mov    $0x800,%edi
call   1030 <ina_status@plt>
mov    %rax,%rcx
mov    $0xb,%ax
test   %rcx,%rcx
jne    1127 <ina_scan_status+0x17>
mov    $0x1000,%edi
call   1030 <ina_status@plt>
mov    %rax,%rcx
mov    $0xc,%ax
test   %rcx,%rcx
jne    1127 <ina_scan_status+0x17>
mov    $0x2000,%edi
call   1030 <ina_status@plt>
mov    %rax,%rcx
mov    $0xd,%ax
test   %rcx,%rcx
jne    1127 <ina_scan_status+0x17>
mov    $0x4000,%edi
call   1030 <ina_status@plt>
mov    %rax,%rcx
mov    $0xe,%ax
test   %rcx,%rcx
jne    1127 <ina_scan_status+0x17>
mov    $0x8000,%edi
call   1030 <ina_status@plt>
xor    %ecx,%ecx
test   %rax,%rax
mov    $0xf,%eax
cmove  %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define zeroext i16 @ina_scan_status() {
%1 = alloca i16
%2 = alloca i32
store i32 3, i32* %2
br label %3
3: ; preds = %15, %0
%4 = load i32, i32* %2
%5 = icmp ult i32 %4, 16
br i1 %5, label %6, label %18
6: ; preds = %3
%7 = load i32, i32* %2
%8 = shl i32 1, %7
%9 = call i64 @ina_status(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* %2
%13 = trunc i32 %12 to i16
store i16 %13, i16* %1
br label %19
14: ; preds = %6
br label %15
15: ; preds = %14
%16 = load i32, i32* %2
%17 = add i32 %16, 1
store i32 %17, i32* %2
br label %3
18: ; preds = %3
store i16 0, i16* %1
br label %19
19: ; preds = %18, %11
%20 = load i16, i16* %1
ret i16 %20
}

LLVM IR (-O2):
define zeroext i16 @ina_scan_status() {
%1 = tail call i64 @ina_status(i32 8)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %40
3: ; preds = %0
%4 = tail call i64 @ina_status(i32 16)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %40
6: ; preds = %3
%7 = tail call i64 @ina_status(i32 32)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %40
9: ; preds = %6
%10 = tail call i64 @ina_status(i32 64)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %40
12: ; preds = %9
%13 = tail call i64 @ina_status(i32 128)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %40
15: ; preds = %12
%16 = tail call i64 @ina_status(i32 256)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %40
18: ; preds = %15
%19 = tail call i64 @ina_status(i32 512)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %40
21: ; preds = %18
%22 = tail call i64 @ina_status(i32 1024)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %40
24: ; preds = %21
%25 = tail call i64 @ina_status(i32 2048)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %40
27: ; preds = %24
%28 = tail call i64 @ina_status(i32 4096)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %40
30: ; preds = %27
%31 = tail call i64 @ina_status(i32 8192)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %40
33: ; preds = %30
%34 = tail call i64 @ina_status(i32 16384)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = tail call i64 @ina_status(i32 32768)
%38 = icmp eq i64 %37, 0
%39 = select i1 %38, i16 0, i16 15
br label %40
40: ; preds = %36, %0, %3, %6, %9, %12, %15, %18, %21, %24, %27, %30, %33
%41 = phi i16 [ 3, %0 ], [ 4, %3 ], [ 5, %6 ], [ 6, %9 ], [ 7, %12 ], [ 8, %15 ], [ 9, %18 ], [ 10, %21 ], [ 11, %24 ], [ 12, %27 ], [ 13, %30 ], [ 14, %33 ], [ %39, %36 ]
ret i16 %41
}