#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*/ compare_strings(char *, char *);
char *perform_KMG(char *);
char *perform_addsub(char *);
char *perform_exponent(char *);
char *perform_muldiv(char *);
char *solve_sub_string(char buffer[]) {
  char *string = buffer;
  do {
    buffer = string;
    string = perform_KMG(buffer);
  } while (!compare_strings(buffer, string));
  do {
    buffer = string;
    string = perform_exponent(buffer);
  } while (!compare_strings(buffer, string));
  do {
    buffer = string;
    string = perform_muldiv(buffer);
  } while (!compare_strings(buffer, string));
  do {
    buffer = string;
    string = perform_addsub(buffer);
  } while (!compare_strings(buffer, string));
  return string;
}


x86 assembly (clang, -O0):
<solve_sub_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <perform_KMG@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <compare_strings@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1164 <solve_sub_string+0x14>
jmp    119b <solve_sub_string+0x4b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <perform_exponent@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <compare_strings@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    119b <solve_sub_string+0x4b>
jmp    11d2 <solve_sub_string+0x82>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <perform_muldiv@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <compare_strings@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d2 <solve_sub_string+0x82>
jmp    1209 <solve_sub_string+0xb9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <perform_addsub@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <compare_strings@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1209 <solve_sub_string+0xb9>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve_sub_string>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%r14
mov    %rbx,%rdi
call   1030 <perform_KMG@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <compare_strings@plt>
test   %eax,%eax
je     1160 <solve_sub_string+0x10>
nopl   (%rax)
mov    %rbx,%r14
mov    %rbx,%rdi
call   1070 <perform_exponent@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <compare_strings@plt>
test   %eax,%eax
je     1180 <solve_sub_string+0x30>
nopl   (%rax)
mov    %rbx,%r14
mov    %rbx,%rdi
call   1050 <perform_muldiv@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <compare_strings@plt>
test   %eax,%eax
je     11a0 <solve_sub_string+0x50>
nopl   (%rax)
mov    %rbx,%r14
mov    %rbx,%rdi
call   1040 <perform_addsub@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <compare_strings@plt>
test   %eax,%eax
je     11c0 <solve_sub_string+0x70>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @solve_sub_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %9, %1
%6 = load i8*, i8** %3
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i8* @perform_KMG(i8* %7)
store i8* %8, i8** %3
br label %9
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = load i8*, i8** %3
%12 = call i32 @compare_strings(i8* %10, i8* %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %5, label %15
15: ; preds = %9
br label %16
16: ; preds = %20, %15
%17 = load i8*, i8** %3
store i8* %17, i8** %2
%18 = load i8*, i8** %2
%19 = call i8* @perform_exponent(i8* %18)
store i8* %19, i8** %3
br label %20
20: ; preds = %16
%21 = load i8*, i8** %2
%22 = load i8*, i8** %3
%23 = call i32 @compare_strings(i8* %21, i8* %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %16, label %26
26: ; preds = %20
br label %27
27: ; preds = %31, %26
%28 = load i8*, i8** %3
store i8* %28, i8** %2
%29 = load i8*, i8** %2
%30 = call i8* @perform_muldiv(i8* %29)
store i8* %30, i8** %3
br label %31
31: ; preds = %27
%32 = load i8*, i8** %2
%33 = load i8*, i8** %3
%34 = call i32 @compare_strings(i8* %32, i8* %33)
%35 = icmp ne i32 %34, 0
%36 = xor i1 %35, true
br i1 %36, label %27, label %37
37: ; preds = %31
br label %38
38: ; preds = %42, %37
%39 = load i8*, i8** %3
store i8* %39, i8** %2
%40 = load i8*, i8** %2
%41 = call i8* @perform_addsub(i8* %40)
store i8* %41, i8** %3
br label %42
42: ; preds = %38
%43 = load i8*, i8** %2
%44 = load i8*, i8** %3
%45 = call i32 @compare_strings(i8* %43, i8* %44)
%46 = icmp ne i32 %45, 0
%47 = xor i1 %46, true
br i1 %47, label %38, label %48
48: ; preds = %42
%49 = load i8*, i8** %3
ret i8* %49
}

LLVM IR (-O2):
define i8* @solve_sub_string(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %4, %2 ]
%4 = tail call i8* @perform_KMG(i8* %3)
%5 = tail call i32 @compare_strings(i8* %3, i8* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %2, label %7
7: ; preds = %2, %7
%8 = phi i8* [ %9, %7 ], [ %4, %2 ]
%9 = tail call i8* @perform_exponent(i8* %8)
%10 = tail call i32 @compare_strings(i8* %8, i8* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %7, label %12
12: ; preds = %7, %12
%13 = phi i8* [ %14, %12 ], [ %9, %7 ]
%14 = tail call i8* @perform_muldiv(i8* %13)
%15 = tail call i32 @compare_strings(i8* %13, i8* %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %12, label %17
17: ; preds = %12, %17
%18 = phi i8* [ %19, %17 ], [ %14, %12 ]
%19 = tail call i8* @perform_addsub(i8* %18)
%20 = tail call i32 @compare_strings(i8* %18, i8* %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %17, label %22
22: ; preds = %17
ret i8* %19
}