#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 long atol(char *);
int /*<<< orphan*/ paraDec(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char const);
unsigned long int geraNumRelSR(const char *nIPBin, const char *maskBin,
                               const char cIP) {
  register char i;
  char auxBin[32] = "\0", auxDec[10] = "\0";
  switch (cIP) {
  case 'A':
    i = 8;
    break;
  case 'B':
    i = 16;
    break;
  case 'C':
    i = 24;
    break;
  default:
    return 0;
    break;
  }
  while (*(maskBin + i) == '1') {
    sprintf(auxBin,
            "%s"
            "%c",
            auxBin, *(nIPBin + i));
    ++i;
  }
  paraDec(auxBin, auxDec, 2);
  return atol(auxDec);
}


x86 assembly (clang, -O0):
<geraNumRelSR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %dl,%al
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %al,-0x19(%rbp)
xorps  %xmm0,%xmm0
movaps %xmm0,-0x30(%rbp)
movaps %xmm0,-0x40(%rbp)
movw   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movsbl -0x19(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x41,%eax
je     1195 <geraNumRelSR+0x65>
jmp    1173 <geraNumRelSR+0x43>
mov    -0x54(%rbp),%eax
sub    $0x42,%eax
je     119e <geraNumRelSR+0x6e>
jmp    1184 <geraNumRelSR+0x54>
mov    -0x54(%rbp),%eax
sub    $0x43,%eax
je     11a7 <geraNumRelSR+0x77>
jmp    11b0 <geraNumRelSR+0x80>
movb   $0x8,-0x1a(%rbp)
jmp    11bd <geraNumRelSR+0x8d>
movb   $0x10,-0x1a(%rbp)
jmp    11bd <geraNumRelSR+0x8d>
movb   $0x18,-0x1a(%rbp)
jmp    11bd <geraNumRelSR+0x8d>
movq   $0x0,-0x8(%rbp)
jmp    1229 <geraNumRelSR+0xf9>
jmp    11c2 <geraNumRelSR+0x92>
mov    -0x18(%rbp),%rax
movsbl -0x1a(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
jne    120a <geraNumRelSR+0xda>
lea    -0x40(%rbp),%rdi
lea    -0x40(%rbp),%rdx
mov    -0x10(%rbp),%rax
movsbl -0x1a(%rbp),%ecx
movslq %ecx,%rcx
lea    0xe0c(%rip),%rsi
movsbl (%rax,%rcx,1),%ecx
call   1050 <sprintf@plt>
mov    -0x1a(%rbp),%al
add    $0x1,%al
mov    %al,-0x1a(%rbp)
jmp    11c2 <geraNumRelSR+0x92>
lea    -0x40(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x2,%edx
call   1030 <paraDec@plt>
lea    -0x50(%rbp),%rdi
call   1040 <atol@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geraNumRelSR>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movw   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
add    $0xffffffbf,%edx
cmp    $0x2,%edx
ja     11d0 <geraNumRelSR+0xa0>
mov    %rsi,%r12
mov    %edx,%eax
cmpb   $0x31,0x8(%rsi,%rax,8)
jne    11b1 <geraNumRelSR+0x81>
mov    %rdi,%r14
lea    0x8(,%rax,8),%rbx
lea    0xe81(%rip),%r15
lea    0x10(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r14,%rbx,1),%ecx
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1050 <sprintf@plt>
add    $0x1,%bl
movsbq %bl,%rbx
cmpb   $0x31,(%r12,%rbx,1)
je     1190 <geraNumRelSR+0x60>
lea    0x10(%rsp),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <paraDec@plt>
mov    %rbx,%rdi
call   1040 <atol@plt>
jmp    11d2 <geraNumRelSR+0xa2>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s%c\00"
define i64 @geraNumRelSR(i8* %0, i8* %1, i8 signext %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i8
%9 = alloca [32 x i8]
%10 = alloca [10 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8 %2, i8* %7
%11 = bitcast [32 x i8]* %9 to i8*
%12 = bitcast [10 x i8]* %10 to i8*
%13 = load i8, i8* %7
%14 = sext i8 %13 to i32
switch i32 %14, label %18 [
i32 65, label %15
i32 66, label %16
i32 67, label %17
]
15: ; preds = %3
store i8 8, i8* %8
br label %19
16: ; preds = %3
store i8 16, i8* %8
br label %19
17: ; preds = %3
store i8 24, i8* %8
br label %19
18: ; preds = %3
store i64 0, i64* %4
br label %47
19: ; preds = %17, %16, %15
br label %20
20: ; preds = %29, %19
%21 = load i8*, i8** %6
%22 = load i8, i8* %8
%23 = sext i8 %22 to i32
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 49
br i1 %28, label %29, label %41
29: ; preds = %20
%30 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%32 = load i8*, i8** %5
%33 = load i8, i8* %8
%34 = sext i8 %33 to i32
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
%37 = load i8, i8* %36
%38 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %31, i8 signext %37)
%39 = load i8, i8* %8
%40 = add i8 %39, 1
store i8 %40, i8* %8
br label %20
41: ; preds = %20
%42 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%43 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 0
%44 = call i32 @paraDec(i8* %42, i8* %43, i32 2)
%45 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 0
%46 = call i64 @atol(i8* %45)
store i64 %46, i64* %4
br label %47
47: ; preds = %41, %18
%48 = load i64, i64* %4
ret i64 %48
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%c\00"
define i64 @geraNumRelSR(i8* nocapture %0, i8* nocapture %1, i8 signext %2) {
%4 = alloca [32 x i8]
%5 = alloca [10 x i8]
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%8 = sext i8 %2 to i32
%9 = add nsw i32 %8, -65
%10 = icmp ult i32 %9, 3
br i1 %10, label %11, label %32
11: ; preds = %3
%12 = zext i32 %9 to i64
%13 = shl nuw nsw i64 %12, 3
%14 = add nuw nsw i64 %13, 8
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 49
br i1 %17, label %18, label %29
18: ; preds = %11, %18
%19 = phi i64 [ %25, %18 ], [ %14, %11 ]
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6, i8 signext %21)
%23 = shl nsw i64 %19, 56
%24 = add i64 %23, 72057594037927936
%25 = ashr exact i64 %24, 56
%26 = getelementptr inbounds i8, i8* %1, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 49
br i1 %28, label %18, label %29
29: ; preds = %18, %11
%30 = call i32 @paraDec(i8* %6, i8* %7, i32 2)
%31 = call i64 @atol(i8* %7)
br label %32
32: ; preds = %3, %29
%33 = phi i64 [ %31, %29 ], [ 0, %3 ]
ret i64 %33
}