#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*/ sscanf(char *, char *, unsigned char *, unsigned char *,
                          unsigned char *, unsigned char *);
unsigned int dotted_decimal_to_int(char ip[]) {
  unsigned char bytes[4] = {0};
  sscanf(ip, "%hhd.%hhd.%hhd.%hhd", &bytes[3], &bytes[2], &bytes[1], &bytes[0]);
  return bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24;
}


x86 assembly (clang, -O0):
<dotted_decimal_to_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rdx
add    $0x3,%rdx
lea    -0xc(%rbp),%rcx
add    $0x2,%rcx
lea    -0xc(%rbp),%r8
add    $0x1,%r8
lea    -0xc(%rbp),%r9
lea    0xe9d(%rip),%rsi
call   1040 <sscanf@plt>
movzbl -0xc(%rbp),%eax
movzbl -0xb(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movzbl -0xa(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
movzbl -0x9(%rbp),%ecx
shl    $0x18,%ecx
or     %ecx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dotted_decimal_to_int>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0x7(%rsp),%rdx
lea    0x6(%rsp),%rcx
lea    0x5(%rsp),%r8
lea    0xed1(%rip),%rsi
lea    0x4(%rsp),%r9
call   1030 <sscanf@plt>
mov    0x4(%rsp),%eax
pop    %rcx
ret

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

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