#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 */
int /*<<< orphan*/ convNumIP(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void geraEndIPRede(const char *nIPBin, const char cIP, char *nIPRedeDec,
                   char *nIPRedeBin) {
  *(nIPRedeDec + 0) = '\0';
  *(nIPRedeBin + 0) = '\0';
  switch (cIP) {
  case 'A':
    strncpy(nIPRedeBin, nIPBin, 8);
    *(nIPRedeBin + 8) = '\0';
    strcat(nIPRedeBin, "000000000000000000000000");
    convNumIP(nIPRedeDec, nIPRedeBin, 1);
    break;
  case 'B':
    strncpy(nIPRedeBin, nIPBin, 16);
    *(nIPRedeBin + 16) = '\0';
    strcat(nIPRedeBin, "0000000000000000");
    convNumIP(nIPRedeDec, nIPRedeBin, 1);
    break;
  case 'C':
    strncpy(nIPRedeBin, nIPBin, 24);
    *(nIPRedeBin + 24) = '\0';
    strcat(nIPRedeBin, "00000000");
    convNumIP(nIPRedeDec, nIPRedeBin, 1);
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<geraEndIPRede>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movsbl -0x9(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x41,%eax
je     118f <geraEndIPRede+0x5f>
jmp    116d <geraEndIPRede+0x3d>
mov    -0x24(%rbp),%eax
sub    $0x42,%eax
je     11d0 <geraEndIPRede+0xa0>
jmp    117e <geraEndIPRede+0x4e>
mov    -0x24(%rbp),%eax
sub    $0x43,%eax
je     1211 <geraEndIPRede+0xe1>
jmp    1252 <geraEndIPRede+0x122>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,0x8(%rax)
mov    -0x20(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1040 <convNumIP@plt>
jmp    1257 <geraEndIPRede+0x127>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x10,%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,0x10(%rax)
mov    -0x20(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1040 <convNumIP@plt>
jmp    1257 <geraEndIPRede+0x127>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x18,%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,0x18(%rax)
mov    -0x20(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1040 <convNumIP@plt>
jmp    1257 <geraEndIPRede+0x127>
jmp    1257 <geraEndIPRede+0x127>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geraEndIPRede>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movb   $0x0,(%rdx)
movb   $0x0,(%rcx)
add    $0xffffffbf,%esi
cmp    $0x2,%esi
ja     11a1 <geraEndIPRede+0x71>
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rdi,%rax
lea    0x8(,%rsi,8),%edx
mov    %esi,%r12d
movslq %esi,%rcx
lea    0xeb9(%rip),%rsi
movslq (%rsi,%rcx,4),%r15
add    %rsi,%r15
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strncpy@plt>
movb   $0x0,0x8(%rbx,%r12,8)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <convNumIP@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [25 x i8] c"000000000000000000000000\00"
@.str.1 = [17 x i8] c"0000000000000000\00"
@.str.2 = [9 x i8] c"00000000\00"
@reltable.geraEndIPRede = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.geraEndIPRede to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.geraEndIPRede to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.geraEndIPRede to i64)) to i32)]
define void @geraEndIPRede(i8* %0, i8 signext %1, i8* %2, i8* %3) {
store i8 0, i8* %2
store i8 0, i8* %3
%5 = sext i8 %1 to i32
%6 = add nsw i32 %5, -65
%7 = icmp ult i32 %6, 3
br i1 %7, label %8, label %21
8: ; preds = %4
%9 = shl nsw i32 %6, 3
%10 = add nsw i32 %9, 8
%11 = zext i32 %6 to i64
%12 = shl nuw nsw i64 %11, 3
%13 = add nuw nsw i64 %12, 8
%14 = sext i32 %6 to i64
%15 = shl i64 %14, 2
%16 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.geraEndIPRede to i8*), i64 %15)
%17 = tail call i32 @strncpy(i8* %3, i8* %0, i32 %10)
%18 = getelementptr inbounds i8, i8* %3, i64 %13
store i8 0, i8* %18
%19 = tail call i32 @strcat(i8* %3, i8* %16)
%20 = tail call i32 @convNumIP(i8* %2, i8* %3, i32 1)
br label %21
21: ; preds = %4, %8
ret void
}