#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 sscanf(char *, char *, int *, int *, int *, int *);
int checkIP(char *buffer) {
  int pri, seg, ter, cua;
  return (sscanf(buffer, "%d.%d.%d.%d", &pri, &seg, &ter, &cua) == 4 &&
          pri <= 255 && pri >= 0 && seg <= 255 && seg >= 0 && ter <= 255 &&
          ter >= 0 && cua <= 255 && cua >= 0);
}


x86 assembly (clang, -O0):
<checkIP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed9(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
lea    -0x18(%rbp),%r9
call   1030 <sscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x4,%ecx
mov    %al,-0x19(%rbp)
jne    11cb <checkIP+0xbb>
xor    %eax,%eax
cmpl   $0xff,-0xc(%rbp)
mov    %al,-0x19(%rbp)
jg     11cb <checkIP+0xbb>
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x19(%rbp)
jl     11cb <checkIP+0xbb>
xor    %eax,%eax
cmpl   $0xff,-0x10(%rbp)
mov    %al,-0x19(%rbp)
jg     11cb <checkIP+0xbb>
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x19(%rbp)
jl     11cb <checkIP+0xbb>
xor    %eax,%eax
cmpl   $0xff,-0x14(%rbp)
mov    %al,-0x19(%rbp)
jg     11cb <checkIP+0xbb>
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x19(%rbp)
jl     11cb <checkIP+0xbb>
xor    %eax,%eax
cmpl   $0xff,-0x18(%rbp)
mov    %al,-0x19(%rbp)
jg     11cb <checkIP+0xbb>
cmpl   $0x0,-0x18(%rbp)
setge  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkIP>:
sub    $0x18,%rsp
lea    0xee5(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
call   1030 <sscanf@plt>
mov    0x8(%rsp),%edx
mov    %edx,%ecx
not    %ecx
shr    $0x1f,%ecx
xor    %esi,%esi
cmp    $0x100,%edx
cmovge %esi,%ecx
mov    0xc(%rsp),%edx
test   %edx,%edx
cmovs  %esi,%ecx
cmp    $0x100,%edx
cmovge %esi,%ecx
mov    0x10(%rsp),%edx
test   %edx,%edx
cmovs  %esi,%ecx
cmp    $0x100,%edx
cmovge %esi,%ecx
mov    0x14(%rsp),%edx
test   %edx,%edx
cmovs  %esi,%ecx
cmp    $0x100,%edx
cmovge %esi,%ecx
cmp    $0x4,%eax
cmovne %esi,%ecx
mov    %ecx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i32 @checkIP(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6)
%9 = icmp eq i32 %8, 4
br i1 %9, label %10, label %34
10: ; preds = %1
%11 = load i32, i32* %3
%12 = icmp sle i32 %11, 255
br i1 %12, label %13, label %34
13: ; preds = %10
%14 = load i32, i32* %3
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %34
16: ; preds = %13
%17 = load i32, i32* %4
%18 = icmp sle i32 %17, 255
br i1 %18, label %19, label %34
19: ; preds = %16
%20 = load i32, i32* %4
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %34
22: ; preds = %19
%23 = load i32, i32* %5
%24 = icmp sle i32 %23, 255
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i32, i32* %5
%27 = icmp sge i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %25
%29 = load i32, i32* %6
%30 = icmp sle i32 %29, 255
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %6
%33 = icmp sge i32 %32, 0
br label %34
34: ; preds = %31, %28, %25, %22, %19, %16, %13, %10, %1
%35 = phi i1 [ false, %28 ], [ false, %25 ], [ false, %22 ], [ false, %19 ], [ false, %16 ], [ false, %13 ], [ false, %10 ], [ false, %1 ], [ %33, %31 ]
%36 = zext i1 %35 to i32
ret i32 %36
}

LLVM IR (-O2):
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i32 @checkIP(i8* nocapture %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5)
%11 = icmp eq i32 %10, 4
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 256
%14 = select i1 %11, i1 %13, i1 false
%15 = icmp sgt i32 %12, -1
%16 = select i1 %14, i1 %15, i1 false
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 256
%19 = select i1 %16, i1 %18, i1 false
%20 = icmp sgt i32 %17, -1
%21 = select i1 %19, i1 %20, i1 false
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 256
%24 = select i1 %21, i1 %23, i1 false
%25 = icmp sgt i32 %22, -1
%26 = select i1 %24, i1 %25, i1 false
%27 = load i32, i32* %5
%28 = icmp slt i32 %27, 256
%29 = select i1 %26, i1 %28, i1 false
%30 = xor i32 %27, -1
%31 = lshr i32 %30, 31
%32 = select i1 %29, i32 %31, i32 0
ret i32 %32
}