#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*/ xbuf;
typedef scalar_t__ u_int32_t;
typedef int /*<<< orphan*/ u_char;

/* Variables and functions */
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ memset(char **, int /*<<< orphan*/, int);
int /*<<< orphan*/ str2e(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int ec_a2o(char *cp, u_int32_t *op) {
  char xbuf[128];
  u_char e[6];
  memset(&xbuf, 0, sizeof(xbuf));
  strncpy(xbuf, &cp[0], 2);
  strcat(xbuf, ":");
  strncat(xbuf, &cp[2], 2);
  strcat(xbuf, ":");
  strncat(xbuf, &cp[4], 2);
  strcat(xbuf, ":0:0:0");
  if (!str2e(xbuf, e))
    return (0);
  *op = 0;
  memmove((char *)op, (char *)e, 3);
  return (1);
}


x86 assembly (clang, -O0):
<ec_a2o>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1080 <strcat@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x2,%rsi
mov    $0x2,%edx
call   1060 <strncat@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1080 <strcat@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x4,%rsi
mov    $0x2,%edx
call   1060 <strncat@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   1080 <strcat@plt>
lea    -0xa0(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
call   1040 <str2e@plt>
cmp    $0x0,%eax
jne    122e <ec_a2o+0xce>
movl   $0x0,-0x4(%rbp)
jmp    1255 <ec_a2o+0xf5>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
mov    $0x3,%edx
call   1070 <memmove@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ec_a2o>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xa0,%rsp
mov    %rsi,%r14
mov    %rdi,%rbp
lea    0x20(%rsp),%rbx
xor    %r15d,%r15d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
lea    0xe5d(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
lea    0x2(%rbp),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1060 <strncat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
add    $0x4,%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1060 <strncat@plt>
lea    0xe1d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <str2e@plt>
test   %eax,%eax
je     1219 <ec_a2o+0xb9>
movq   $0x0,(%r14)
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x3,%edx
call   1070 <memmove@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@.str.1 = [7 x i8] c":0:0:0\00"
define i32 @ec_a2o(i8* %0, i64* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca [128 x i8]
%7 = alloca [6 x i32]
store i8* %0, i8** %4
store i64* %1, i64** %5
%8 = bitcast [128 x i8]* %6 to i8**
%9 = call i32 @memset(i8** %8, i32 0, i32 128)
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = call i32 @strncpy(i8* %10, i8* %12, i32 2)
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 2
%19 = call i32 @strncat(i8* %16, i8* %18, i32 2)
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 4
%25 = call i32 @strncat(i8* %22, i8* %24, i32 2)
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%27 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %7, i64 0, i64 0
%30 = call i32 @str2e(i8* %28, i32* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %2
store i32 0, i32* %3
br label %40
33: ; preds = %2
%34 = load i64*, i64** %5
store i64 0, i64* %34
%35 = load i64*, i64** %5
%36 = bitcast i64* %35 to i8*
%37 = getelementptr inbounds [6 x i32], [6 x i32]* %7, i64 0, i64 0
%38 = bitcast i32* %37 to i8*
%39 = call i32 @memmove(i8* %36, i8* %38, i32 3)
store i32 1, i32* %3
br label %40
40: ; preds = %33, %32
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@.str.1 = [7 x i8] c":0:0:0\00"
define i32 @ec_a2o(i8* %0, i64* %1) {
%3 = alloca [128 x i8]
%4 = alloca [6 x i32]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = bitcast [6 x i32]* %4 to i8*
%7 = bitcast [128 x i8]* %3 to i8**
%8 = call i32 @memset(i8** %7, i32 0, i32 128)
%9 = call i32 @strncpy(i8* %5, i8* %0, i32 2)
%10 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds i8, i8* %0, i64 2
%12 = call i32 @strncat(i8* %5, i8* %11, i32 2)
%13 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds i8, i8* %0, i64 4
%15 = call i32 @strncat(i8* %5, i8* %14, i32 2)
%16 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%18 = call i32 @str2e(i8* %5, i32* %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %2
store i64 0, i64* %1
%21 = bitcast i64* %1 to i8*
%22 = call i32 @memmove(i8* %21, i8* %6, i32 3)
br label %23
23: ; preds = %2, %20
%24 = phi i32 [ 1, %20 ], [ 0, %2 ]
ret i32 %24
}