#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 atoi(char *);
int hostnum2subnet(int);
int /*<<< orphan*/ printf(char *, char *, int);
int /*<<< orphan*/ *strstr(char *, char *);
char *strtok(char *, char *);
void parse_line(char *line) {
  char *ip;
  char *numstr;
  int num;
  if (strstr(line, "CN") == NULL) {
    return;
  }
  if (strstr(line, "ipv4") == NULL) {
    return;
  }
  strtok(line, "|");
  strtok(NULL, "|");
  strtok(NULL, "|");
  ip = strtok(NULL, "|");
  numstr = strtok(NULL, "|");
  num = atoi(numstr);
  printf("%s/%d\n", ip, hostnum2subnet(num));
}


x86 assembly (clang, -O0):
<parse_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
jne    117b <parse_line+0x2b>
jmp    1220 <parse_line+0xd0>
mov    -0x8(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
jne    119a <parse_line+0x4a>
jmp    1220 <parse_line+0xd0>
mov    -0x8(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1050 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe53(%rip),%rsi
call   1050 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe43(%rip),%rsi
call   1050 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe33(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe1f(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <hostnum2subnet@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xdef(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_line>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xea2(%rip),%rsi
call   1070 <strstr@plt>
test   %rax,%rax
je     11e0 <parse_line+0x90>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     11e0 <parse_line+0x90>
lea    0xe85(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strtok@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1030 <hostnum2subnet@plt>
lea    0xe3b(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"CN\00"
@.str.1 = [5 x i8] c"ipv4\00"
@.str.2 = [2 x i8] c"|\00"
@.str.3 = [7 x i8] c"%s/%d\0A\00"
define void @parse_line(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32* @strstr(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
br label %28
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i32* @strstr(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %10
br label %28
15: ; preds = %10
%16 = load i8*, i8** %2
%17 = call i8* @strtok(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %20, i8** %3
%21 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %21, i8** %4
%22 = load i8*, i8** %4
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %5
%24 = load i8*, i8** %3
%25 = load i32, i32* %5
%26 = call i32 @hostnum2subnet(i32 %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %24, i32 %26)
br label %28
28: ; preds = %15, %14, %9
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"CN\00"
@.str.1 = [5 x i8] c"ipv4\00"
@.str.2 = [2 x i8] c"|\00"
@.str.3 = [7 x i8] c"%s/%d\0A\00"
define void @parse_line(i8* %0) {
%2 = tail call i32* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = tail call i32* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %16, label %7
7: ; preds = %4
%8 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @atoi(i8* %12)
%14 = tail call i32 @hostnum2subnet(i32 %13)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %11, i32 %14)
br label %16
16: ; preds = %4, %1, %7
ret void
}