#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ search(int /*<<< orphan*/, char *, int *, char **, int *);
int strlen(char *);
char **restoreIpAddresses(char *s, int *size) {
  int len = strlen(s);
  if (len > 12 || len < 4)
    return NULL;
  int stack[4] = {0};
  char **table = (char **)malloc(sizeof(char *) * 100);
  search(0, s, stack, table, size);
  return table;
}


x86 assembly (clang, -O0):
<restoreIpAddresses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xc,-0x1c(%rbp)
jg     1170 <restoreIpAddresses+0x30>
cmpl   $0x4,-0x1c(%rbp)
jge    117d <restoreIpAddresses+0x3d>
movq   $0x0,-0x8(%rbp)
jmp    11ba <restoreIpAddresses+0x7a>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    $0x320,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%r8
xor    %edi,%edi
call   1040 <search@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<restoreIpAddresses>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
add    $0xfffffff3,%eax
cmp    $0xfffffff7,%eax
jae    1150 <restoreIpAddresses+0x20>
xor    %ebx,%ebx
jmp    1177 <restoreIpAddresses+0x47>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    $0x320,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rsp,%rdx
xor    %edi,%edi
mov    %r15,%rsi
mov    %rax,%rcx
mov    %r14,%r8
call   1040 <search@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8** @restoreIpAddresses(i8* %0, i32* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca [4 x i32]
%8 = alloca i8**
store i8* %0, i8** %4
store i32* %1, i32** %5
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp sgt i32 %11, 12
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %17
16: ; preds = %13, %2
store i8** null, i8*** %3
br label %27
17: ; preds = %13
%18 = bitcast [4 x i32]* %7 to i8*
%19 = call i64 @malloc(i32 800)
%20 = inttoptr i64 %19 to i8**
store i8** %20, i8*** %8
%21 = load i8*, i8** %4
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%23 = load i8**, i8*** %8
%24 = load i32*, i32** %5
%25 = call i32 @search(i32 0, i8* %21, i32* %22, i8** %23, i32* %24)
%26 = load i8**, i8*** %8
store i8** %26, i8*** %3
br label %27
27: ; preds = %17, %16
%28 = load i8**, i8*** %3
ret i8** %28
}

LLVM IR (-O2):
define i8** @restoreIpAddresses(i8* %0, i32* %1) {
%3 = alloca [4 x i32]
%4 = tail call i32 @strlen(i8* %0)
%5 = add i32 %4, -13
%6 = icmp ult i32 %5, -9
br i1 %6, label %13, label %7
7: ; preds = %2
%8 = bitcast [4 x i32]* %3 to i8*
%9 = tail call i64 @malloc(i32 800)
%10 = inttoptr i64 %9 to i8**
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%12 = call i32 @search(i32 0, i8* %0, i32* %11, i8** %10, i32* %1)
br label %13
13: ; preds = %2, %7
%14 = phi i8** [ %10, %7 ], [ null, %2 ]
ret i8** %14
}