#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 */
typedef int uint32_t;
typedef int int64_t;

/* Variables and functions */
int INT64_MIN;
uint32_t num_significant_bits_var2(int64_t x) {
  int64_t bound;
  uint32_t k;
  if (x < 0) {
    bound = INT64_MIN / 2;
    k = 64;
    while (bound <= x) {
      bound /= 2;
      k--;
    }
  } else {
    bound = -(INT64_MIN / 2);
    k = 64;
    while (x < bound) {
      bound /= 2;
      k--;
    }
  }
  return k;
}


x86 assembly (clang, -O0):
<num_significant_bits_var2>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1159 <num_significant_bits_var2+0x59>
mov    0x2ed0(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
movl   $0x40,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1154 <num_significant_bits_var2+0x54>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    112c <num_significant_bits_var2+0x2c>
jmp    11a7 <num_significant_bits_var2+0xa7>
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
movl   $0x40,-0xc(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a2 <num_significant_bits_var2+0xa2>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    117a <num_significant_bits_var2+0x7a>
jmp    11a7 <num_significant_bits_var2+0xa7>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_significant_bits_var2>:
mov    0x2ee1(%rip),%rax
mov    (%rax),%edx
test   %edi,%edi
js     1142 <num_significant_bits_var2+0x42>
mov    %edx,%ecx
shr    $0x1f,%ecx
add    %edx,%ecx
sar    %ecx
neg    %ecx
mov    $0x40,%eax
cmp    %edi,%ecx
jle    1160 <num_significant_bits_var2+0x60>
mov    $0x40,%eax
mov    %ecx,%edx
nopl   0x0(%rax,%rax,1)
shr    $0x1f,%edx
add    %ecx,%edx
sar    %edx
add    $0xffffffff,%eax
mov    %edx,%ecx
cmp    %edi,%edx
jg     1130 <num_significant_bits_var2+0x30>
jmp    1160 <num_significant_bits_var2+0x60>
mov    $0x41,%eax
mov    %edx,%ecx
nopl   0x0(%rax)
shr    $0x1f,%ecx
add    %edx,%ecx
sar    %ecx
add    $0xffffffff,%eax
mov    %ecx,%edx
cmp    %edi,%ecx
jle    1150 <num_significant_bits_var2+0x50>
ret

LLVM IR (-O0):
@INT64_MIN = global i32 0
define i32 @num_significant_bits_var2(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %20
7: ; preds = %1
%8 = load i32, i32* @INT64_MIN
%9 = sdiv i32 %8, 2
store i32 %9, i32* %3
store i32 64, i32* %4
br label %10
10: ; preds = %14, %7
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* %3
%16 = sdiv i32 %15, 2
store i32 %16, i32* %3
%17 = load i32, i32* %4
%18 = add nsw i32 %17, -1
store i32 %18, i32* %4
br label %10
19: ; preds = %10
br label %34
20: ; preds = %1
%21 = load i32, i32* @INT64_MIN
%22 = sdiv i32 %21, 2
%23 = sub nsw i32 0, %22
store i32 %23, i32* %3
store i32 64, i32* %4
br label %24
24: ; preds = %28, %20
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i32, i32* %3
%30 = sdiv i32 %29, 2
store i32 %30, i32* %3
%31 = load i32, i32* %4
%32 = add nsw i32 %31, -1
store i32 %32, i32* %4
br label %24
33: ; preds = %24
br label %34
34: ; preds = %33, %19
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
@INT64_MIN = global i32 0
define i32 @num_significant_bits_var2(i32 %0) {
%2 = icmp slt i32 %0, 0
%3 = load i32, i32* @INT64_MIN
br i1 %2, label %4, label %10
4: ; preds = %1, %4
%5 = phi i32 [ %7, %4 ], [ %3, %1 ]
%6 = phi i32 [ %9, %4 ], [ 64, %1 ]
%7 = sdiv i32 %5, 2
%8 = icmp sgt i32 %7, %0
%9 = add nsw i32 %6, -1
br i1 %8, label %19, label %4
10: ; preds = %1
%11 = sdiv i32 %3, -2
%12 = icmp sgt i32 %11, %0
br i1 %12, label %13, label %19
13: ; preds = %10, %13
%14 = phi i32 [ %17, %13 ], [ 64, %10 ]
%15 = phi i32 [ %16, %13 ], [ %11, %10 ]
%16 = sdiv i32 %15, 2
%17 = add nsw i32 %14, -1
%18 = icmp sgt i32 %16, %0
br i1 %18, label %13, label %19
19: ; preds = %13, %4, %10
%20 = phi i32 [ 64, %10 ], [ %6, %4 ], [ %17, %13 ]
ret i32 %20
}