#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int fscanf(int /*<<< orphan*/ *, char *, unsigned int *, unsigned int *,
           unsigned int *, unsigned int *, unsigned int *);
void ReadPrefix(FILE *fp, unsigned char *IPpref, unsigned char *IPmask) {
  unsigned int tpref[4], tMask;
  int ret;
  tMask = 32;
  ret = fscanf(fp, "%d.%d.%d.%d/%d", &tpref[0], &tpref[1], &tpref[2], &tpref[3],
               &tMask);
  if (ret != 5)
    return;
  IPpref[0] = (unsigned char)tpref[0];
  IPpref[1] = (unsigned char)tpref[1];
  IPpref[2] = (unsigned char)tpref[2];
  IPpref[3] = (unsigned char)tpref[3];
  *IPmask = (unsigned char)tMask;
}


x86 assembly (clang, -O0):
<ReadPrefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x20,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    -0x30(%rbp),%rcx
add    $0x4,%rcx
lea    -0x30(%rbp),%r8
add    $0x8,%r8
lea    -0x30(%rbp),%r9
add    $0xc,%r9
lea    0xeae(%rip),%rsi
lea    -0x34(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <fscanf@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x5,-0x38(%rbp)
je     1171 <ReadPrefix+0x61>
jmp    11ab <ReadPrefix+0x9b>
mov    -0x30(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x2c(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x28(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x24(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x34(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadPrefix>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
movl   $0x20,0xc(%rsp)
lea    0x14(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0x1c(%rsp),%r9
lea    0xc(%rsp),%rax
mov    %rax,(%rsp)
lea    0xecc(%rip),%rsi
lea    0x10(%rsp),%rdx
call   1030 <fscanf@plt>
cmp    $0x5,%eax
jne    1174 <ReadPrefix+0x64>
movdqa 0x10(%rsp),%xmm0
pand   0xe9f(%rip),%xmm0
packuswb %xmm0,%xmm0
packuswb %xmm0,%xmm0
movd   %xmm0,(%rbx)
mov    0xc(%rsp),%al
mov    %al,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"%d.%d.%d.%d/%d\00"
define void @ReadPrefix(i32* nocapture %0, i8* nocapture writeonly %1, i8* nocapture writeonly %2) {
%4 = alloca <4 x i32>
%5 = alloca i32
%6 = bitcast <4 x i32>* %4 to i8*
%7 = bitcast i32* %5 to i8*
store i32 32, i32* %5
%8 = getelementptr inbounds <4 x i32>, <4 x i32>* %4, i64 0, i64 0
%9 = getelementptr inbounds <4 x i32>, <4 x i32>* %4, i64 0, i64 1
%10 = getelementptr inbounds <4 x i32>, <4 x i32>* %4, i64 0, i64 2
%11 = getelementptr inbounds <4 x i32>, <4 x i32>* %4, i64 0, i64 3
%12 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32* %8, i32* %9, i32* %10, i32* %11, i32* %5)
%13 = icmp eq i32 %12, 5
br i1 %13, label %14, label %20
14: ; preds = %3
%15 = load <4 x i32>, <4 x i32>* %4
%16 = trunc <4 x i32> %15 to <4 x i8>
%17 = bitcast i8* %1 to <4 x i8>*
store <4 x i8> %16, <4 x i8>* %17
%18 = load i32, i32* %5
%19 = trunc i32 %18 to i8
store i8 %19, i8* %2
br label %20
20: ; preds = %3, %14
ret void
}