#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 geraNumRelHost(const char *nIPBin, const char *maskBin) {
  register char i = 0;
  char auxBin[32] = "\0", auxDec[10] = "\0";
  while (*(maskBin + i) == '1')
    ++i;
  while (i < 32) {
    sprintf(auxBin,
            "%s"
            "%c",
            auxBin, *(nIPBin + i));
    ++i;
  }
  paraDec(auxBin, auxDec, 2);
  return atol(auxDec);
}


x86 assembly (clang, -O0):
<geraNumRelHost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
lea    -0x4a(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
movsbl -0x11(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
jne    1199 <geraNumRelHost+0x59>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1174 <geraNumRelHost+0x34>
jmp    119e <geraNumRelHost+0x5e>
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
jge    11db <geraNumRelHost+0x9b>
lea    -0x40(%rbp),%rdi
lea    -0x40(%rbp),%rdx
mov    -0x8(%rbp),%rax
movsbl -0x11(%rbp),%ecx
movslq %ecx,%rcx
lea    0xe3b(%rip),%rsi
movsbl (%rax,%rcx,1),%ecx
call   1060 <sprintf@plt>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    119e <geraNumRelHost+0x5e>
lea    -0x40(%rbp),%rdi
lea    -0x4a(%rbp),%rsi
mov    $0x2,%edx
call   1040 <paraDec@plt>
lea    -0x4a(%rbp),%rdi
call   1050 <atol@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geraNumRelHost>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r12
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movw   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
mov    $0xdf,%bl
nopl   0x0(%rax)
lea    0x21(%rbx),%eax
movsbq %al,%rax
add    $0x1,%bl
cmpb   $0x31,(%rsi,%rax,1)
je     1160 <geraNumRelHost+0x30>
lea    0x20(%rbx),%eax
cmp    $0x1f,%al
jg     11ac <geraNumRelHost+0x7c>
movsbq %al,%rax
add    %rax,%r12
neg    %bl
lea    0xe79(%rip),%r14
lea    0x10(%rsp),%r15
nopl   0x0(%rax)
movsbl (%r12),%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <sprintf@plt>
add    $0x1,%r12
add    $0xff,%bl
jne    1190 <geraNumRelHost+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>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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