#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 int sscanf(char const *, char *, unsigned int *, unsigned int *,
                    unsigned int *, unsigned int *);
unsigned uInIpv4Format(const char *cIPv4, unsigned *uIPv4) {
  unsigned a = 0, b = 0, c = 0, d = 0, uCount = 0;
  uCount = sscanf(cIPv4, "%u.%u.%u.%u", &a, &b, &c, &d);
  if (uCount != 4)
    return (0);
  if (!a)
    return (0);
  if (b > 254)
    return (0);
  if (c > 254)
    return (0);
  if (d > 254)
    return (0);
  *uIPv4 = d + (c << 8) + (b << 16) + (a << 24);
  return (1);
}


x86 assembly (clang, -O0):
<uInIpv4Format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r8
lea    -0x28(%rbp),%r9
call   1030 <sscanf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
je     117c <uInIpv4Format+0x6c>
movl   $0x0,-0x4(%rbp)
jmp    1205 <uInIpv4Format+0xf5>
cmpl   $0x0,-0x1c(%rbp)
jne    1192 <uInIpv4Format+0x82>
movl   $0x0,-0x4(%rbp)
jmp    1205 <uInIpv4Format+0xf5>
cmpl   $0xfe,-0x20(%rbp)
jbe    11ab <uInIpv4Format+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    1205 <uInIpv4Format+0xf5>
cmpl   $0xfe,-0x24(%rbp)
jbe    11c4 <uInIpv4Format+0xb4>
movl   $0x0,-0x4(%rbp)
jmp    1205 <uInIpv4Format+0xf5>
cmpl   $0xfe,-0x28(%rbp)
jbe    11dd <uInIpv4Format+0xcd>
movl   $0x0,-0x4(%rbp)
jmp    1205 <uInIpv4Format+0xf5>
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%eax
shl    $0x8,%eax
add    %eax,%ecx
mov    -0x20(%rbp),%eax
shl    $0x10,%eax
add    %eax,%ecx
mov    -0x1c(%rbp),%eax
shl    $0x18,%eax
add    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uInIpv4Format>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xec2(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %rsp,%r9
call   1030 <sscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x4,%ecx
jne    119f <uInIpv4Format+0x8f>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     119f <uInIpv4Format+0x8f>
mov    0x8(%rsp),%edx
cmp    $0xfe,%edx
ja     119f <uInIpv4Format+0x8f>
mov    0x4(%rsp),%esi
cmp    $0xfe,%esi
ja     119f <uInIpv4Format+0x8f>
mov    (%rsp),%edi
cmp    $0xfe,%edi
ja     119f <uInIpv4Format+0x8f>
shl    $0x8,%esi
shl    $0x10,%edx
shl    $0x18,%ecx
add    %edx,%ecx
add    %esi,%ecx
add    %edi,%ecx
mov    %ecx,(%rbx)
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i32 @uInIpv4Format(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%11 = load i8*, i8** %4
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %6, i32* %7, i32* %8, i32* %9)
store i32 %12, i32* %10
%13 = load i32, i32* %10
%14 = icmp ne i32 %13, 4
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 0, i32* %3
br label %44
16: ; preds = %2
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %16
store i32 0, i32* %3
br label %44
20: ; preds = %16
%21 = load i32, i32* %7
%22 = icmp ugt i32 %21, 254
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 0, i32* %3
br label %44
24: ; preds = %20
%25 = load i32, i32* %8
%26 = icmp ugt i32 %25, 254
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 0, i32* %3
br label %44
28: ; preds = %24
%29 = load i32, i32* %9
%30 = icmp ugt i32 %29, 254
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 0, i32* %3
br label %44
32: ; preds = %28
%33 = load i32, i32* %9
%34 = load i32, i32* %8
%35 = shl i32 %34, 8
%36 = add i32 %33, %35
%37 = load i32, i32* %7
%38 = shl i32 %37, 16
%39 = add i32 %36, %38
%40 = load i32, i32* %6
%41 = shl i32 %40, 24
%42 = add i32 %39, %41
%43 = load i32*, i32** %5
store i32 %42, i32* %43
store i32 1, i32* %3
br label %44
44: ; preds = %32, %31, %27, %23, %19, %15
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i32 @uInIpv4Format(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%10 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%11 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6)
%12 = icmp eq i32 %11, 4
br i1 %12, label %13, label %32
13: ; preds = %2
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
br i1 %15, label %32, label %16
16: ; preds = %13
%17 = load i32, i32* %4
%18 = icmp ugt i32 %17, 254
br i1 %18, label %32, label %19
19: ; preds = %16
%20 = load i32, i32* %5
%21 = icmp ugt i32 %20, 254
br i1 %21, label %32, label %22
22: ; preds = %19
%23 = load i32, i32* %6
%24 = icmp ugt i32 %23, 254
br i1 %24, label %32, label %25
25: ; preds = %22
%26 = shl nuw nsw i32 %20, 8
%27 = shl nuw nsw i32 %17, 16
%28 = shl i32 %14, 24
%29 = add nuw i32 %27, %28
%30 = add nuw i32 %29, %26
%31 = add nuw i32 %30, %23
store i32 %31, i32* %1
br label %32
32: ; preds = %22, %19, %16, %13, %2, %25
%33 = phi i32 [ 1, %25 ], [ 0, %2 ], [ 0, %13 ], [ 0, %16 ], [ 0, %19 ], [ 0, %22 ]
ret i32 %33
}