#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*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strtok(char *, char *);
int getipnr(char *n, char *network, char *netmask) {
  char *m;
  size_t i;
  int pw, pm;
  char buf[20];
  pw = pm = 0;
  m = strtok(n, "/");
  sscanf(m, "%19s", buf);
  for (i = 0; i < strlen(buf); i++)
    if ((buf[i] < '0' || buf[i] > '9') && buf[i] != '.')
      return 1;
    else if (buf[i] == '.')
      ++pw;
  strcpy(network, buf);
  switch (pw) {
  case 0:
    strcat(network, ".0.0.0");
    ++pw;
    break;
  case 1:
    if (network[strlen(network) - 1] == '.')
      strcat(network, "0.0.0");
    else {
      strcat(network, ".0.0");
      pw++;
    }
    break;
  case 2:
    if (network[strlen(network) - 1] == '.')
      strcat(network, "0.0");
    else {
      strcat(network, ".0");
      pw++;
    }
    break;
  case 3:
    if (network[strlen(network) - 1] == '.')
      strcat(network, "0");
    else
      pw++;
    break;
  default:
    return 1;
    break;
  }
  m = strtok(NULL, "/");
  if ((m != NULL) && (strlen(m) != 0)) {
    sscanf(m, "%s", buf);
    for (i = 0; i < strlen(buf); i++)
      if ((buf[i] < '0' || buf[i] > '9') && buf[i] != '.')
        return 1;
      else if (buf[i] == '.')
        pm++;
    strcpy(netmask, buf);
    switch (pm) {
    case 0:
      strcat(netmask, ".0.0.0");
      break;
    case 1:
      if (netmask[strlen(netmask) - 1] == '.')
        strcat(netmask, "0.0.0");
      else
        strcat(netmask, ".0.0");
      break;
    case 2:
      if (netmask[strlen(netmask) - 1] == '.')
        strcat(netmask, "0.0");
      else
        strcat(netmask, ".0");
      break;
    case 3:
      if (netmask[strlen(netmask) - 1] == '.')
        strcat(netmask, "0");
      break;
    default:
      return 1;
    }
  } else
    switch (pw) {
    case 1:
      strcpy(netmask, "255.0.0.0");
      break;
    case 2:
      strcpy(netmask, "255.255.0.0");
      break;
    case 3:
      strcpy(netmask, "255.255.255.0");
      break;
    case 4:
      strcpy(netmask, "255.255.255.255");
      break;
    default:
      return 1;
    }
  return 0;
}


