#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 *);
int find_character(char *, char);
char *perform_operation(char *, char);
char *perform_muldiv(char buffer[]) {
  char *string = buffer;
  int first_mul, first_div;
  do {
    buffer = string;
    first_mul = find_character(buffer, '*');
    first_div = find_character(buffer, '/');
    if ((first_mul == -1) && (first_div == -1))
      break;
    if (first_mul == -1)
      string = perform_operation(buffer, '/');
    else if (first_div == -1)
      string = perform_operation(buffer, '*');
    else if (first_mul < first_div)
      string = perform_operation(buffer, '*');
    else
      string = perform_operation(buffer, '/');
  } while (!compare_strings(buffer, string));
  return string;
}


x86 assembly (clang, -O0):
<perform_muldiv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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
mov    $0x2a,%esi
call   1030 <find_character@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <find_character@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1187 <perform_muldiv+0x57>
cmpl   $0xffffffff,-0x18(%rbp)
jne    1187 <perform_muldiv+0x57>
jmp    122a <perform_muldiv+0xfa>
cmpl   $0xffffffff,-0x14(%rbp)
jne    11a8 <perform_muldiv+0x78>
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <perform_operation@plt>
mov    %rax,-0x10(%rbp)
jmp    1208 <perform_muldiv+0xd8>
cmpl   $0xffffffff,-0x18(%rbp)
jne    11c9 <perform_muldiv+0x99>
mov    -0x8(%rbp),%rdi
mov    $0x2a,%esi
call   1040 <perform_operation@plt>
mov    %rax,-0x10(%rbp)
jmp    1203 <perform_muldiv+0xd3>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11ec <perform_muldiv+0xbc>
mov    -0x8(%rbp),%rdi
mov    $0x2a,%esi
call   1040 <perform_operation@plt>
mov    %rax,-0x10(%rbp)
jmp    11fe <perform_muldiv+0xce>
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <perform_operation@plt>
mov    %rax,-0x10(%rbp)
jmp    1203 <perform_muldiv+0xd3>
jmp    1208 <perform_muldiv+0xd8>
jmp    120d <perform_muldiv+0xdd>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <compare_strings@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1144 <perform_muldiv+0x14>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perform_muldiv>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
jmp    1183 <perform_muldiv+0x53>
nopl   0x0(%rax)
xor    %ecx,%ecx
cmp    $0xffffffff,%ebp
sete   %cl
xor    %edx,%edx
cmp    %eax,%ebp
setge  %dl
cmp    $0xffffffff,%eax
lea    0x2a(%rcx,%rcx,4),%eax
lea    0x2a(%rdx,%rdx,4),%ecx
cmove  %eax,%ecx
cmp    $0xffffffff,%ebp
cmove  %eax,%ecx
movzbl %cl,%esi
mov    %r14,%rdi
call   1040 <perform_operation@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <compare_strings@plt>
mov    %rbx,%r14
test   %eax,%eax
jne    11ac <perform_muldiv+0x7c>
mov    %r14,%rdi
mov    $0x2a,%esi
call   1030 <find_character@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    $0x2f,%esi
call   1030 <find_character@plt>
cmp    $0xffffffff,%ebp
jne    1140 <perform_muldiv+0x10>
cmp    $0xffffffff,%eax
jne    1140 <perform_muldiv+0x10>
mov    %r14,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @perform_muldiv(i8* %0) {
br label %2
2: ; preds = %9, %1
%3 = phi i8* [ %0, %1 ], [ %15, %9 ]
%4 = tail call i32 @find_character(i8* %3, i8 signext 42)
%5 = tail call i32 @find_character(i8* %3, i8 signext 47)
%6 = icmp eq i32 %4, -1
%7 = icmp eq i32 %5, -1
%8 = select i1 %6, i1 %7, i1 false
br i1 %8, label %18, label %9
9: ; preds = %2
%10 = select i1 %6, i1 true, i1 %7
%11 = select i1 %6, i8 47, i8 42
%12 = icmp slt i32 %4, %5
%13 = select i1 %12, i8 42, i8 47
%14 = select i1 %10, i8 %11, i8 %13
%15 = tail call i8* @perform_operation(i8* %3, i8 signext %14)
%16 = tail call i32 @compare_strings(i8* %3, i8* %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %2, label %18
18: ; preds = %2, %9
%19 = phi i8* [ %3, %2 ], [ %15, %9 ]
ret i8* %19
}