#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*/ free(char *);
scalar_t__ pow(int, int);
char *strdup(char *);
char *strtok_r(char *, char *, char **);
unsigned int strtoul(char *, int /*<<< orphan*/ *, int);
unsigned int ipUtils_ipToUnsignedInt(char *ip) {
  unsigned int ipAsUint = 0;
  char *partOfIp = NULL, *savePtr = NULL;
  char *input = strdup(ip);
  partOfIp = strtok_r(input, ".\0", &savePtr);
  ipAsUint += strtoul(partOfIp, NULL, 10) * (unsigned int)pow(256, 3);
  partOfIp = strtok_r(NULL, ".\0", &savePtr);
  ipAsUint += strtoul(partOfIp, NULL, 10) * (unsigned int)pow(256, 2);
  partOfIp = strtok_r(NULL, ".\0", &savePtr);
  ipAsUint += strtoul(partOfIp, NULL, 10) * (unsigned int)pow(256, 1);
  partOfIp = strtok_r(NULL, ".\0", &savePtr);
  ipAsUint += strtoul(partOfIp, NULL, 10) * (unsigned int)pow(256, 0);
  free(input);
  return ipAsUint;
}


x86 assembly (clang, -O0):
<ipUtils_ipToUnsignedInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe75(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x38(%rbp)
mov    $0x100,%edi
mov    $0x3,%esi
call   1050 <pow@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%eax
imul   %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe2a(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x34(%rbp)
mov    $0x100,%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %rax,%rcx
mov    -0x34(%rbp),%eax
imul   %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xddf(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x30(%rbp)
mov    $0x100,%edi
mov    $0x1,%esi
call   1050 <pow@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%eax
imul   %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd94(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x100,%edi
xor    %esi,%esi
call   1050 <pow@plt>
mov    %rax,%rcx
mov    -0x2c(%rbp),%eax
imul   %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipUtils_ipToUnsignedInt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movq   $0x0,(%rsp)
call   1070 <strdup@plt>
mov    %rax,%r14
lea    0xe8e(%rip),%r12
mov    %rsp,%r15
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1040 <strtok_r@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebx
mov    $0x100,%edi
mov    $0x3,%esi
call   1050 <pow@plt>
mov    %rax,%r13
imul   %ebx,%r13d
xor    %edi,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   1040 <strtok_r@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebp
mov    $0x100,%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %rax,%rbx
imul   %ebp,%ebx
add    %r13d,%ebx
xor    %edi,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   1040 <strtok_r@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%r13d
mov    $0x100,%edi
mov    $0x1,%esi
call   1050 <pow@plt>
mov    %rax,%rbp
imul   %r13d,%ebp
add    %ebx,%ebp
xor    %edi,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   1040 <strtok_r@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%r15d
mov    $0x100,%edi
xor    %esi,%esi
call   1050 <pow@plt>
mov    %rax,%rbx
imul   %r15d,%ebx
add    %ebp,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c".\00\00"
define i32 @ipUtils_ipToUnsignedInt(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
store i8* null, i8** %4
store i8* null, i8** %5
%7 = load i8*, i8** %2
%8 = call i8* @strdup(i8* %7)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = call i8* @strtok_r(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %5)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = call i32 @strtoul(i8* %11, i32* null, i32 10)
%13 = call i64 @pow(i32 256, i32 3)
%14 = trunc i64 %13 to i32
%15 = mul i32 %12, %14
%16 = load i32, i32* %3
%17 = add i32 %16, %15
store i32 %17, i32* %3
%18 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %5)
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = call i32 @strtoul(i8* %19, i32* null, i32 10)
%21 = call i64 @pow(i32 256, i32 2)
%22 = trunc i64 %21 to i32
%23 = mul i32 %20, %22
%24 = load i32, i32* %3
%25 = add i32 %24, %23
store i32 %25, i32* %3
%26 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %5)
store i8* %26, i8** %4
%27 = load i8*, i8** %4
%28 = call i32 @strtoul(i8* %27, i32* null, i32 10)
%29 = call i64 @pow(i32 256, i32 1)
%30 = trunc i64 %29 to i32
%31 = mul i32 %28, %30
%32 = load i32, i32* %3
%33 = add i32 %32, %31
store i32 %33, i32* %3
%34 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %5)
store i8* %34, i8** %4
%35 = load i8*, i8** %4
%36 = call i32 @strtoul(i8* %35, i32* null, i32 10)
%37 = call i64 @pow(i32 256, i32 0)
%38 = trunc i64 %37 to i32
%39 = mul i32 %36, %38
%40 = load i32, i32* %3
%41 = add i32 %40, %39
store i32 %41, i32* %3
%42 = load i8*, i8** %6
%43 = call i32 @free(i8* %42)
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str = [3 x i8] c".\00\00"
define i32 @ipUtils_ipToUnsignedInt(i8* nocapture %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = tail call i8* @strdup(i8* %0)
%5 = call i8* @strtok_r(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2)
%6 = call i32 @strtoul(i8* nocapture %5, i32* null, i32 10)
%7 = call i64 @pow(i32 256, i32 3)
%8 = trunc i64 %7 to i32
%9 = mul i32 %6, %8
%10 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2)
%11 = call i32 @strtoul(i8* nocapture %10, i32* null, i32 10)
%12 = call i64 @pow(i32 256, i32 2)
%13 = trunc i64 %12 to i32
%14 = mul i32 %11, %13
%15 = add i32 %14, %9
%16 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2)
%17 = call i32 @strtoul(i8* nocapture %16, i32* null, i32 10)
%18 = call i64 @pow(i32 256, i32 1)
%19 = trunc i64 %18 to i32
%20 = mul i32 %17, %19
%21 = add i32 %15, %20
%22 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2)
%23 = call i32 @strtoul(i8* nocapture %22, i32* null, i32 10)
%24 = call i64 @pow(i32 256, i32 0)
%25 = trunc i64 %24 to i32
%26 = mul i32 %23, %25
%27 = add i32 %21, %26
%28 = call i32 @free(i8* %4)
ret i32 %27
}