#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
scalar_t__ inet_aton(char *, TYPE_1__ *);
int SetAddress(char *Composite, struct sockaddr_in *Addr) {
  int i;
  char IPAddress[16];
  bzero(Addr, sizeof(*Addr));
  Addr->sin_family = AF_INET;
  for (i = 0; Composite[i] != ':' && Composite[i] != 0 && i < 16; i++)
    IPAddress[i] = Composite[i];
  IPAddress[i] = 0;
  if (Composite[i] == ':')
    Addr->sin_port = htons(atoi(Composite + i + 1));
  else
    Addr->sin_port = 0;
  if (*IPAddress == 0) {
    Addr->sin_addr.s_addr = INADDR_ANY;
    return 0;
  } else
    return (inet_aton(IPAddress, &Addr->sin_addr) == 0);
}


x86 assembly (clang, -O0):
<SetAddress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0xc,%esi
call   1050 <bzero@plt>
mov    0x2e83(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x3a,%ecx
mov    %al,-0x31(%rbp)
je     11b3 <SetAddress+0x73>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
je     11b3 <SetAddress+0x73>
cmpl   $0x10,-0x1c(%rbp)
setl   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11c3 <SetAddress+0x83>
jmp    11e4 <SetAddress+0xa4>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1175 <SetAddress+0x35>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x30(%rbp,%rax,1)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    122b <SetAddress+0xeb>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
jmp    1236 <SetAddress+0xf6>
mov    -0x18(%rbp),%rax
movl   $0x0,0x4(%rax)
movsbl -0x30(%rbp),%eax
cmp    $0x0,%eax
jne    125e <SetAddress+0x11e>
mov    0x2d96(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    127a <SetAddress+0x13a>
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <inet_aton@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetAddress>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    $0xc,%esi
call   1050 <bzero@plt>
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%r14)
mov    (%rbx),%cl
xor    %eax,%eax
cmp    $0x3a,%cl
je     118b <SetAddress+0x4b>
test   %cl,%cl
je     11a5 <SetAddress+0x65>
cmp    $0xf,%rax
ja     11a5 <SetAddress+0x65>
mov    %cl,(%rsp,%rax,1)
movzbl 0x1(%rbx,%rax,1),%ecx
add    $0x1,%rax
cmp    $0x3a,%cl
jne    1170 <SetAddress+0x30>
movb   $0x0,(%rsp,%rax,1)
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
jmp    11ab <SetAddress+0x6b>
movb   $0x0,(%rsp,%rax,1)
xor    %eax,%eax
mov    %eax,0x4(%r14)
cmpb   $0x0,(%rsp)
je     11cd <SetAddress+0x8d>
mov    %rsp,%rdi
mov    %r14,%rsi
call   1040 <inet_aton@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
jmp    11db <SetAddress+0x9b>
mov    0x2e0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
define i32 @SetAddress(i8* %0, %struct.sockaddr_in* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.sockaddr_in*
%6 = alloca i32
%7 = alloca [16 x i8]
store i8* %0, i8** %4
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %5
%8 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%9 = call i32 @bzero(%struct.sockaddr_in* %8, i32 12)
%10 = load i32, i32* @AF_INET
%11 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %10, i32* %12
store i32 0, i32* %6
br label %13
13: ; preds = %43, %2
%14 = load i8*, i8** %4
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 58
br i1 %20, label %21, label %32
21: ; preds = %13
%22 = load i8*, i8** %4
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %21
%30 = load i32, i32* %6
%31 = icmp slt i32 %30, 16
br label %32
32: ; preds = %29, %21, %13
%33 = phi i1 [ false, %21 ], [ false, %13 ], [ %31, %29 ]
br i1 %33, label %34, label %46
34: ; preds = %32
%35 = load i8*, i8** %4
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %41
store i8 %39, i8* %42
br label %43
43: ; preds = %34
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %13
46: ; preds = %32
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %48
store i8 0, i8* %49
%50 = load i8*, i8** %4
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 58
br i1 %56, label %57, label %67
57: ; preds = %46
%58 = load i8*, i8** %4
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = getelementptr inbounds i8, i8* %61, i64 1
%63 = call i32 @atoi(i8* %62)
%64 = call i32 @htons(i32 %63)
%65 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%66 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %65, i32 0, i32 1
store i32 %64, i32* %66
br label %70
67: ; preds = %46
%68 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%69 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %68, i32 0, i32 1
store i32 0, i32* %69
br label %70
70: ; preds = %67, %57
%71 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %80
75: ; preds = %70
%76 = load i32, i32* @INADDR_ANY
%77 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%78 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %77, i32 0, i32 0
%79 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %78, i32 0, i32 0
store i32 %76, i32* %79
store i32 0, i32* %3
br label %87
80: ; preds = %70
%81 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%82 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%83 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %82, i32 0, i32 0
%84 = call i64 @inet_aton(i8* %81, %struct.TYPE_2__* %83)
%85 = icmp eq i64 %84, 0
%86 = zext i1 %85 to i32
store i32 %86, i32* %3
br label %87
87: ; preds = %80, %75
%88 = load i32, i32* %3
ret i32 %88
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
define i32 @SetAddress(i8* nocapture %0, %struct.sockaddr_in* %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @bzero(%struct.sockaddr_in* %1, i32 12)
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %6, i32* %7
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 58
br i1 %9, label %22, label %10
10: ; preds = %2, %16
%11 = phi i64 [ %18, %16 ], [ 0, %2 ]
%12 = phi i8 [ %20, %16 ], [ %8, %2 ]
%13 = icmp ne i8 %12, 0
%14 = icmp ult i64 %11, 16
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %16, label %29
16: ; preds = %10
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %11
store i8 %12, i8* %17
%18 = add nuw nsw i64 %11, 1
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 58
br i1 %21, label %22, label %10
22: ; preds = %16, %2
%23 = phi i64 [ 0, %2 ], [ %18, %16 ]
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %23
store i8 0, i8* %25
%26 = getelementptr inbounds i8, i8* %24, i64 1
%27 = tail call i32 @atoi(i8* %26)
%28 = tail call i32 @htons(i32 %27)
br label %32
29: ; preds = %10
%30 = and i64 %11, 4294967295
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %30
store i8 0, i8* %31
br label %32
32: ; preds = %29, %22
%33 = phi i32 [ 0, %29 ], [ %28, %22 ]
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i32 %33, i32* %34
%35 = load i8, i8* %4
%36 = icmp eq i8 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i32, i32* @INADDR_ANY
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0, i32 0
store i32 %38, i32* %39
br label %45
40: ; preds = %32
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
%42 = call i64 @inet_aton(i8* %4, %struct.TYPE_2__* %41)
%43 = icmp eq i64 %42, 0
%44 = zext i1 %43 to i32
br label %45
45: ; preds = %40, %37
%46 = phi i32 [ 0, %37 ], [ %44, %40 ]
ret i32 %46
}