#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 */
char getBit(unsigned int *, int);
int getLCPwithBitsAfterLCP(unsigned int *first, unsigned int *second,
                           char *bit1, char *bit2) {
  int b = 0;
  unsigned int diff = (*first) ^ (*second);
  unsigned int firstone = (unsigned int)(1 << (32 - 1));
  for (; diff != 0; diff = diff << 1) {
    if (diff & (firstone)) {
      *bit1 = getBit(first, b);
      *bit2 = getBit(second, b);
      return b;
    }
    b++;
  }
  return 32;
}


x86 assembly (clang, -O0):
<getLCPwithBitsAfterLCP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
xor    (%rcx),%eax
mov    %eax,-0x30(%rbp)
movl   $0x80000000,-0x34(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     11a8 <getLCPwithBitsAfterLCP+0x98>
mov    -0x30(%rbp),%eax
and    -0x34(%rbp),%eax
cmp    $0x0,%eax
je     1191 <getLCPwithBitsAfterLCP+0x81>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1030 <getBit@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1030 <getBit@plt>
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11af <getLCPwithBitsAfterLCP+0x9f>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1145 <getLCPwithBitsAfterLCP+0x35>
movl   $0x20,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLCPwithBitsAfterLCP>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%eax
xor    (%rdi),%eax
je     1140 <getLCPwithBitsAfterLCP+0x30>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
test   %eax,%eax
js     1147 <getLCPwithBitsAfterLCP+0x37>
add    $0x1,%ebp
lea    (%rax,%rax,1),%ecx
test   %eax,%eax
mov    %ecx,%eax
jne    1130 <getLCPwithBitsAfterLCP+0x20>
mov    $0x20,%ebp
jmp    115e <getLCPwithBitsAfterLCP+0x4e>
mov    %ebp,%esi
call   1030 <getBit@plt>
mov    %al,(%r15)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <getBit@plt>
mov    %al,(%r14)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getLCPwithBitsAfterLCP(i32* %0, i32* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 0, i32* %10
%13 = load i32*, i32** %6
%14 = load i32, i32* %13
%15 = load i32*, i32** %7
%16 = load i32, i32* %15
%17 = xor i32 %14, %16
store i32 %17, i32* %11
store i32 -2147483648, i32* %12
br label %18
18: ; preds = %39, %4
%19 = load i32, i32* %11
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %42
21: ; preds = %18
%22 = load i32, i32* %11
%23 = load i32, i32* %12
%24 = and i32 %22, %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %36
26: ; preds = %21
%27 = load i32*, i32** %6
%28 = load i32, i32* %10
%29 = call signext i8 @getBit(i32* %27, i32 %28)
%30 = load i8*, i8** %8
store i8 %29, i8* %30
%31 = load i32*, i32** %7
%32 = load i32, i32* %10
%33 = call signext i8 @getBit(i32* %31, i32 %32)
%34 = load i8*, i8** %9
store i8 %33, i8* %34
%35 = load i32, i32* %10
store i32 %35, i32* %5
br label %43
36: ; preds = %21
%37 = load i32, i32* %10
%38 = add nsw i32 %37, 1
store i32 %38, i32* %10
br label %39
39: ; preds = %36
%40 = load i32, i32* %11
%41 = shl i32 %40, 1
store i32 %41, i32* %11
br label %18
42: ; preds = %18
store i32 32, i32* %5
br label %43
43: ; preds = %42, %26
%44 = load i32, i32* %5
ret i32 %44
}

LLVM IR (-O2):
define i32 @getLCPwithBitsAfterLCP(i32* %0, i32* %1, i8* nocapture writeonly %2, i8* nocapture writeonly %3) {
%5 = load i32, i32* %0
%6 = load i32, i32* %1
%7 = xor i32 %6, %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %20, label %9
9: ; preds = %4, %16
%10 = phi i32 [ %18, %16 ], [ %7, %4 ]
%11 = phi i32 [ %17, %16 ], [ 0, %4 ]
%12 = icmp sgt i32 %10, -1
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = tail call signext i8 @getBit(i32* %0, i32 %11)
store i8 %14, i8* %2
%15 = tail call signext i8 @getBit(i32* %1, i32 %11)
store i8 %15, i8* %3
br label %20
16: ; preds = %9
%17 = add nuw nsw i32 %11, 1
%18 = shl nuw i32 %10, 1
%19 = icmp eq i32 %10, 0
br i1 %19, label %20, label %9
20: ; preds = %16, %4, %13
%21 = phi i32 [ %11, %13 ], [ 32, %4 ], [ 32, %16 ]
ret i32 %21
}