#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 */
int /*<<< orphan*/ bzero(char *, scalar_t__);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ nameformat(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *strtok(char *, char *);
void nameformatIP(char *ip, char *resu) {
  char *reverse, *temp, *x, *comps[10];
  int px = 0;
  temp = malloc(strlen(ip) + 3);
  reverse = malloc(strlen(ip) + 30);
  bzero(reverse, strlen(ip) + 30);
  strcpy(temp, ip);
  x = strtok(temp, ".");
  while (x != NULL) {
    if (px >= 10) {
      puts("Force DUMP:: dumbass, wtf you think this is, IPV6?");
      exit(1);
    }
    comps[px++] = x;
    x = strtok(NULL, ".");
  }
  for (px--; px >= 0; px--) {
    strcat(reverse, comps[px]);
    strcat(reverse, ".");
  }
  strcat(reverse, "in-addr.arpa");
  nameformat(reverse, resu);
  free(temp);
  free(reverse);
}


x86 assembly (clang, -O0):
<nameformatIP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x1e,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x90(%rbp),%rdi
mov    %rax,%rsi
add    $0x1e,%rsi
call   10a0 <bzero@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     129a <nameformatIP+0xfa>
cmpl   $0xa,-0x84(%rbp)
jl     1265 <nameformatIP+0xc5>
lea    0xdac(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x28(%rbp),%rcx
mov    -0x84(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x84(%rbp)
cltq
mov    %rcx,-0x80(%rbp,%rax,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd74(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    1237 <nameformatIP+0x97>
mov    -0x84(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jl     12ef <nameformatIP+0x14f>
mov    -0x18(%rbp),%rdi
movslq -0x84(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rsi
call   10b0 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xd2a(%rip),%rsi
call   10b0 <strcat@plt>
mov    -0x84(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x84(%rbp)
jmp    12a9 <nameformatIP+0x109>
mov    -0x18(%rbp),%rdi
lea    0xd3b(%rip),%rsi
call   10b0 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <nameformat@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nameformatIP>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%r14
mov    %rdi,%r13
call   1060 <strlen@plt>
mov    %rax,%rbx
lea    0x3(%rax),%rdi
call   1080 <malloc@plt>
mov    %rax,%r15
add    $0x1e,%rbx
mov    %rbx,%rdi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %rbx,%rsi
call   10a0 <bzero@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
lea    0xe0d(%rip),%rsi
mov    %r15,%rdi
call   1090 <strtok@plt>
test   %rax,%rax
je     13a2 <nameformatIP+0x202>
mov    %rax,(%rsp)
lea    0xdf1(%rip),%rsi
xor    %edi,%edi
call   1090 <strtok@plt>
test   %rax,%rax
je     132a <nameformatIP+0x18a>
mov    %rax,0x8(%rsp)
lea    0xdd5(%rip),%rsi
xor    %edi,%edi
call   1090 <strtok@plt>
test   %rax,%rax
je     1331 <nameformatIP+0x191>
mov    %rax,0x10(%rsp)
lea    0xdb9(%rip),%rsi
xor    %edi,%edi
call   1090 <strtok@plt>
test   %rax,%rax
je     1338 <nameformatIP+0x198>
mov    %rax,0x18(%rsp)
lea    0xd9d(%rip),%rsi
xor    %edi,%edi
call   1090 <strtok@plt>
test   %rax,%rax
je     133f <nameformatIP+0x19f>
mov    %rax,0x20(%rsp)
lea    0xd81(%rip),%rsi
xor    %edi,%edi
call   1090 <strtok@plt>
test   %rax,%rax
je     1346 <nameformatIP+0x1a6>
mov    %rax,0x28(%rsp)
lea    0xd65(%rip),%rsi
xor    %edi,%edi
call   1090 <strtok@plt>
test   %rax,%rax
je     134d <nameformatIP+0x1ad>
mov    %rax,0x30(%rsp)
lea    0xd49(%rip),%rsi
xor    %edi,%edi
call   1090 <strtok@plt>
test   %rax,%rax
je     1354 <nameformatIP+0x1b4>
mov    %rax,0x38(%rsp)
lea    0xd2d(%rip),%rsi
xor    %edi,%edi
call   1090 <strtok@plt>
test   %rax,%rax
je     135b <nameformatIP+0x1bb>
mov    %rax,0x40(%rsp)
lea    0xd15(%rip),%rsi
xor    %edi,%edi
call   1090 <strtok@plt>
test   %rax,%rax
je     1362 <nameformatIP+0x1c2>
mov    %rax,0x48(%rsp)
lea    0xcfd(%rip),%rsi
xor    %edi,%edi
call   1090 <strtok@plt>
mov    $0xa,%ebx
test   %rax,%rax
je     1367 <nameformatIP+0x1c7>
lea    0xce7(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    $0x1,%ebx
jmp    1367 <nameformatIP+0x1c7>
mov    $0x2,%ebx
jmp    1367 <nameformatIP+0x1c7>
mov    $0x3,%ebx
jmp    1367 <nameformatIP+0x1c7>
mov    $0x4,%ebx
jmp    1367 <nameformatIP+0x1c7>
mov    $0x5,%ebx
jmp    1367 <nameformatIP+0x1c7>
mov    $0x6,%ebx
jmp    1367 <nameformatIP+0x1c7>
mov    $0x7,%ebx
jmp    1367 <nameformatIP+0x1c7>
mov    $0x8,%ebx
jmp    1367 <nameformatIP+0x1c7>
mov    $0x9,%ebx
add    $0x1,%rbx
lea    0xc8e(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    -0x10(%rsp,%rbx,8),%rsi
mov    %r12,%rdi
call   10b0 <strcat@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   10b0 <strcat@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1380 <nameformatIP+0x1e0>
lea    0xc8c(%rip),%rsi
mov    %r12,%rdi
call   10b0 <strcat@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <nameformat@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [51 x i8] c"Force DUMP:: dumbass, wtf you think this is, IPV6?\00"
@.str.2 = [13 x i8] c"in-addr.arpa\00"
define void @nameformatIP(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [10 x i8*]
%9 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %9
%10 = load i8*, i8** %3
%11 = call i64 @strlen(i8* %10)
%12 = add nsw i64 %11, 3
%13 = call i8* @malloc(i64 %12)
store i8* %13, i8** %6
%14 = load i8*, i8** %3
%15 = call i64 @strlen(i8* %14)
%16 = add nsw i64 %15, 30
%17 = call i8* @malloc(i64 %16)
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = load i8*, i8** %3
%20 = call i64 @strlen(i8* %19)
%21 = add nsw i64 %20, 30
%22 = call i32 @bzero(i8* %18, i64 %21)
%23 = load i8*, i8** %6
%24 = load i8*, i8** %3
%25 = call i32 @strcpy(i8* %23, i8* %24)
%26 = load i8*, i8** %6
%27 = call i8* @strtok(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %27, i8** %7
br label %28
28: ; preds = %37, %2
%29 = load i8*, i8** %7
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %44
31: ; preds = %28
%32 = load i32, i32* %9
%33 = icmp sge i32 %32, 10
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = call i32 @puts(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %31
%38 = load i8*, i8** %7
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
%41 = sext i32 %39 to i64
%42 = getelementptr inbounds [10 x i8*], [10 x i8*]* %8, i64 0, i64 %41
store i8* %38, i8** %42
%43 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %43, i8** %7
br label %28
44: ; preds = %28
%45 = load i32, i32* %9
%46 = add nsw i32 %45, -1
store i32 %46, i32* %9
br label %47
47: ; preds = %59, %44
%48 = load i32, i32* %9
%49 = icmp sge i32 %48, 0
br i1 %49, label %50, label %62
50: ; preds = %47
%51 = load i8*, i8** %5
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [10 x i8*], [10 x i8*]* %8, i64 0, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 @strcat(i8* %51, i8* %55)
%57 = load i8*, i8** %5
%58 = call i32 @strcat(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %59
59: ; preds = %50
%60 = load i32, i32* %9
%61 = add nsw i32 %60, -1
store i32 %61, i32* %9
br label %47
62: ; preds = %47
%63 = load i8*, i8** %5
%64 = call i32 @strcat(i8* %63, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%65 = load i8*, i8** %5
%66 = load i8*, i8** %4
%67 = call i32 @nameformat(i8* %65, i8* %66)
%68 = load i8*, i8** %6
%69 = call i32 @free(i8* %68)
%70 = load i8*, i8** %5
%71 = call i32 @free(i8* %70)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [51 x i8] c"Force DUMP:: dumbass, wtf you think this is, IPV6?\00"
@.str.2 = [13 x i8] c"in-addr.arpa\00"
define void @nameformatIP(i8* %0, i8* %1) {
%3 = alloca [10 x i8*]
%4 = bitcast [10 x i8*]* %3 to i8*
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = add nsw i64 %5, 3
%7 = tail call i8* @malloc(i64 %6)
%8 = add nsw i64 %5, 30
%9 = tail call i8* @malloc(i64 %8)
%10 = tail call i32 @bzero(i8* %9, i64 %8)
%11 = tail call i32 @strcpy(i8* %7, i8* %0)
%12 = tail call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i8* %12, null
br i1 %13, label %67, label %14
14: ; preds = %2
%15 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 0
store i8* %12, i8** %15
%16 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i8* %16, null
br i1 %17, label %57, label %21
18: ; preds = %53
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %14
%22 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 1
store i8* %16, i8** %22
%23 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i8* %23, null
br i1 %24, label %57, label %25
25: ; preds = %21
%26 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 2
store i8* %23, i8** %26
%27 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%28 = icmp eq i8* %27, null
br i1 %28, label %57, label %29
29: ; preds = %25
%30 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 3
store i8* %27, i8** %30
%31 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%32 = icmp eq i8* %31, null
br i1 %32, label %57, label %33
33: ; preds = %29
%34 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 4
store i8* %31, i8** %34
%35 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%36 = icmp eq i8* %35, null
br i1 %36, label %57, label %37
37: ; preds = %33
%38 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 5
store i8* %35, i8** %38
%39 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%40 = icmp eq i8* %39, null
br i1 %40, label %57, label %41
41: ; preds = %37
%42 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 6
store i8* %39, i8** %42
%43 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%44 = icmp eq i8* %43, null
br i1 %44, label %57, label %45
45: ; preds = %41
%46 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 7
store i8* %43, i8** %46
%47 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%48 = icmp eq i8* %47, null
br i1 %48, label %57, label %49
49: ; preds = %45
%50 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 8
store i8* %47, i8** %50
%51 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%52 = icmp eq i8* %51, null
br i1 %52, label %57, label %53
53: ; preds = %49
%54 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 9
store i8* %51, i8** %54
%55 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%56 = icmp eq i8* %55, null
br i1 %56, label %57, label %18
57: ; preds = %53, %49, %45, %41, %37, %33, %29, %25, %21, %14
%58 = phi i64 [ 1, %14 ], [ 2, %21 ], [ 3, %25 ], [ 4, %29 ], [ 5, %33 ], [ 6, %37 ], [ 7, %41 ], [ 8, %45 ], [ 9, %49 ], [ 10, %53 ]
br label %59
59: ; preds = %57, %59
%60 = phi i64 [ %61, %59 ], [ %58, %57 ]
%61 = add nsw i64 %60, -1
%62 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %61
%63 = load i8*, i8** %62
%64 = tail call i32 @strcat(i8* %9, i8* %63)
%65 = tail call i32 @strcat(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%66 = icmp ugt i64 %60, 1
br i1 %66, label %59, label %67
67: ; preds = %59, %2
%68 = tail call i32 @strcat(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%69 = tail call i32 @nameformat(i8* %9, i8* %1)
%70 = tail call i32 @free(i8* %7)
%71 = tail call i32 @free(i8* %9)
ret void
}