#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 */
unsigned char atoi(char *);
int /*<<< orphan*/ errAbort(char *, char *);
int /*<<< orphan*/ internetIsDottedQuad(char *);
char *strchr(char *, char);
void internetParseDottedQuad(char *dottedQuad, unsigned char quad[4]) {
  char *s = dottedQuad;
  int i;
  if (!internetIsDottedQuad(s))
    errAbort("%s is not a dotted quad", s);
  for (i = 0; i < 4; ++i) {
    quad[i] = atoi(s);
    s = strchr(s, '.') + 1;
  }
}


x86 assembly (clang, -O0):
<internetParseDottedQuad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <internetIsDottedQuad@plt>
cmp    $0x0,%eax
jne    117a <internetParseDottedQuad+0x3a>
mov    -0x18(%rbp),%rsi
lea    0xe8b(%rip),%rdi
call   1040 <errAbort@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11c5 <internetParseDottedQuad+0x85>
mov    -0x18(%rbp),%rdi
call   1060 <atoi@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1181 <internetParseDottedQuad+0x41>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<internetParseDottedQuad>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <internetIsDottedQuad@plt>
test   %eax,%eax
jne    1162 <internetParseDottedQuad+0x22>
lea    0xea6(%rip),%rdi
mov    %rbx,%rsi
call   1040 <errAbort@plt>
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %al,(%r14)
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
lea    0x1(%rax),%rbx
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %al,0x1(%r14)
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
lea    0x1(%rax),%rbx
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %al,0x2(%r14)
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
lea    0x1(%rax),%rdi
call   1060 <atoi@plt>
mov    %al,0x3(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"%s is not a dotted quad\00"
define void @internetParseDottedQuad(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @internetIsDottedQuad(i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = call i32 @errAbort(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %2
store i32 0, i32* %6
br label %15
15: ; preds = %28, %14
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %31
18: ; preds = %15
%19 = load i8*, i8** %5
%20 = call zeroext i8 @atoi(i8* %19)
%21 = load i8*, i8** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 %20, i8* %24
%25 = load i8*, i8** %5
%26 = call i8* @strchr(i8* %25, i8 signext 46)
%27 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %27, i8** %5
br label %28
28: ; preds = %18
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %15
31: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"%s is not a dotted quad\00"
define void @internetParseDottedQuad(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @internetIsDottedQuad(i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @errAbort(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %7
7: ; preds = %5, %2
%8 = tail call zeroext i8 @atoi(i8* %0)
store i8 %8, i8* %1
%9 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 46)
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = tail call zeroext i8 @atoi(i8* %10)
%12 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %11, i8* %12
%13 = tail call i8* @strchr(i8* dereferenceable(1) %10, i8 signext 46)
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = tail call zeroext i8 @atoi(i8* %14)
%16 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %15, i8* %16
%17 = tail call i8* @strchr(i8* dereferenceable(1) %14, i8 signext 46)
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = tail call zeroext i8 @atoi(i8* %18)
%20 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %19, i8* %20
ret void
}