#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*/ byte;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
char *getByte(char *IP, int index) {
  int i = 0;
  int separator = 0;
  static char byte[3];
  for (i = 0; i < 4; i++)
    byte[i] = '\0';
  memset(byte, 0, sizeof(byte));
  for (i = 0; i < strlen(IP); i++) {
    if ((IP[i] == '.') && (separator == index - 1)) {
      return byte;
    } else if (IP[i] == '.') {
      separator++;
    } else if (separator == index - 1) {
      strncat(byte, &IP[i], 1);
    }
  }
  return byte;
}


x86 assembly (clang, -O0):
<getByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    117b <getByte+0x4b>
movslq -0x18(%rbp),%rcx
lea    0x2ed0(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1154 <getByte+0x24>
lea    0x2eb7(%rip),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1040 <memset@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    1254 <getByte+0x124>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    11e7 <getByte+0xb7>
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11e7 <getByte+0xb7>
lea    0x2e5b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125f <getByte+0x12f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    120a <getByte+0xda>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    123c <getByte+0x10c>
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1237 <getByte+0x107>
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
lea    0x2e0c(%rip),%rdi
mov    $0x1,%edx
call   1050 <strncat@plt>
jmp    123c <getByte+0x10c>
jmp    1241 <getByte+0x111>
jmp    1246 <getByte+0x116>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1195 <getByte+0x65>
lea    0x2dde(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getByte>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r12
movl   $0x0,0x2ef4(%rip)
lea    0x2eed(%rip),%rdi
xor    %ebp,%ebp
xor    %esi,%esi
mov    $0x3,%edx
call   1040 <memset@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11c3 <getByte+0x93>
add    $0xffffffff,%r15d
lea    0x2ec8(%rip),%r14
xor    %ebx,%ebx
jmp    1196 <getByte+0x66>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
add    $0x1,%rbx
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11c3 <getByte+0x93>
movzbl (%r12,%rbx,1),%eax
cmp    $0x2e,%al
jne    11a4 <getByte+0x74>
cmp    %r15d,%ebp
je     11c3 <getByte+0x93>
cmp    $0x2e,%al
je     1180 <getByte+0x50>
cmp    %r15d,%ebp
jne    1183 <getByte+0x53>
lea    (%r12,%rbx,1),%rsi
mov    %r14,%rdi
mov    $0x1,%edx
call   1050 <strncat@plt>
mov    %r15d,%ebp
jmp    1183 <getByte+0x53>
lea    0x2e72(%rip),%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@getByte.byte = internal global [3 x i8] zeroinitializer
define i8* @getByte(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = 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* %6
br label %8
8: ; preds = %15, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [3 x i8], [3 x i8]* @getByte.byte, i64 0, i64 %13
store i8 0, i8* %14
br label %15
15: ; preds = %11
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
br label %8
18: ; preds = %8
%19 = call i32 @memset(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @getByte.byte, i64 0, i64 0), i32 0, i32 3)
store i32 0, i32* %6
br label %20
20: ; preds = %64, %18
%21 = load i32, i32* %6
%22 = load i8*, i8** %4
%23 = call i32 @strlen(i8* %22)
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %67
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 46
br i1 %32, label %33, label %39
33: ; preds = %25
%34 = load i32, i32* %7
%35 = load i32, i32* %5
%36 = sub nsw i32 %35, 1
%37 = icmp eq i32 %34, %36
br i1 %37, label %38, label %39
38: ; preds = %33
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @getByte.byte, i64 0, i64 0), i8** %3
br label %68
39: ; preds = %33, %25
%40 = load i8*, i8** %4
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 46
br i1 %46, label %47, label %50
47: ; preds = %39
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %62
50: ; preds = %39
%51 = load i32, i32* %7
%52 = load i32, i32* %5
%53 = sub nsw i32 %52, 1
%54 = icmp eq i32 %51, %53
br i1 %54, label %55, label %61
55: ; preds = %50
%56 = load i8*, i8** %4
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = call i32 @strncat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @getByte.byte, i64 0, i64 0), i8* %59, i32 1)
br label %61
61: ; preds = %55, %50
br label %62
62: ; preds = %61, %47
br label %63
63: ; preds = %62
br label %64
64: ; preds = %63
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
store i32 %66, i32* %6
br label %20
67: ; preds = %20
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @getByte.byte, i64 0, i64 0), i8** %3
br label %68
68: ; preds = %67, %38
%69 = load i8*, i8** %3
ret i8* %69
}

LLVM IR (-O2):
@getByte.byte = internal global [3 x i8] zeroinitializer
define i8* @getByte(i8* %0, i32 %1) {
store i32 0, i32* bitcast ([3 x i8]* @getByte.byte to i32*)
%3 = tail call i32 @memset(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @getByte.byte, i64 0, i64 0), i32 0, i32 3)
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %28
6: ; preds = %2
%7 = add nsw i32 %1, -1
br label %8
8: ; preds = %6, %22
%9 = phi i64 [ 0, %6 ], [ %24, %22 ]
%10 = phi i32 [ 0, %6 ], [ %23, %22 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %9
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 46
%14 = icmp eq i32 %10, %7
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %28, label %16
16: ; preds = %8
br i1 %13, label %17, label %19
17: ; preds = %16
%18 = add nsw i32 %10, 1
br label %22
19: ; preds = %16
br i1 %14, label %20, label %22
20: ; preds = %19
%21 = tail call i32 @strncat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @getByte.byte, i64 0, i64 0), i8* %11, i32 1)
br label %22
22: ; preds = %19, %20, %17
%23 = phi i32 [ %18, %17 ], [ %7, %20 ], [ %10, %19 ]
%24 = add nuw nsw i64 %9, 1
%25 = tail call i32 @strlen(i8* %0)
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %8, label %28
28: ; preds = %8, %22, %2
ret i8* getelementptr inbounds ([3 x i8], [3 x i8]* @getByte.byte, i64 0, i64 0)
}