#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 *, int *, int *, int *, int *);
int isip(char *ip) {
  int a, b, c, d;
  sscanf(ip, "%d.%d.%d.%d", &a, &b, &c, &d);
  if (a < 0)
    return 0;
  if (a > 255)
    return 0;
  if (b < 0)
    return 0;
  if (b > 255)
    return 0;
  if (c < 0)
    return 0;
  if (c > 255)
    return 0;
  if (d < 0)
    return 0;
  if (d > 255)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<isip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    -0x20(%rbp),%r9
call   1030 <sscanf@plt>
cmpl   $0x0,-0x14(%rbp)
jge    1152 <isip+0x42>
movl   $0x0,-0x4(%rbp)
jmp    11ff <isip+0xef>
cmpl   $0xff,-0x14(%rbp)
jle    116b <isip+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    11ff <isip+0xef>
cmpl   $0x0,-0x18(%rbp)
jge    1181 <isip+0x71>
movl   $0x0,-0x4(%rbp)
jmp    11ff <isip+0xef>
cmpl   $0xff,-0x18(%rbp)
jle    119a <isip+0x8a>
movl   $0x0,-0x4(%rbp)
jmp    11ff <isip+0xef>
cmpl   $0x0,-0x1c(%rbp)
jge    11b0 <isip+0xa0>
movl   $0x0,-0x4(%rbp)
jmp    11ff <isip+0xef>
cmpl   $0xff,-0x1c(%rbp)
jle    11c9 <isip+0xb9>
movl   $0x0,-0x4(%rbp)
jmp    11ff <isip+0xef>
cmpl   $0x0,-0x20(%rbp)
jge    11df <isip+0xcf>
movl   $0x0,-0x4(%rbp)
jmp    11ff <isip+0xef>
cmpl   $0xff,-0x20(%rbp)
jle    11f8 <isip+0xe8>
movl   $0x0,-0x4(%rbp)
jmp    11ff <isip+0xef>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isip>:
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>
xor    %eax,%eax
cmpl   $0xff,0x14(%rsp)
ja     1167 <isip+0x57>
cmpl   $0xff,0x10(%rsp)
ja     1167 <isip+0x57>
cmpl   $0xff,0xc(%rsp)
ja     1167 <isip+0x57>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
js     1167 <isip+0x57>
xor    %eax,%eax
cmp    $0x100,%ecx
setb   %al
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i32 @isip(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 = load i32, i32* %2
%12 = icmp ugt i32 %11, 255
%13 = load i32, i32* %3
%14 = icmp ugt i32 %13, 255
%15 = select i1 %12, i1 true, i1 %14
%16 = load i32, i32* %4
%17 = icmp ugt i32 %16, 255
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %25, label %19
19: ; preds = %1
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = icmp ult i32 %20, 256
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %22, %19, %1
%26 = phi i32 [ 0, %1 ], [ 0, %19 ], [ %24, %22 ]
ret i32 %26
}