#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__ pow(char, int);
size_t strlen(char *);
bool if_reverse(char *s) {
  long sum = 0;
  for (size_t i = 0; i < strlen(s); ++i)
    sum += pow(s[i] - '0', 3);
  return sum % 2 == 0;
}


x86 assembly (clang, -O0):
<if_reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jae    1192 <if_reverse+0x72>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    $0x3,%esi
movsbl %al,%edi
call   1040 <pow@plt>
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113c <if_reverse+0x1c>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<if_reverse>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1191 <if_reverse+0x71>
mov    %rdi,%r14
add    $0xd0,%al
movsbl %al,%edi
mov    $0x3,%esi
call   1040 <pow@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%rax
jb     1188 <if_reverse+0x68>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r14,%rbx,1),%eax
add    $0xd0,%al
movsbl %al,%edi
mov    $0x3,%esi
call   1040 <pow@plt>
add    %rax,%r15
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbx
jb     1160 <if_reverse+0x40>
not    %r15d
and    $0x1,%r15d
jmp    1197 <if_reverse+0x77>
mov    $0x1,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @if_reverse(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
store i8* %0, i8** %2
store i64 0, i64* %3
store i64 0, i64* %4
br label %5
5: ; preds = %21, %1
%6 = load i64, i64* %4
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* %7)
%9 = icmp ult i64 %6, %8
br i1 %9, label %10, label %24
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = load i64, i64* %4
%13 = getelementptr inbounds i8, i8* %11, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = sub nsw i32 %15, 48
%17 = trunc i32 %16 to i8
%18 = call i64 @pow(i8 signext %17, i32 3)
%19 = load i64, i64* %3
%20 = add nsw i64 %19, %18
store i64 %20, i64* %3
br label %21
21: ; preds = %10
%22 = load i64, i64* %4
%23 = add i64 %22, 1
store i64 %23, i64* %4
br label %5
24: ; preds = %5
%25 = load i64, i64* %3
%26 = srem i64 %25, 2
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
ret i32 %28
}

LLVM IR (-O2):
define i32 @if_reverse(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = add i8 %2, -48
%6 = tail call i64 @pow(i8 signext %5, i32 3)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = icmp ugt i64 %7, 1
br i1 %8, label %16, label %9
9: ; preds = %16, %4
%10 = phi i64 [ %6, %4 ], [ %23, %16 ]
%11 = trunc i64 %10 to i32
%12 = and i32 %11, 1
%13 = xor i32 %12, 1
br label %14
14: ; preds = %9, %1
%15 = phi i32 [ 1, %1 ], [ %13, %9 ]
ret i32 %15
16: ; preds = %4, %16
%17 = phi i64 [ %24, %16 ], [ 1, %4 ]
%18 = phi i64 [ %23, %16 ], [ %6, %4 ]
%19 = getelementptr inbounds i8, i8* %0, i64 %17
%20 = load i8, i8* %19
%21 = add i8 %20, -48
%22 = tail call i64 @pow(i8 signext %21, i32 3)
%23 = add nsw i64 %22, %18
%24 = add nuw i64 %17, 1
%25 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%26 = icmp ult i64 %24, %25
br i1 %26, label %16, label %9
}