#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 */
unsigned int abs(int);
int /*<<< orphan*/ acpp_asm_add_mapping_symbol(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int acpp_asm_add_mapping_symbol_range(char *sb, char *sa, int r1, int r2,
                                      char *error_msg) {
  unsigned int range = abs(r2 - r1);
  int increment_sign = (r1 < r2) ? 1 : -1;
  char final_symbol[200];
  if (sb == NULL && sa == NULL) {
    sprintf(error_msg, "Internal parser error");
    return 0;
  }
  if (r1 < 0 || r2 < 0) {
    sprintf(error_msg, "Only positive values are accepted");
    return 0;
  }
  final_symbol[0] = '\0';
  char *p_fs = final_symbol;
  char *saved_p_fs;
  if (sb != NULL)
    strcpy(p_fs, sb);
  while (*p_fs != '\0')
    p_fs++;
  saved_p_fs = p_fs;
  int i;
  for (i = 0; i <= range; i++) {
    p_fs = saved_p_fs;
    sprintf(p_fs, "%d", r1 + (i * increment_sign));
    while (*p_fs != '\0')
      p_fs++;
    if (sa != NULL)
      strcpy(p_fs, sa);
    if (!acpp_asm_add_mapping_symbol(final_symbol, error_msg))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<acpp_asm_add_mapping_symbol_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x20(%rbp),%edi
sub    -0x1c(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%esi
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmovl  %ecx,%eax
mov    %eax,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b7 <acpp_asm_add_mapping_symbol_range+0x77>
cmpq   $0x0,-0x18(%rbp)
jne    11b7 <acpp_asm_add_mapping_symbol_range+0x77>
mov    -0x28(%rbp),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    132b <acpp_asm_add_mapping_symbol_range+0x1eb>
cmpl   $0x0,-0x1c(%rbp)
jl     11cb <acpp_asm_add_mapping_symbol_range+0x8b>
cmpl   $0x0,-0x20(%rbp)
jge    11e9 <acpp_asm_add_mapping_symbol_range+0xa9>
mov    -0x28(%rbp),%rdi
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    132b <acpp_asm_add_mapping_symbol_range+0x1eb>
movb   $0x0,-0x100(%rbp)
lea    -0x100(%rbp),%rax
mov    %rax,-0x108(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1219 <acpp_asm_add_mapping_symbol_range+0xd9>
mov    -0x108(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    121e <acpp_asm_add_mapping_symbol_range+0xde>
mov    -0x108(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1248 <acpp_asm_add_mapping_symbol_range+0x108>
mov    -0x108(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x108(%rbp)
jmp    121e <acpp_asm_add_mapping_symbol_range+0xde>
mov    -0x108(%rbp),%rax
mov    %rax,-0x110(%rbp)
movl   $0x0,-0x114(%rbp)
mov    -0x114(%rbp),%eax
cmp    -0x2c(%rbp),%eax
ja     1324 <acpp_asm_add_mapping_symbol_range+0x1e4>
mov    -0x110(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    -0x108(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x114(%rbp),%eax
imul   -0x30(%rbp),%eax
add    %eax,%edx
lea    0xd9e(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x108(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12cb <acpp_asm_add_mapping_symbol_range+0x18b>
mov    -0x108(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x108(%rbp)
jmp    12a1 <acpp_asm_add_mapping_symbol_range+0x161>
cmpq   $0x0,-0x18(%rbp)
je     12e6 <acpp_asm_add_mapping_symbol_range+0x1a6>
mov    -0x108(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <acpp_asm_add_mapping_symbol@plt>
cmp    $0x0,%eax
jne    130b <acpp_asm_add_mapping_symbol_range+0x1cb>
movl   $0x0,-0x4(%rbp)
jmp    132b <acpp_asm_add_mapping_symbol_range+0x1eb>
jmp    1310 <acpp_asm_add_mapping_symbol_range+0x1d0>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1260 <acpp_asm_add_mapping_symbol_range+0x120>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acpp_asm_add_mapping_symbol_range>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rsi,%r12
mov    %ecx,%eax
sub    %edx,%eax
mov    %eax,%r13d
neg    %r13d
cmovs  %eax,%r13d
mov    %rdi,%rax
or     %rsi,%rax
jne    1178 <acpp_asm_add_mapping_symbol_range+0x48>
movups 0xe9f(%rip),%xmm0
movups %xmm0,(%r8)
movabs $0x726f7272652072,%rax
mov    %rax,0xe(%r8)
jmp    125e <acpp_asm_add_mapping_symbol_range+0x12e>
mov    %edx,%ebx
mov    %ecx,%eax
or     %edx,%eax
js     1240 <acpp_asm_add_mapping_symbol_range+0x110>
mov    %rdi,%rsi
mov    %r8,0x8(%rsp)
movb   $0x0,0x10(%rsp)
test   %rdi,%rdi
je     11a4 <acpp_asm_add_mapping_symbol_range+0x74>
lea    0x10(%rsp),%rdi
mov    %ecx,%ebp
call   1030 <strcpy@plt>
mov    %ebp,%ecx
lea    0xf(%rsp),%rbp
nopl   0x0(%rax)
cmpb   $0x0,0x1(%rbp)
lea    0x1(%rbp),%rbp
jne    11b0 <acpp_asm_add_mapping_symbol_range+0x80>
mov    %rbp,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,(%rsp)
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edx
neg    %edx
mov    %ecx,%r14d
cmp    %ebx,%ecx
cmovg  %r15d,%edx
add    %ebx,%edx
mov    %rbp,%rdi
lea    0xe4e(%rip),%rsi
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    (%rsp),%rdi
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x0,0x1(%rdi)
lea    0x1(%rdi),%rdi
jne    1200 <acpp_asm_add_mapping_symbol_range+0xd0>
test   %r12,%r12
je     1217 <acpp_asm_add_mapping_symbol_range+0xe7>
mov    %r12,%rsi
call   1030 <strcpy@plt>
lea    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
call   1050 <acpp_asm_add_mapping_symbol@plt>
test   %eax,%eax
je     125e <acpp_asm_add_mapping_symbol_range+0x12e>
lea    0x1(%r15),%eax
cmp    %r13d,%r15d
mov    %eax,%r15d
mov    %r14d,%ecx
jne    11d0 <acpp_asm_add_mapping_symbol_range+0xa0>
mov    $0x1,%eax
jmp    1260 <acpp_asm_add_mapping_symbol_range+0x130>
movups 0xddf(%rip),%xmm0
movups %xmm0,0x10(%r8)
movups 0xdc3(%rip),%xmm0
movups %xmm0,(%r8)
movw   $0x64,0x20(%r8)
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Internal parser error\00"
@.str.1 = [34 x i8] c"Only positive values are accepted\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @acpp_asm_add_mapping_symbol_range(i8* %0, i8* %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca [200 x i8]
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8* %4, i8** %11
%18 = load i32, i32* %10
%19 = load i32, i32* %9
%20 = sub nsw i32 %18, %19
%21 = call i32 @abs(i32 %20)
store i32 %21, i32* %12
%22 = load i32, i32* %9
%23 = load i32, i32* %10
%24 = icmp slt i32 %22, %23
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 1, i32 -1
store i32 %26, i32* %13
%27 = load i8*, i8** %7
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %35
29: ; preds = %5
%30 = load i8*, i8** %8
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i8*, i8** %11
%34 = call i32 (i8*, i8*, ...) @sprintf(i8* %33, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %103
35: ; preds = %29, %5
%36 = load i32, i32* %9
%37 = icmp slt i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = load i32, i32* %10
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38, %35
%42 = load i8*, i8** %11
%43 = call i32 (i8*, i8*, ...) @sprintf(i8* %42, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %103
44: ; preds = %38
%45 = getelementptr inbounds [200 x i8], [200 x i8]* %14, i64 0, i64 0
store i8 0, i8* %45
%46 = getelementptr inbounds [200 x i8], [200 x i8]* %14, i64 0, i64 0
store i8* %46, i8** %15
%47 = load i8*, i8** %7
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %53
49: ; preds = %44
%50 = load i8*, i8** %15
%51 = load i8*, i8** %7
%52 = call i32 @strcpy(i8* %50, i8* %51)
br label %53
53: ; preds = %49, %44
br label %54
54: ; preds = %59, %53
%55 = load i8*, i8** %15
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %54
%60 = load i8*, i8** %15
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %15
br label %54
62: ; preds = %54
%63 = load i8*, i8** %15
store i8* %63, i8** %16
store i32 0, i32* %17
br label %64
64: ; preds = %99, %62
%65 = load i32, i32* %17
%66 = load i32, i32* %12
%67 = icmp ule i32 %65, %66
br i1 %67, label %68, label %102
68: ; preds = %64
%69 = load i8*, i8** %16
store i8* %69, i8** %15
%70 = load i8*, i8** %15
%71 = load i32, i32* %9
%72 = load i32, i32* %17
%73 = load i32, i32* %13
%74 = mul nsw i32 %72, %73
%75 = add nsw i32 %71, %74
%76 = call i32 (i8*, i8*, ...) @sprintf(i8* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %82, %68
%78 = load i8*, i8** %15
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %77
%83 = load i8*, i8** %15
%84 = getelementptr inbounds i8, i8* %83, i32 1
store i8* %84, i8** %15
br label %77
85: ; preds = %77
%86 = load i8*, i8** %8
%87 = icmp ne i8* %86, null
br i1 %87, label %88, label %92
88: ; preds = %85
%89 = load i8*, i8** %15
%90 = load i8*, i8** %8
%91 = call i32 @strcpy(i8* %89, i8* %90)
br label %92
92: ; preds = %88, %85
%93 = getelementptr inbounds [200 x i8], [200 x i8]* %14, i64 0, i64 0
%94 = load i8*, i8** %11
%95 = call i32 @acpp_asm_add_mapping_symbol(i8* %93, i8* %94)
%96 = icmp ne i32 %95, 0
br i1 %96, label %98, label %97
97: ; preds = %92
store i32 0, i32* %6
br label %103
98: ; preds = %92
br label %99
99: ; preds = %98
%100 = load i32, i32* %17
%101 = add nsw i32 %100, 1
store i32 %101, i32* %17
br label %64
102: ; preds = %64
store i32 1, i32* %6
br label %103
103: ; preds = %102, %97, %41, %32
%104 = load i32, i32* %6
ret i32 %104
}

LLVM IR (-O2):
@.str = [22 x i8] c"Internal parser error\00"
@.str.1 = [34 x i8] c"Only positive values are accepted\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @acpp_asm_add_mapping_symbol_range(i8* %0, i8* %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca [200 x i8]
%7 = sub nsw i32 %3, %2
%8 = tail call i32 @llvm.abs.i32(i32 %7, i1 true)
%9 = icmp sgt i32 %3, %2
%10 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%11 = icmp eq i8* %0, null
%12 = icmp eq i8* %1, null
%13 = and i1 %11, %12
br i1 %13, label %14, label %15
14: ; preds = %5
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(22) %4, i8* align 1 dereferenceable(22) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 22, i1 false)
br label %48
15: ; preds = %5
%16 = or i32 %3, %2
%17 = icmp sgt i32 %16, -1
br i1 %17, label %19, label %18
18: ; preds = %15
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(34) %4, i8* align 1 dereferenceable(34) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 34, i1 false)
br label %48
19: ; preds = %15
store i8 0, i8* %10
br i1 %11, label %22, label %20
20: ; preds = %19
%21 = call i32 @strcpy(i8* %10, i8* %0)
br label %22
22: ; preds = %20, %19
br label %23
23: ; preds = %22, %23
%24 = phi i8* [ %27, %23 ], [ %10, %22 ]
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
%27 = getelementptr inbounds i8, i8* %24, i64 1
br i1 %26, label %31, label %23
28: ; preds = %45
%29 = add nuw i32 %32, 1
%30 = icmp eq i32 %32, %8
br i1 %30, label %48, label %31
31: ; preds = %23, %28
%32 = phi i32 [ %29, %28 ], [ 0, %23 ]
%33 = sub nsw i32 0, %32
%34 = select i1 %9, i32 %32, i32 %33
%35 = add nsw i32 %34, %2
%36 = call i32 (i8*, i8*, ...) @sprintf(i8* %24, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %37, %31
%38 = phi i8* [ %24, %31 ], [ %41, %37 ]
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 0
%41 = getelementptr inbounds i8, i8* %38, i64 1
br i1 %40, label %42, label %37
42: ; preds = %37
br i1 %12, label %45, label %43
43: ; preds = %42
%44 = call i32 @strcpy(i8* %38, i8* %1)
br label %45
45: ; preds = %43, %42
%46 = call i32 @acpp_asm_add_mapping_symbol(i8* %10, i8* %4)
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %28
48: ; preds = %45, %28, %18, %14
%49 = phi i32 [ 0, %14 ], [ 0, %18 ], [ 1, %28 ], [ 0, %45 ]
ret i32 %49
}