#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 */
scalar_t__ convertedTermValueExceedsMaximumFrequency(int, char *);
int /*<<< orphan*/ showBadNumeralStringMessage(char *);
int /*<<< orphan*/ showTermExceedsMaximumValueMessage(char *);
int /*<<< orphan*/ showViolatesModernConventionMessage(char *);
int checkConvertedTermValue(int convertedTermValue, int currentTotal,
                            char *numeralString) {
  if (convertedTermValue < 0) {
    showBadNumeralStringMessage(numeralString);
    return 0;
  }
  if (convertedTermValueExceedsMaximumFrequency(convertedTermValue,
                                                numeralString) > 0) {
    showViolatesModernConventionMessage(numeralString);
    return 0;
  }
  int newTotal = currentTotal + convertedTermValue;
  if (newTotal < 4000)
    return newTotal;
  showTermExceedsMaximumValueMessage(numeralString);
  return 0;
}


x86 assembly (clang, -O0):
<checkConvertedTermValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1171 <checkConvertedTermValue+0x31>
mov    -0x18(%rbp),%rdi
call   1050 <showBadNumeralStringMessage@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cd <checkConvertedTermValue+0x8d>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <convertedTermValueExceedsMaximumFrequency@plt>
cmp    $0x0,%rax
jle    119c <checkConvertedTermValue+0x5c>
mov    -0x18(%rbp),%rdi
call   1060 <showViolatesModernConventionMessage@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cd <checkConvertedTermValue+0x8d>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xfa0,-0x1c(%rbp)
jge    11bd <checkConvertedTermValue+0x7d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <checkConvertedTermValue+0x8d>
mov    -0x18(%rbp),%rdi
call   1040 <showTermExceedsMaximumValueMessage@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkConvertedTermValue>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
test   %edi,%edi
js     1166 <checkConvertedTermValue+0x26>
mov    %esi,%ebx
mov    %edi,%ebp
mov    %r14,%rsi
call   1030 <convertedTermValueExceedsMaximumFrequency@plt>
test   %rax,%rax
jle    1170 <checkConvertedTermValue+0x30>
mov    %r14,%rdi
call   1060 <showViolatesModernConventionMessage@plt>
jmp    1182 <checkConvertedTermValue+0x42>
mov    %r14,%rdi
call   1050 <showBadNumeralStringMessage@plt>
jmp    1182 <checkConvertedTermValue+0x42>
add    %ebp,%ebx
cmp    $0xfa0,%ebx
jl     1184 <checkConvertedTermValue+0x44>
mov    %r14,%rdi
call   1040 <showTermExceedsMaximumValueMessage@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @checkConvertedTermValue(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i8*, i8** %7
%13 = call i32 @showBadNumeralStringMessage(i8* %12)
store i32 0, i32* %4
br label %33
14: ; preds = %3
%15 = load i32, i32* %5
%16 = load i8*, i8** %7
%17 = call i64 @convertedTermValueExceedsMaximumFrequency(i32 %15, i8* %16)
%18 = icmp sgt i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i8*, i8** %7
%21 = call i32 @showViolatesModernConventionMessage(i8* %20)
store i32 0, i32* %4
br label %33
22: ; preds = %14
%23 = load i32, i32* %6
%24 = load i32, i32* %5
%25 = add nsw i32 %23, %24
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 4000
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = load i32, i32* %8
store i32 %29, i32* %4
br label %33
30: ; preds = %22
%31 = load i8*, i8** %7
%32 = call i32 @showTermExceedsMaximumValueMessage(i8* %31)
store i32 0, i32* %4
br label %33
33: ; preds = %30, %28, %19, %11
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
define i32 @checkConvertedTermValue(i32 %0, i32 %1, i8* %2) {
%4 = icmp slt i32 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @showBadNumeralStringMessage(i8* %2)
br label %17
7: ; preds = %3
%8 = tail call i64 @convertedTermValueExceedsMaximumFrequency(i32 %0, i8* %2)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @showViolatesModernConventionMessage(i8* %2)
br label %17
12: ; preds = %7
%13 = add nsw i32 %1, %0
%14 = icmp slt i32 %13, 4000
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @showTermExceedsMaximumValueMessage(i8* %2)
br label %17
17: ; preds = %15, %12, %10, %5
%18 = phi i32 [ 0, %5 ], [ 0, %10 ], [ 0, %15 ], [ %13, %12 ]
ret i32 %18
}