#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*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ atol(char *);
char *strtok(char *, char *);
void TransIP(char *str, uint8_t iphex[4]) {
  char *p;
  int count = 0;
  p = strtok(str, ".");
  if (p != NULL) {
    iphex[count++] = atol(p);
    while (1) {
      p = strtok(NULL, ".");
      if (p == NULL)
        break;
      else
        iphex[count++] = atol(p);
    }
  }
  return;
}


x86 assembly (clang, -O0):
<TransIP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c4 <TransIP+0xa4>
mov    -0x18(%rbp),%rdi
call   1030 <atol@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe7f(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119a <TransIP+0x7a>
jmp    11bf <TransIP+0x9f>
mov    -0x18(%rbp),%rdi
call   1030 <atol@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1176 <TransIP+0x56>
jmp    11c4 <TransIP+0xa4>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TransIP>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
lea    0xed2(%rip),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     117d <TransIP+0x5d>
mov    %rax,%rdi
call   1030 <atol@plt>
mov    %eax,(%rbx)
lea    0xeb7(%rip),%rsi
xor    %edi,%edi
call   1040 <strtok@plt>
test   %rax,%rax
je     117d <TransIP+0x5d>
add    $0x4,%rbx
lea    0xea0(%rip),%r14
mov    %rax,%rdi
call   1030 <atol@plt>
mov    %eax,(%rbx)
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
add    $0x4,%rbx
test   %rax,%rax
jne    1160 <TransIP+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
define void @TransIP(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 0, i32* %6
%7 = load i8*, i8** %3
%8 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %34
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = call i32 @atol(i8* %12)
%14 = load i32*, i32** %4
%15 = load i32, i32* %6
%16 = add nsw i32 %15, 1
store i32 %16, i32* %6
%17 = sext i32 %15 to i64
%18 = getelementptr inbounds i32, i32* %14, i64 %17
store i32 %13, i32* %18
br label %19
19: ; preds = %11, %32
%20 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %5
%21 = load i8*, i8** %5
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %24
23: ; preds = %19
br label %33
24: ; preds = %19
%25 = load i8*, i8** %5
%26 = call i32 @atol(i8* %25)
%27 = load i32*, i32** %4
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds i32, i32* %27, i64 %30
store i32 %26, i32* %31
br label %32
32: ; preds = %24
br label %19
33: ; preds = %23
br label %34
34: ; preds = %33, %2
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
define void @TransIP(i8* %0, i32* nocapture writeonly %1) {
%3 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %17, label %5
5: ; preds = %2
%6 = tail call i32 @atol(i8* %3)
store i32 %6, i32* %1
%7 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %17, label %9
9: ; preds = %5, %9
%10 = phi i64 [ %13, %9 ], [ 1, %5 ]
%11 = phi i8* [ %15, %9 ], [ %7, %5 ]
%12 = tail call i32 @atol(i8* %11)
%13 = add nuw i64 %10, 1
%14 = getelementptr inbounds i32, i32* %1, i64 %10
store i32 %12, i32* %14
%15 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %9
17: ; preds = %9, %5, %2
ret void
}