#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ sscanf(char *, char *, int *, int *, int *, int *);
uint32_t cast_IPv4_to_uint(char *ipAddress) {
  uint32_t ipbytes[4];
  sscanf(ipAddress, "%u.%u.%u.%u", &ipbytes[3], &ipbytes[2], &ipbytes[1],
         &ipbytes[0]);
  return ipbytes[0] | ipbytes[1] << 8 | ipbytes[2] << 16 | ipbytes[3] << 24;
}


x86 assembly (clang, -O0):
<cast_IPv4_to_uint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rdx
add    $0xc,%rdx
lea    -0x20(%rbp),%rcx
add    $0x8,%rcx
lea    -0x20(%rbp),%r8
add    $0x4,%r8
lea    -0x20(%rbp),%r9
lea    0xebd(%rip),%rsi
call   1030 <sscanf@plt>
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x14(%rbp),%ecx
shl    $0x18,%ecx
or     %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cast_IPv4_to_uint>:
sub    $0x18,%rsp
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
lea    0xed6(%rip),%rsi
mov    %rsp,%r9
call   1030 <sscanf@plt>
mov    0x4(%rsp),%ecx
mov    0x8(%rsp),%edx
shl    $0x8,%ecx
or     (%rsp),%ecx
shl    $0x10,%edx
mov    0xc(%rsp),%eax
shl    $0x18,%eax
or     %edx,%eax
or     %ecx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i32 @cast_IPv4_to_uint(i8* %0) {
%2 = alloca i8*
%3 = alloca [4 x i32]
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%9 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7, i32* %8)
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%13 = load i32, i32* %12
%14 = shl i32 %13, 8
%15 = or i32 %11, %14
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%17 = load i32, i32* %16
%18 = shl i32 %17, 16
%19 = or i32 %15, %18
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
%21 = load i32, i32* %20
%22 = shl i32 %21, 24
%23 = or i32 %19, %22
ret i32 %23
}

LLVM IR (-O2):
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i32 @cast_IPv4_to_uint(i8* nocapture %0) {
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %2 to i8*
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%8 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i32* %7)
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = shl i32 %10, 8
%12 = or i32 %11, %9
%13 = load i32, i32* %5
%14 = shl i32 %13, 16
%15 = or i32 %12, %14
%16 = load i32, i32* %4
%17 = shl i32 %16, 24
%18 = or i32 %15, %17
ret i32 %18
}