#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 */
long evalfuns();
int /*<<< orphan*/ non_fatal(char *, char *);
scalar_t__ test(char *);
long evalmdr() {
  long temp;
  long val;
  for (val = evalfuns();;) {
    if (test("*"))
      val = val * evalfuns();
    else if (test("/")) {
      temp = evalfuns();
      if (temp == 0) {
        non_fatal("Division by zero", "");
        val = 0;
      } else
        val = val / temp;
    } else if (test("%")) {
      temp = evalfuns();
      if (temp == 0) {
        non_fatal("Division by zero", "");
        val = 0;
      } else
        val = val % temp;
    } else
      break;
  }
  return (val);
}


x86 assembly (clang, -O0):
<evalmdr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <evalfuns@plt>
mov    %rax,-0x10(%rbp)
lea    0xeb6(%rip),%rdi
call   1050 <test@plt>
cmp    $0x0,%rax
je     117c <evalmdr+0x4c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <evalfuns@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
imul   %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    1249 <evalmdr+0x119>
lea    0xe7f(%rip),%rdi
call   1050 <test@plt>
cmp    $0x0,%rax
je     11db <evalmdr+0xab>
mov    $0x0,%al
call   1030 <evalfuns@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11c8 <evalmdr+0x98>
lea    0xe55(%rip),%rdi
lea    0xe60(%rip),%rsi
call   1040 <non_fatal@plt>
movq   $0x0,-0x10(%rbp)
jmp    11d6 <evalmdr+0xa6>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x8(%rbp)
mov    %rax,-0x10(%rbp)
jmp    1244 <evalmdr+0x114>
lea    0xe33(%rip),%rdi
call   1050 <test@plt>
cmp    $0x0,%rax
je     123a <evalmdr+0x10a>
mov    $0x0,%al
call   1030 <evalfuns@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1227 <evalmdr+0xf7>
lea    0xdf6(%rip),%rdi
lea    0xe01(%rip),%rsi
call   1040 <non_fatal@plt>
movq   $0x0,-0x10(%rbp)
jmp    1235 <evalmdr+0x105>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x8(%rbp)
mov    %rdx,-0x10(%rbp)
jmp    123f <evalmdr+0x10f>
jmp    124e <evalmdr+0x11e>
jmp    1244 <evalmdr+0x114>
jmp    1249 <evalmdr+0x119>
jmp    1143 <evalmdr+0x13>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evalmdr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <evalfuns@plt>
mov    %rax,%rbp
lea    0xeb4(%rip),%rbx
lea    0xeaf(%rip),%r14
lea    0xebb(%rip),%r15
lea    0xea3(%rip),%r12
lea    0xeae(%rip),%r13
jmp    117b <evalmdr+0x4b>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <evalfuns@plt>
imul   %rax,%rbp
mov    %rbx,%rdi
call   1050 <test@plt>
test   %rax,%rax
jne    1170 <evalmdr+0x40>
mov    %r14,%rdi
call   1050 <test@plt>
test   %rax,%rax
je     11ba <evalmdr+0x8a>
xor    %eax,%eax
call   1030 <evalfuns@plt>
test   %rax,%rax
je     11ec <evalmdr+0xbc>
mov    %rax,%rcx
or     %rbp,%rax
shr    $0x20,%rax
je     11fb <evalmdr+0xcb>
mov    %rbp,%rax
cqto
idiv   %rcx
mov    %rax,%rbp
jmp    117b <evalmdr+0x4b>
mov    %r15,%rdi
call   1050 <test@plt>
test   %rax,%rax
je     1215 <evalmdr+0xe5>
xor    %eax,%eax
call   1030 <evalfuns@plt>
test   %rax,%rax
je     11ec <evalmdr+0xbc>
mov    %rax,%rcx
or     %rbp,%rax
shr    $0x20,%rax
je     1208 <evalmdr+0xd8>
mov    %rbp,%rax
cqto
idiv   %rcx
mov    %rdx,%rbp
jmp    117b <evalmdr+0x4b>
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <non_fatal@plt>
xor    %ebp,%ebp
jmp    117b <evalmdr+0x4b>
mov    %ebp,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%ebp
jmp    117b <evalmdr+0x4b>
mov    %ebp,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%ebp
jmp    117b <evalmdr+0x4b>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"*\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [17 x i8] c"Division by zero\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c"%\00"
define i64 @evalmdr() {
%1 = tail call i64 (...) @evalfuns()
br label %2
2: ; preds = %19, %0
%3 = phi i64 [ %1, %0 ], [ %20, %19 ]
%4 = tail call i64 @test(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i64 (...) @evalfuns()
%8 = mul nsw i64 %7, %3
br label %19
9: ; preds = %2
%10 = tail call i64 @test(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %9
%13 = tail call i64 (...) @evalfuns()
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @non_fatal(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %19
17: ; preds = %12
%18 = sdiv i64 %3, %13
br label %19
19: ; preds = %17, %15, %27, %29, %6
%20 = phi i64 [ %8, %6 ], [ 0, %15 ], [ %18, %17 ], [ 0, %27 ], [ %30, %29 ]
br label %2
21: ; preds = %9
%22 = tail call i64 @test(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %21
%25 = tail call i64 (...) @evalfuns()
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = tail call i32 @non_fatal(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %19
29: ; preds = %24
%30 = srem i64 %3, %25
br label %19
31: ; preds = %21
ret i64 %3
}