x86 assembly (clang, -O0):
<getipnr>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xe9a(%rip),%rsi
call   1050 <sscanf@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    1240 <getipnr+0xf0>
mov    -0x30(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x30,%eax
jl     11ec <getipnr+0x9c>
mov    -0x30(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x39,%eax
jle    120a <getipnr+0xba>
mov    -0x30(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x2e,%eax
je     120a <getipnr+0xba>
movl   $0x1,-0x4(%rbp)
jmp    167d <getipnr+0x52d>
mov    -0x30(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x2e,%eax
jne    1225 <getipnr+0xd5>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    122a <getipnr+0xda>
jmp    122f <getipnr+0xdf>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11a5 <getipnr+0x55>
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x34(%rbp),%eax
mov    %rax,-0x60(%rbp)
sub    $0x3,%rax
ja     1397 <getipnr+0x247>
mov    -0x60(%rbp),%rax
lea    0xd97(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
lea    0xdc0(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    13a3 <getipnr+0x253>
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    12cf <getipnr+0x17f>
mov    -0x18(%rbp),%rdi
lea    0xd79(%rip),%rsi
call   1070 <strcat@plt>
jmp    12e8 <getipnr+0x198>
mov    -0x18(%rbp),%rdi
lea    0xd65(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    13a3 <getipnr+0x253>
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x70(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    132c <getipnr+0x1dc>
mov    -0x18(%rbp),%rdi
lea    0xd1e(%rip),%rsi
call   1070 <strcat@plt>
jmp    1345 <getipnr+0x1f5>
mov    -0x18(%rbp),%rdi
lea    0xd0a(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    13a3 <getipnr+0x253>
mov    -0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1389 <getipnr+0x239>
mov    -0x18(%rbp),%rdi
lea    0xcc3(%rip),%rsi
call   1070 <strcat@plt>
jmp    1392 <getipnr+0x242>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    13a3 <getipnr+0x253>
movl   $0x1,-0x4(%rbp)
jmp    167d <getipnr+0x52d>
xor    %eax,%eax
mov    %eax,%edi
lea    0xc82(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     15e2 <getipnr+0x492>
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
je     15e2 <getipnr+0x492>
mov    -0x28(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xc54(%rip),%rsi
call   1050 <sscanf@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x80(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    148b <getipnr+0x33b>
mov    -0x30(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x30,%eax
jl     1437 <getipnr+0x2e7>
mov    -0x30(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x39,%eax
jle    1455 <getipnr+0x305>
mov    -0x30(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x2e,%eax
je     1455 <getipnr+0x305>
movl   $0x1,-0x4(%rbp)
jmp    167d <getipnr+0x52d>
mov    -0x30(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x2e,%eax
jne    1470 <getipnr+0x320>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1475 <getipnr+0x325>
jmp    147a <getipnr+0x32a>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    13f0 <getipnr+0x2a0>
mov    -0x20(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%eax
mov    %rax,-0x88(%rbp)
sub    $0x3,%rax
ja     15d1 <getipnr+0x481>
mov    -0x88(%rbp),%rax
lea    0xb66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rdi
lea    0xb6f(%rip),%rsi
call   1070 <strcat@plt>
jmp    15dd <getipnr+0x48d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x90(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    151d <getipnr+0x3cd>
mov    -0x20(%rbp),%rdi
lea    0xb2b(%rip),%rsi
call   1070 <strcat@plt>
jmp    152d <getipnr+0x3dd>
mov    -0x20(%rbp),%rdi
lea    0xb17(%rip),%rsi
call   1070 <strcat@plt>
jmp    15dd <getipnr+0x48d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x98(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1577 <getipnr+0x427>
mov    -0x20(%rbp),%rdi
lea    0xad3(%rip),%rsi
call   1070 <strcat@plt>
jmp    1587 <getipnr+0x437>
mov    -0x20(%rbp),%rdi
lea    0xabf(%rip),%rsi
call   1070 <strcat@plt>
jmp    15dd <getipnr+0x48d>
mov    -0x20(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xa0(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    15cc <getipnr+0x47c>
mov    -0x20(%rbp),%rdi
lea    0xa7b(%rip),%rsi
call   1070 <strcat@plt>
jmp    15dd <getipnr+0x48d>
movl   $0x1,-0x4(%rbp)
jmp    167d <getipnr+0x52d>
jmp    1676 <getipnr+0x526>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0xa8(%rbp)
sub    $0x3,%eax
ja     1665 <getipnr+0x515>
mov    -0xa8(%rbp),%rax
lea    0xa08(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rdi
lea    0xa1e(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1671 <getipnr+0x521>
mov    -0x20(%rbp),%rdi
lea    0xa13(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1671 <getipnr+0x521>
mov    -0x20(%rbp),%rdi
lea    0xa0a(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1671 <getipnr+0x521>
mov    -0x20(%rbp),%rdi
lea    0xa03(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1671 <getipnr+0x521>
movl   $0x1,-0x4(%rbp)
jmp    167d <getipnr+0x52d>
jmp    1676 <getipnr+0x526>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getipnr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xec5(%rip),%rsi
call   1060 <strtok@plt>
lea    0xebb(%rip),%rsi
mov    %rsp,%rbx
mov    %rax,%rdi
mov    %rbx,%rdx
call   1050 <sscanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     11d5 <getipnr+0x85>
xor    %ebx,%ebx
mov    %rsp,%r12
xor    %ebp,%ebp
mov    $0x1,%r13d
jmp    11c0 <getipnr+0x70>
xor    %ecx,%ecx
cmp    $0x2e,%al
sete   %cl
add    %ecx,%ebx
add    $0x1,%rbp
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jae    12a9 <getipnr+0x159>
movzbl (%rsp,%rbp,1),%eax
cmp    $0x2e,%al
je     11a0 <getipnr+0x50>
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
jbe    11a0 <getipnr+0x50>
jmp    1335 <getipnr+0x1e5>
mov    %rsp,%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
lea    0xe56(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcat@plt>
mov    $0x1,%ebp
lea    0xe35(%rip),%rsi
xor    %edi,%edi
call   1060 <strtok@plt>
test   %rax,%rax
je     1285 <getipnr+0x135>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     1285 <getipnr+0x135>
lea    0xe1a(%rip),%rsi
mov    %rsp,%rbp
mov    %rbx,%rdi
mov    %rbp,%rdx
call   1050 <sscanf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     12ed <getipnr+0x19d>
xor    %ebx,%ebx
mov    %rsp,%r15
xor    %ebp,%ebp
mov    $0x1,%r13d
jmp    1270 <getipnr+0x120>
nopw   0x0(%rax,%rax,1)
xor    %ecx,%ecx
cmp    $0x2e,%al
sete   %cl
add    %ecx,%ebx
add    $0x1,%rbp
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jae    1347 <getipnr+0x1f7>
movzbl (%rsp,%rbp,1),%eax
cmp    $0x2e,%al
je     1250 <getipnr+0x100>
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
jbe    1250 <getipnr+0x100>
jmp    1335 <getipnr+0x1e5>
add    $0xffffffff,%ebp
cmp    $0x3,%ebp
ja     1309 <getipnr+0x1b9>
lea    0xd8c(%rip),%rax
movslq (%rax,%rbp,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xd96(%rip),%rsi
jmp    132a <getipnr+0x1da>
mov    %rsp,%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
cmp    $0x3,%ebx
ja     1335 <getipnr+0x1e5>
mov    %ebx,%eax
lea    0xd3e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x2e,-0x1(%rax,%r15,1)
jne    13ca <getipnr+0x27a>
lea    0xd56(%rip),%rsi
jmp    11e7 <getipnr+0x97>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xd3e(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcat@plt>
jmp    1332 <getipnr+0x1e2>
mov    $0x1,%r13d
jmp    1335 <getipnr+0x1e5>
lea    0xd2c(%rip),%rsi
jmp    132a <getipnr+0x1da>
lea    0xd2f(%rip),%rsi
jmp    132a <getipnr+0x1da>
lea    0xd34(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
xor    %r13d,%r13d
mov    %r13d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
cmp    $0x3,%ebx
ja     1335 <getipnr+0x1e5>
mov    %ebx,%eax
lea    0xcb0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x2e,-0x1(%rax,%r14,1)
jne    1447 <getipnr+0x2f7>
lea    0xcb8(%rip),%rsi
jmp    12ff <getipnr+0x1af>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x2e,-0x1(%rax,%r15,1)
jne    13e3 <getipnr+0x293>
lea    0xc9c(%rip),%rsi
jmp    13d1 <getipnr+0x281>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
mov    $0x4,%ebp
cmpb   $0x2e,-0x1(%rax,%r15,1)
jne    11f4 <getipnr+0xa4>
lea    0xc7a(%rip),%rsi
jmp    13ea <getipnr+0x29a>
lea    0xc6e(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcat@plt>
mov    $0x2,%ebp
jmp    11f4 <getipnr+0xa4>
lea    0xc57(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcat@plt>
mov    $0x3,%ebp
jmp    11f4 <getipnr+0xa4>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x2e,-0x1(%rax,%r14,1)
jne    1453 <getipnr+0x303>
lea    0xc2b(%rip),%rsi
jmp    12ff <getipnr+0x1af>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
xor    %r13d,%r13d
cmpb   $0x2e,-0x1(%rax,%r14,1)
jne    1335 <getipnr+0x1e5>
lea    0xc08(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcat@plt>
jmp    1335 <getipnr+0x1e5>
lea    0xbf1(%rip),%rsi
jmp    12ff <getipnr+0x1af>
lea    0xbe7(%rip),%rsi
jmp    12ff <getipnr+0x1af>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [5 x i8] c"%19s\00"
@.str.2 = [7 x i8] c".0.0.0\00"
@.str.3 = [6 x i8] c"0.0.0\00"
@.str.4 = [5 x i8] c".0.0\00"
@.str.5 = [4 x i8] c"0.0\00"
@.str.6 = [3 x i8] c".0\00"
@.str.7 = [2 x i8] c"0\00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [10 x i8] c"255.0.0.0\00"
@.str.10 = [12 x i8] c"255.255.0.0\00"
@.str.11 = [14 x i8] c"255.255.255.0\00"
@.str.12 = [16 x i8] c"255.255.255.255\00"
define i32 @getipnr(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca [20 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 0, i32* %11
store i32 0, i32* %10
%13 = load i8*, i8** %5
%14 = call i8* @strtok(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %8
%15 = load i8*, i8** %8
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%17 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %16)
store i64 0, i64* %9
br label %18
18: ; preds = %54, %3
%19 = load i64, i64* %9
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = sext i32 %21 to i64
%23 = icmp ult i64 %19, %22
br i1 %23, label %24, label %57
24: ; preds = %18
%25 = load i64, i64* %9
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp slt i32 %28, 48
br i1 %29, label %36, label %30
30: ; preds = %24
%31 = load i64, i64* %9
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp sgt i32 %34, 57
br i1 %35, label %36, label %43
36: ; preds = %30, %24
%37 = load i64, i64* %9
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 46
br i1 %41, label %42, label %43
42: ; preds = %36
store i32 1, i32* %4
br label %249
43: ; preds = %36, %30
%44 = load i64, i64* %9
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 46
br i1 %48, label %49, label %52
49: ; preds = %43
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 1
store i32 %51, i32* %10
br label %52
52: ; preds = %49, %43
br label %53
53: ; preds = %52
br label %54
54: ; preds = %53
%55 = load i64, i64* %9
%56 = add i64 %55, 1
store i64 %56, i64* %9
br label %18
57: ; preds = %18
%58 = load i8*, i8** %6
%59 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%60 = call i32 @strcpy(i8* %58, i8* %59)
%61 = load i32, i32* %10
switch i32 %61, label %122 [
i32 0, label %62
i32 1, label %67
i32 2, label %86
i32 3, label %105
]
62: ; preds = %57
%63 = load i8*, i8** %6
%64 = call i32 @strcat(i8* %63, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%65 = load i32, i32* %10
%66 = add nsw i32 %65, 1
store i32 %66, i32* %10
br label %123
67: ; preds = %57
%68 = load i8*, i8** %6
%69 = load i8*, i8** %6
%70 = call i32 @strlen(i8* %69)
%71 = sub nsw i32 %70, 1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %68, i64 %72
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 46
br i1 %76, label %77, label %80
77: ; preds = %67
%78 = load i8*, i8** %6
%79 = call i32 @strcat(i8* %78, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %85
80: ; preds = %67
%81 = load i8*, i8** %6
%82 = call i32 @strcat(i8* %81, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%83 = load i32, i32* %10
%84 = add nsw i32 %83, 1
store i32 %84, i32* %10
br label %85
85: ; preds = %80, %77
br label %123
86: ; preds = %57
%87 = load i8*, i8** %6
%88 = load i8*, i8** %6
%89 = call i32 @strlen(i8* %88)
%90 = sub nsw i32 %89, 1
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8, i8* %87, i64 %91
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 46
br i1 %95, label %96, label %99
96: ; preds = %86
%97 = load i8*, i8** %6
%98 = call i32 @strcat(i8* %97, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %104
99: ; preds = %86
%100 = load i8*, i8** %6
%101 = call i32 @strcat(i8* %100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%102 = load i32, i32* %10
%103 = add nsw i32 %102, 1
store i32 %103, i32* %10
br label %104
104: ; preds = %99, %96
br label %123
105: ; preds = %57
%106 = load i8*, i8** %6
%107 = load i8*, i8** %6
%108 = call i32 @strlen(i8* %107)
%109 = sub nsw i32 %108, 1
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %106, i64 %110
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %113, 46
br i1 %114, label %115, label %118
115: ; preds = %105
%116 = load i8*, i8** %6
%117 = call i32 @strcat(i8* %116, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %121
118: ; preds = %105
%119 = load i32, i32* %10
%120 = add nsw i32 %119, 1
store i32 %120, i32* %10
br label %121
121: ; preds = %118, %115
br label %123
122: ; preds = %57
store i32 1, i32* %4
br label %249
123: ; preds = %121, %104, %85, %62
%124 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %124, i8** %8
%125 = load i8*, i8** %8
%126 = icmp ne i8* %125, null
br i1 %126, label %127, label %232
127: ; preds = %123
%128 = load i8*, i8** %8
%129 = call i32 @strlen(i8* %128)
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %232
131: ; preds = %127
%132 = load i8*, i8** %8
%133 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%134 = call i32 @sscanf(i8* %132, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %133)
store i64 0, i64* %9
br label %135
135: ; preds = %171, %131
%136 = load i64, i64* %9
%137 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%138 = call i32 @strlen(i8* %137)
%139 = sext i32 %138 to i64
%140 = icmp ult i64 %136, %139
br i1 %140, label %141, label %174
141: ; preds = %135
%142 = load i64, i64* %9
%143 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 %142
%144 = load i8, i8* %143
%145 = sext i8 %144 to i32
%146 = icmp slt i32 %145, 48
br i1 %146, label %153, label %147
147: ; preds = %141
%148 = load i64, i64* %9
%149 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 %148
%150 = load i8, i8* %149
%151 = sext i8 %150 to i32
%152 = icmp sgt i32 %151, 57
br i1 %152, label %153, label %160
153: ; preds = %147, %141
%154 = load i64, i64* %9
%155 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 %154
%156 = load i8, i8* %155
%157 = sext i8 %156 to i32
%158 = icmp ne i32 %157, 46
br i1 %158, label %159, label %160
159: ; preds = %153
store i32 1, i32* %4
br label %249
160: ; preds = %153, %147
%161 = load i64, i64* %9
%162 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 %161
%163 = load i8, i8* %162
%164 = sext i8 %163 to i32
%165 = icmp eq i32 %164, 46
br i1 %165, label %166, label %169
166: ; preds = %160
%167 = load i32, i32* %11
%168 = add nsw i32 %167, 1
store i32 %168, i32* %11
br label %169
169: ; preds = %166, %160
br label %170
170: ; preds = %169
br label %171
171: ; preds = %170
%172 = load i64, i64* %9
%173 = add i64 %172, 1
store i64 %173, i64* %9
br label %135
174: ; preds = %135
%175 = load i8*, i8** %7
%176 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%177 = call i32 @strcpy(i8* %175, i8* %176)
%178 = load i32, i32* %11
switch i32 %178, label %230 [
i32 0, label %179
i32 1, label %182
i32 2, label %199
i32 3, label %216
]
179: ; preds = %174
%180 = load i8*, i8** %7
%181 = call i32 @strcat(i8* %180, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %231
182: ; preds = %174
%183 = load i8*, i8** %7
%184 = load i8*, i8** %7
%185 = call i32 @strlen(i8* %184)
%186 = sub nsw i32 %185, 1
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds i8, i8* %183, i64 %187
%189 = load i8, i8* %188
%190 = sext i8 %189 to i32
%191 = icmp eq i32 %190, 46
br i1 %191, label %192, label %195
192: ; preds = %182
%193 = load i8*, i8** %7
%194 = call i32 @strcat(i8* %193, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %198
195: ; preds = %182
%196 = load i8*, i8** %7
%197 = call i32 @strcat(i8* %196, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %198
198: ; preds = %195, %192
br label %231
199: ; preds = %174
%200 = load i8*, i8** %7
%201 = load i8*, i8** %7
%202 = call i32 @strlen(i8* %201)
%203 = sub nsw i32 %202, 1
%204 = sext i32 %203 to i64
%205 = getelementptr inbounds i8, i8* %200, i64 %204
%206 = load i8, i8* %205
%207 = sext i8 %206 to i32
%208 = icmp eq i32 %207, 46
br i1 %208, label %209, label %212
209: ; preds = %199
%210 = load i8*, i8** %7
%211 = call i32 @strcat(i8* %210, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %215
212: ; preds = %199
%213 = load i8*, i8** %7
%214 = call i32 @strcat(i8* %213, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %215
215: ; preds = %212, %209
br label %231
216: ; preds = %174
%217 = load i8*, i8** %7
%218 = load i8*, i8** %7
%219 = call i32 @strlen(i8* %218)
%220 = sub nsw i32 %219, 1
%221 = sext i32 %220 to i64
%222 = getelementptr inbounds i8, i8* %217, i64 %221
%223 = load i8, i8* %222
%224 = sext i8 %223 to i32
%225 = icmp eq i32 %224, 46
br i1 %225, label %226, label %229
226: ; preds = %216
%227 = load i8*, i8** %7
%228 = call i32 @strcat(i8* %227, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %229
229: ; preds = %226, %216
br label %231
230: ; preds = %174
store i32 1, i32* %4
br label %249
231: ; preds = %229, %215, %198, %179
br label %248
232: ; preds = %127, %123
%233 = load i32, i32* %10
switch i32 %233, label %246 [
i32 1, label %234
i32 2, label %237
i32 3, label %240
i32 4, label %243
]
234: ; preds = %232
%235 = load i8*, i8** %7
%236 = call i32 @strcpy(i8* %235, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
br label %247
237: ; preds = %232
%238 = load i8*, i8** %7
%239 = call i32 @strcpy(i8* %238, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %247
240: ; preds = %232
%241 = load i8*, i8** %7
%242 = call i32 @strcpy(i8* %241, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
br label %247
243: ; preds = %232
%244 = load i8*, i8** %7
%245 = call i32 @strcpy(i8* %244, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
br label %247
246: ; preds = %232
store i32 1, i32* %4
br label %249
247: ; preds = %243, %240, %237, %234
br label %248
248: ; preds = %247, %231
store i32 0, i32* %4
br label %249
249: ; preds = %248, %246, %230, %159, %122, %42
%250 = load i32, i32* %4
ret i32 %250
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [5 x i8] c"%19s\00"
@.str.2 = [7 x i8] c".0.0.0\00"
@.str.3 = [6 x i8] c"0.0.0\00"
@.str.4 = [5 x i8] c".0.0\00"
@.str.5 = [4 x i8] c"0.0\00"
@.str.6 = [3 x i8] c".0\00"
@.str.7 = [2 x i8] c"0\00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [10 x i8] c"255.0.0.0\00"
@.str.10 = [12 x i8] c"255.255.0.0\00"
@.str.11 = [14 x i8] c"255.255.255.0\00"
@.str.12 = [16 x i8] c"255.255.255.255\00"
define i32 @getipnr(i8* %0, i8* %1, i8* %2) {
%4 = alloca [20 x i8]
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%6 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%8 = call i32 @strlen(i8* %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 @strcpy(i8* %1, i8* %5)
br label %30
12: ; preds = %3, %21
%13 = phi i32 [ %23, %21 ], [ 0, %3 ]
%14 = phi i64 [ %24, %21 ], [ 0, %3 ]
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = add i8 %16, -48
%18 = icmp ult i8 %17, 10
%19 = icmp eq i8 %16, 46
%20 = or i1 %19, %18
br i1 %20, label %21, label %136
21: ; preds = %12
%22 = zext i1 %19 to i32
%23 = add nuw nsw i32 %13, %22
%24 = add nuw i64 %14, 1
%25 = call i32 @strlen(i8* %5)
%26 = sext i32 %25 to i64
%27 = icmp ult i64 %24, %26
br i1 %27, label %12, label %28
28: ; preds = %21
%29 = call i32 @strcpy(i8* %1, i8* %5)
switch i32 %23, label %136 [
i32 0, label %30
i32 1, label %32
i32 2, label %43
i32 3, label %54
]
30: ; preds = %10, %28
%31 = call i32 @strcat(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %63
32: ; preds = %28
%33 = call i32 @strlen(i8* %1)
%34 = add nsw i32 %33, -1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %1, i64 %35
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 46
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = call i32 @strcat(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %63
41: ; preds = %32
%42 = call i32 @strcat(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %63
43: ; preds = %28
%44 = call i32 @strlen(i8* %1)
%45 = add nsw i32 %44, -1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %1, i64 %46
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 46
br i1 %49, label %50, label %52
50: ; preds = %43
%51 = call i32 @strcat(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %63
52: ; preds = %43
%53 = call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %63
54: ; preds = %28
%55 = call i32 @strlen(i8* %1)
%56 = add nsw i32 %55, -1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %1, i64 %57
%59 = load i8, i8* %58
%60 = icmp eq i8 %59, 46
br i1 %60, label %61, label %63
61: ; preds = %54
%62 = call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %63
63: ; preds = %54, %61, %50, %52, %39, %41, %30
%64 = phi i32 [ 3, %61 ], [ 2, %50 ], [ 3, %52 ], [ 1, %39 ], [ 2, %41 ], [ 1, %30 ], [ 4, %54 ]
%65 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%66 = icmp eq i8* %65, null
br i1 %66, label %127, label %67
67: ; preds = %63
%68 = call i32 @strlen(i8* %65)
%69 = icmp eq i32 %68, 0
br i1 %69, label %127, label %70
70: ; preds = %67
%71 = call i32 @sscanf(i8* %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %5)
%72 = call i32 @strlen(i8* %5)
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %70
%75 = call i32 @strcpy(i8* %2, i8* %5)
br label %94
76: ; preds = %70, %85
%77 = phi i32 [ %87, %85 ], [ 0, %70 ]
%78 = phi i64 [ %88, %85 ], [ 0, %70 ]
%79 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 %78
%80 = load i8, i8* %79
%81 = add i8 %80, -48
%82 = icmp ult i8 %81, 10
%83 = icmp eq i8 %80, 46
%84 = or i1 %83, %82
br i1 %84, label %85, label %136
85: ; preds = %76
%86 = zext i1 %83 to i32
%87 = add nuw nsw i32 %77, %86
%88 = add nuw i64 %78, 1
%89 = call i32 @strlen(i8* %5)
%90 = sext i32 %89 to i64
%91 = icmp ult i64 %88, %90
br i1 %91, label %76, label %92
92: ; preds = %85
%93 = call i32 @strcpy(i8* %2, i8* %5)
switch i32 %87, label %136 [
i32 0, label %94
i32 1, label %96
i32 2, label %107
i32 3, label %118
]
94: ; preds = %74, %92
%95 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %136
96: ; preds = %92
%97 = call i32 @strlen(i8* %2)
%98 = add nsw i32 %97, -1
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8, i8* %2, i64 %99
%101 = load i8, i8* %100
%102 = icmp eq i8 %101, 46
br i1 %102, label %103, label %105
103: ; preds = %96
%104 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %136
105: ; preds = %96
%106 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %136
107: ; preds = %92
%108 = call i32 @strlen(i8* %2)
%109 = add nsw i32 %108, -1
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %2, i64 %110
%112 = load i8, i8* %111
%113 = icmp eq i8 %112, 46
br i1 %113, label %114, label %116
114: ; preds = %107
%115 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %136
116: ; preds = %107
%117 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %136
118: ; preds = %92
%119 = call i32 @strlen(i8* %2)
%120 = add nsw i32 %119, -1
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds i8, i8* %2, i64 %121
%123 = load i8, i8* %122
%124 = icmp eq i8 %123, 46
br i1 %124, label %125, label %136
125: ; preds = %118
%126 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %136
127: ; preds = %67, %63
switch i32 %64, label %136 [
i32 1, label %128
i32 2, label %130
i32 3, label %132
i32 4, label %134
]
128: ; preds = %127
%129 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
br label %136
130: ; preds = %127
%131 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %136
132: ; preds = %127
%133 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
br label %136
134: ; preds = %127
%135 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
br label %136
136: ; preds = %12, %76, %118, %125, %114, %116, %103, %105, %94, %134, %132, %130, %128, %127, %92, %28
%137 = phi i32 [ 1, %28 ], [ 1, %92 ], [ 1, %127 ], [ 0, %128 ], [ 0, %130 ], [ 0, %132 ], [ 0, %134 ], [ 0, %94 ], [ 0, %105 ], [ 0, %103 ], [ 0, %116 ], [ 0, %114 ], [ 0, %125 ], [ 0, %118 ], [ 1, %76 ], [ 1, %12 ]
ret i32 %137
}