#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*/ reverse_str(char *, int, int);
int strlen(char *);
void reverse_domain(char *strInput) {
  reverse_str(strInput, 0, strlen(strInput) - 1);
  char *strStart = strInput;
  int nStart = 0;
  int nEnd = 0;
  while (*strInput != '\0') {
    if (*strInput == '.') {
      reverse_str(strStart, nStart, nEnd - 1);
      nStart = nEnd + 1;
      strStart = strInput;
    }
    nEnd++;
    strInput++;
  }
}


x86 assembly (clang, -O0):
<reverse_domain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <reverse_str@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c0 <reverse_domain+0xa0>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11a6 <reverse_domain+0x86>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
call   1040 <reverse_str@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1163 <reverse_domain+0x43>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_domain>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    -0x1(%rax),%edx
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <reverse_str@plt>
mov    %rbx,%rdi
xor    %ebp,%ebp
jmp    1168 <reverse_domain+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x1(%rbp),%edx
mov    %r14d,%esi
call   1040 <reverse_str@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
add    $0x1,%rbx
mov    %ebp,%r14d
movzbl (%rbx),%eax
cmp    $0x2e,%al
je     1150 <reverse_domain+0x30>
test   %al,%al
je     117c <reverse_domain+0x5c>
add    $0x1,%ebp
add    $0x1,%rbx
jmp    1168 <reverse_domain+0x48>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @reverse_domain(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = sub nsw i32 %8, 1
%10 = call i32 @reverse_str(i8* %6, i32 0, i32 %9)
%11 = load i8*, i8** %2
store i8* %11, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %12
12: ; preds = %31, %1
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %36
17: ; preds = %12
%18 = load i8*, i8** %2
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 46
br i1 %21, label %22, label %31
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = sub nsw i32 %25, 1
%27 = call i32 @reverse_str(i8* %23, i32 %24, i32 %26)
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
%30 = load i8*, i8** %2
store i8* %30, i8** %3
br label %31
31: ; preds = %22, %17
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
%34 = load i8*, i8** %2
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %2
br label %12
36: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @reverse_domain(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = tail call i32 @reverse_str(i8* %0, i32 0, i32 %3)
br label %5
5: ; preds = %17, %1
%6 = phi i8* [ %0, %1 ], [ %21, %17 ]
%7 = phi i8* [ %0, %1 ], [ %19, %17 ]
%8 = phi i32 [ 0, %1 ], [ %20, %17 ]
%9 = phi i32 [ 0, %1 ], [ %18, %17 ]
%10 = load i8, i8* %6
switch i8 %10, label %11 [
i8 0, label %22
i8 46, label %13
]
11: ; preds = %5
%12 = add nuw nsw i32 %9, 1
br label %17
13: ; preds = %5
%14 = add nsw i32 %9, -1
%15 = tail call i32 @reverse_str(i8* %7, i32 %8, i32 %14)
%16 = add nuw nsw i32 %9, 1
br label %17
17: ; preds = %11, %13
%18 = phi i32 [ %12, %11 ], [ %16, %13 ]
%19 = phi i8* [ %7, %11 ], [ %6, %13 ]
%20 = phi i32 [ %8, %11 ], [ %16, %13 ]
%21 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
22: ; preds = %5
ret void
}