#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 BUFSIZ;
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ *strtok(char *, char *);
int IsIpOK(const char *ip) {
  if (ip == NULL || *ip == '\0')
    return (0);
  char buf[BUFSIZ];
  strcpy(buf, ip);
  if (strtok(buf, ".") == NULL)
    return (0);
  if (strtok(NULL, ".") == NULL)
    return (0);
  if (strtok(NULL, ".") == NULL)
    return (0);
  if (strtok(NULL, ".") == NULL)
    return (0);
  if (strtok(NULL, ".") != NULL)
    return (0);
  return (1);
}


x86 assembly (clang, -O0):
<IsIpOK>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1147 <IsIpOK+0x27>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1153 <IsIpOK+0x33>
movl   $0x0,-0x4(%rbp)
jmp    127e <IsIpOK+0x15e>
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1040 <strtok@plt>
cmp    $0x0,%rax
jne    11b5 <IsIpOK+0x95>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    1277 <IsIpOK+0x157>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe40(%rip),%rsi
call   1040 <strtok@plt>
cmp    $0x0,%rax
jne    11e2 <IsIpOK+0xc2>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    1277 <IsIpOK+0x157>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe13(%rip),%rsi
call   1040 <strtok@plt>
cmp    $0x0,%rax
jne    120f <IsIpOK+0xef>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    1277 <IsIpOK+0x157>
xor    %eax,%eax
mov    %eax,%edi
lea    0xde6(%rip),%rsi
call   1040 <strtok@plt>
cmp    $0x0,%rax
jne    123c <IsIpOK+0x11c>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    1277 <IsIpOK+0x157>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdb9(%rip),%rsi
call   1040 <strtok@plt>
cmp    $0x0,%rax
je     1269 <IsIpOK+0x149>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    1277 <IsIpOK+0x157>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsIpOK>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
xor    %ebx,%ebx
test   %rdi,%rdi
je     11d3 <IsIpOK+0xb3>
mov    %rdi,%rsi
cmpb   $0x0,(%rdi)
je     11d3 <IsIpOK+0xb3>
mov    %rsp,%r14
mov    0x2e98(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strtok@plt>
test   %rax,%rax
je     11ce <IsIpOK+0xae>
lea    0xe82(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <strtok@plt>
test   %rax,%rax
je     11d0 <IsIpOK+0xb0>
lea    0xe6d(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <strtok@plt>
test   %rax,%rax
je     11d0 <IsIpOK+0xb0>
lea    0xe58(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <strtok@plt>
test   %rax,%rax
je     11d0 <IsIpOK+0xb0>
lea    0xe43(%rip),%rsi
xor    %edi,%edi
call   1040 <strtok@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
jmp    11d0 <IsIpOK+0xb0>
xor    %ebx,%ebx
mov    %r14,%rsp
mov    %ebx,%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [2 x i8] c".\00"
define i32 @IsIpOK(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %29, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %29, label %6
6: ; preds = %3
%7 = load i32, i32* @BUFSIZ
%8 = zext i32 %7 to i64
%9 = tail call i8* @llvm.stacksave()
%10 = alloca i8, i64 %8
%11 = call i32 @strcpy(i8* %10, i8* %0)
%12 = call i32* @strtok(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %27, label %14
14: ; preds = %6
%15 = call i32* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %27, label %17
17: ; preds = %14
%18 = call i32* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %27, label %20
20: ; preds = %17
%21 = call i32* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %27, label %23
23: ; preds = %20
%24 = call i32* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i32* %24, null
%26 = zext i1 %25 to i32
br label %27
27: ; preds = %23, %20, %17, %14, %6
%28 = phi i32 [ 0, %6 ], [ 0, %14 ], [ 0, %17 ], [ 0, %20 ], [ %26, %23 ]
br label %29
29: ; preds = %1, %3, %27
%30 = phi i32 [ %28, %27 ], [ 0, %3 ], [ 0, %1 ]
ret i32 %30
}