#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 */
typedef int ssize_t;

/* Variables and functions */
int accept_any(char const **, char *);
char *parse_unary(char const *, int *);
const char *parse_muldiv(const char *p, ssize_t *value) {
  if ((p = parse_unary(p, value))) {
    int op;
    ssize_t rhs;
    while ((op = accept_any(&p, "*/")) && (p = parse_unary(p, &rhs)))
      *value = (op == '*') ? (*value * rhs / 8) : 8 * *value / rhs;
  }
  return p;
}


x86 assembly (clang, -O0):
<parse_muldiv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <parse_unary@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     11e5 <parse_muldiv+0xc5>
jmp    1150 <parse_muldiv+0x30>
lea    -0x8(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1040 <accept_any@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     118e <parse_muldiv+0x6e>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <parse_unary@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    119e <parse_muldiv+0x7e>
jmp    11e0 <parse_muldiv+0xc0>
cmpl   $0x2a,-0x14(%rbp)
jne    11c2 <parse_muldiv+0xa2>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
imul   -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
jmp    11d2 <parse_muldiv+0xb2>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shl    $0x3,%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1150 <parse_muldiv+0x30>
jmp    11e5 <parse_muldiv+0xc5>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_muldiv>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
call   1030 <parse_unary@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     11c1 <parse_muldiv+0xa1>
lea    0xeb8(%rip),%rsi
mov    %rsp,%rdi
call   1040 <accept_any@plt>
test   %eax,%eax
je     11bb <parse_muldiv+0x9b>
mov    %eax,%ebp
lea    0xc(%rsp),%r14
lea    0xe9e(%rip),%r15
mov    %rsp,%r12
jmp    118d <parse_muldiv+0x6d>
nopw   0x0(%rax,%rax,1)
shl    $0x3,%ecx
mov    %ecx,%eax
cltd
idivl  0xc(%rsp)
mov    %eax,(%rbx)
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <accept_any@plt>
mov    %eax,%ebp
test   %eax,%eax
je     11bb <parse_muldiv+0x9b>
mov    (%rsp),%rdi
mov    %r14,%rsi
call   1030 <parse_unary@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     11bb <parse_muldiv+0x9b>
mov    (%rbx),%ecx
cmp    $0x2a,%ebp
jne    1170 <parse_muldiv+0x50>
imul   0xc(%rsp),%ecx
lea    0x7(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
sar    $0x3,%eax
jmp    117a <parse_muldiv+0x5a>
mov    (%rsp),%rax
jmp    11c3 <parse_muldiv+0xa3>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"*/\00"
define i8* @parse_muldiv(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%7 = load i8*, i8** %3
%8 = load i32*, i32** %4
%9 = call i8* @parse_unary(i8* %7, i32* %8)
store i8* %9, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %40
11: ; preds = %2
br label %12
12: ; preds = %36, %11
%13 = call i32 @accept_any(i8** %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %5
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = call i8* @parse_unary(i8* %16, i32* %6)
store i8* %17, i8** %3
%18 = icmp ne i8* %17, null
br label %19
19: ; preds = %15, %12
%20 = phi i1 [ false, %12 ], [ %18, %15 ]
br i1 %20, label %21, label %39
21: ; preds = %19
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 42
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load i32*, i32** %4
%26 = load i32, i32* %25
%27 = load i32, i32* %6
%28 = mul nsw i32 %26, %27
%29 = sdiv i32 %28, 8
br label %36
30: ; preds = %21
%31 = load i32*, i32** %4
%32 = load i32, i32* %31
%33 = mul nsw i32 8, %32
%34 = load i32, i32* %6
%35 = sdiv i32 %33, %34
br label %36
36: ; preds = %30, %24
%37 = phi i32 [ %29, %24 ], [ %35, %30 ]
%38 = load i32*, i32** %4
store i32 %37, i32* %38
br label %12
39: ; preds = %19
br label %40
40: ; preds = %39, %2
%41 = load i8*, i8** %3
ret i8* %41
}

LLVM IR (-O2):
@.str = [3 x i8] c"*/\00"
define i8* @parse_muldiv(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = tail call i8* @parse_unary(i8* %0, i32* %1)
store i8* %5, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %33, label %7
7: ; preds = %2
%8 = bitcast i32* %4 to i8*
%9 = call i32 @accept_any(i8** %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %31, label %11
11: ; preds = %7, %27
%12 = phi i32 [ %29, %27 ], [ %9, %7 ]
%13 = load i8*, i8** %3
%14 = call i8* @parse_unary(i8* %13, i32* %4)
store i8* %14, i8** %3
%15 = icmp eq i8* %14, null
br i1 %15, label %31, label %16
16: ; preds = %11
%17 = icmp eq i32 %12, 42
%18 = load i32, i32* %1
br i1 %17, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* %4
%21 = mul nsw i32 %20, %18
%22 = sdiv i32 %21, 8
br label %27
23: ; preds = %16
%24 = shl nsw i32 %18, 3
%25 = load i32, i32* %4
%26 = sdiv i32 %24, %25
br label %27
27: ; preds = %23, %19
%28 = phi i32 [ %22, %19 ], [ %26, %23 ]
store i32 %28, i32* %1
%29 = call i32 @accept_any(i8** %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %11
31: ; preds = %11, %27, %7
%32 = load i8*, i8** %3
br label %33
33: ; preds = %31, %2
%34 = phi i8* [ %32, %31 ], [ null, %2 ]
ret i8* %34
}