#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*/ printf(char *, int);
int is_binary_palindrome(int number) {
  printf("sizeof: %d\n", sizeof(int));
  int offset = -1;
  for (int i = 0; i < 8 * sizeof(int); i++) {
    if (number & (1 << i)) {
      offset = i;
    }
  }
  printf("offset: %d\n", offset);
}


x86 assembly (clang, -O0):
<is_binary_palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
lea    0xede(%rip),%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
movl   $0xffffffff,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
cmp    $0x20,%rax
jae    117b <is_binary_palindrome+0x6b>
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1168 <is_binary_palindrome+0x58>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    116d <is_binary_palindrome+0x5d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113a <is_binary_palindrome+0x2a>
mov    -0xc(%rbp),%esi
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_binary_palindrome>:
push   %rbx
mov    %edi,%ebx
lea    0xee6(%rip),%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
mov    $0xffffffff,%esi
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
bt     %eax,%ebx
cmovb  %eax,%esi
lea    0x1(%rax),%ecx
bt     %ecx,%ebx
cmovb  %ecx,%esi
lea    0x2(%rax),%ecx
bt     %ecx,%ebx
cmovb  %ecx,%esi
lea    0x3(%rax),%ecx
bt     %ecx,%ebx
cmovb  %ecx,%esi
add    $0x4,%eax
cmp    $0x20,%eax
jne    1130 <is_binary_palindrome+0x20>
lea    0xeac(%rip),%rdi
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"sizeof: %d\0A\00"
@.str.1 = [12 x i8] c"offset: %d\0A\00"
define i32 @is_binary_palindrome(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
%6 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 4)
store i32 -1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %20, %1
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %9, 32
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = load i32, i32* %3
%13 = load i32, i32* %5
%14 = shl i32 1, %13
%15 = and i32 %12, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = load i32, i32* %5
store i32 %18, i32* %4
br label %19
19: ; preds = %17, %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %7
23: ; preds = %7
%24 = load i32, i32* %4
%25 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [12 x i8] c"sizeof: %d\0A\00"
@.str.1 = [12 x i8] c"offset: %d\0A\00"
define i32 @is_binary_palindrome(i32 %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 4)
br label %5
3: ; preds = %5
%4 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %26)
ret i32 undef
5: ; preds = %5, %1
%6 = phi i32 [ 0, %1 ], [ %27, %5 ]
%7 = phi i32 [ -1, %1 ], [ %26, %5 ]
%8 = shl nuw i32 1, %6
%9 = and i32 %8, %0
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i32 %7, i32 %6
%12 = or i32 %6, 1
%13 = shl nuw i32 1, %12
%14 = and i32 %13, %0
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 %11, i32 %12
%17 = or i32 %6, 2
%18 = shl nuw i32 1, %17
%19 = and i32 %18, %0
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i32 %16, i32 %17
%22 = or i32 %6, 3
%23 = shl nuw i32 1, %22
%24 = and i32 %23, %0
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i32 %21, i32 %22
%27 = add nuw nsw i32 %6, 4
%28 = icmp eq i32 %27, 32
br i1 %28, label %3, label %5
}