#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*/ gets(char *);
int load(int, char);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main() {
  char str[100];
  int i = 0, t, flag = 1, n, sumrt, sumlt;
  gets(str);
  n = strlen(str) - 1;
  while (str[i] != '\0') {
    sumrt = 0;
    sumlt = 0;
    t = i - 1;
    while (t >= 0) {
      sumlt = sumlt + load((i - t), str[t]);
      t--;
    }
    t = i + 1;
    while (t <= n) {
      sumrt = sumrt + load((t - i), str[t]);
      t++;
    }
    if (sumlt == sumrt) {
      printf("%c is balance from both sides with Balance factor %d\n", str[i],
             sumrt);
      flag = 0;
    }
    i++;
  }
  if (flag = 1) {
    printf("No Such word found!");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x1,-0x7c(%rbp)
lea    -0x70(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x80(%rbp)
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1286 <main+0x146>
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
mov    -0x74(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x78(%rbp)
cmpl   $0x0,-0x78(%rbp)
jl     11ef <main+0xaf>
mov    -0x88(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x74(%rbp),%edi
sub    -0x78(%rbp),%edi
movslq -0x78(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
call   1060 <load@plt>
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x88(%rbp)
mov    -0x78(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x78(%rbp)
jmp    11a7 <main+0x67>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x80(%rbp),%eax
jg     1242 <main+0x102>
mov    -0x84(%rbp),%eax
mov    %eax,-0x90(%rbp)
mov    -0x78(%rbp),%edi
sub    -0x74(%rbp),%edi
movslq -0x78(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
call   1060 <load@plt>
mov    %eax,%ecx
mov    -0x90(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x84(%rbp)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    11f8 <main+0xb8>
mov    -0x88(%rbp),%eax
cmp    -0x84(%rbp),%eax
jne    1278 <main+0x138>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
mov    -0x84(%rbp),%edx
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x7c(%rbp)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1178 <main+0x38>
movl   $0x1,-0x7c(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    129c <main+0x15c>
jmp    12aa <main+0x16a>
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1050 <gets@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,0x4(%rsp)
cmpb   $0x0,0x10(%rsp)
je     125c <main+0x11c>
mov    0x4(%rsp),%r13d
mov    $0x1,%r15d
xor    %eax,%eax
mov    %rax,0x8(%rsp)
jmp    11ac <main+0x6c>
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%r15
add    $0x1,%r15
add    $0xffffffffffffffff,%r13
cmpb   $0x0,0x1(%r12)
lea    0x1(%r12),%r12
je     125c <main+0x11c>
mov    $0x0,%r14d
cmpq   $0x0,0x8(%rsp)
je     11ef <main+0xaf>
xor    %r14d,%r14d
mov    $0x1,%ebx
mov    %r15,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x2(%rbp),%eax
movsbl 0x10(%rsp,%rax,1),%esi
mov    %ebx,%edi
call   1060 <load@plt>
add    %eax,%r14d
add    $0xffffffffffffffff,%rbp
add    $0x1,%ebx
cmp    $0x1,%rbp
jg     11d0 <main+0x90>
mov    %r15,%rbp
mov    0x8(%rsp),%rax
add    $0x1,%rax
xor    %r15d,%r15d
mov    %rax,0x8(%rsp)
cmp    %eax,0x4(%rsp)
jle    1238 <main+0xf8>
xor    %r15d,%r15d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%r12,%rbx,1),%esi
mov    %ebx,%edi
call   1060 <load@plt>
add    %eax,%r15d
add    $0x1,%rbx
cmp    %ebx,%r13d
jne    1220 <main+0xe0>
cmp    %r15d,%r14d
jne    1190 <main+0x50>
movsbl (%r12),%esi
lea    0xdb3(%rip),%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1190 <main+0x50>
lea    0xdd3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [54 x i8] c"%c is balance from both sides with Balance factor %d\0A\00"
@.str.1 = [20 x i8] c"No Such word found!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 1, i32* %5
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %6
br label %14
14: ; preds = %72, %0
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %75
21: ; preds = %14
store i32 0, i32* %7
store i32 0, i32* %8
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 1
store i32 %23, i32* %4
br label %24
24: ; preds = %27, %21
%25 = load i32, i32* %4
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %40
27: ; preds = %24
%28 = load i32, i32* %8
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = sub nsw i32 %29, %30
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = call i32 @load(i32 %31, i8 signext %35)
%37 = add nsw i32 %28, %36
store i32 %37, i32* %8
%38 = load i32, i32* %4
%39 = add nsw i32 %38, -1
store i32 %39, i32* %4
br label %24
40: ; preds = %24
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %43
43: ; preds = %47, %40
%44 = load i32, i32* %4
%45 = load i32, i32* %6
%46 = icmp sle i32 %44, %45
br i1 %46, label %47, label %60
47: ; preds = %43
%48 = load i32, i32* %7
%49 = load i32, i32* %4
%50 = load i32, i32* %3
%51 = sub nsw i32 %49, %50
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = call i32 @load(i32 %51, i8 signext %55)
%57 = add nsw i32 %48, %56
store i32 %57, i32* %7
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
br label %43
60: ; preds = %43
%61 = load i32, i32* %8
%62 = load i32, i32* %7
%63 = icmp eq i32 %61, %62
br i1 %63, label %64, label %72
64: ; preds = %60
%65 = load i32, i32* %3
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %66
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = load i32, i32* %7
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %69, i32 %70)
store i32 0, i32* %5
br label %72
72: ; preds = %64, %60
%73 = load i32, i32* %3
%74 = add nsw i32 %73, 1
store i32 %74, i32* %3
br label %14
75: ; preds = %14
store i32 1, i32* %5
br i1 true, label %76, label %78
76: ; preds = %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %78
78: ; preds = %76, %75
ret i32 0
}

LLVM IR (-O2):
@.str = [54 x i8] c"%c is balance from both sides with Balance factor %d\0A\00"
@.str.1 = [20 x i8] c"No Such word found!\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @gets(i8* %2)
%4 = call i32 @strlen(i8* %2)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
br i1 %6, label %55, label %7
7: ; preds = %0, %50
%8 = phi i64 [ %54, %50 ], [ 1, %0 ]
%9 = phi i64 [ %28, %50 ], [ 0, %0 ]
%10 = phi i8* [ %51, %50 ], [ %2, %0 ]
%11 = icmp eq i64 %9, 0
br i1 %11, label %26, label %12
12: ; preds = %7
%13 = trunc i64 %9 to i32
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ %9, %12 ], [ %17, %14 ]
%16 = phi i32 [ 0, %12 ], [ %24, %14 ]
%17 = add nsw i64 %15, -1
%18 = trunc i64 %17 to i32
%19 = sub nsw i32 %13, %18
%20 = and i64 %17, 4294967295
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = call i32 @load(i32 %19, i8 signext %22)
%24 = add nsw i32 %23, %16
%25 = icmp sgt i64 %15, 1
br i1 %25, label %14, label %26
26: ; preds = %14, %7
%27 = phi i32 [ 0, %7 ], [ %24, %14 ]
%28 = add nuw i64 %9, 1
%29 = trunc i64 %28 to i32
%30 = icmp sgt i32 %4, %29
br i1 %30, label %31, label %43
31: ; preds = %26, %31
%32 = phi i64 [ %40, %31 ], [ %8, %26 ]
%33 = phi i32 [ %39, %31 ], [ 0, %26 ]
%34 = sub nuw nsw i64 %32, %9
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %32
%36 = load i8, i8* %35
%37 = trunc i64 %34 to i32
%38 = call i32 @load(i32 %37, i8 signext %36)
%39 = add nsw i32 %38, %33
%40 = add i64 %32, 1
%41 = trunc i64 %40 to i32
%42 = icmp eq i32 %4, %41
br i1 %42, label %43, label %31
43: ; preds = %31, %26
%44 = phi i32 [ 0, %26 ], [ %39, %31 ]
%45 = icmp eq i32 %27, %44
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = load i8, i8* %10
%48 = sext i8 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %48, i32 %27)
br label %50
50: ; preds = %46, %43
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %28
%52 = load i8, i8* %51
%53 = icmp eq i8 %52, 0
%54 = add nuw i64 %8, 1
br i1 %53, label %55, label %7
55: ; preds = %50, %0
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}