#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__ isletdig(char);
int isdomain(char *s) {
  if (!isletdig(*s)) {
    return 0;
  }
  for (; isletdig(*s); s++) {
  }
  for (; (*s == '-') || (isletdig(*s)); s++) {
  }
  if (*(s - 1) == '-') {
    return 0;
  }
  if (*s == '.') {
    s++;
    return (isdomain(s));
  }
  if (*s == '\0') {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<isdomain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isletdig@plt>
cmp    $0x0,%rax
jne    114e <isdomain+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    1242 <isdomain+0x122>
jmp    1153 <isdomain+0x33>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isletdig@plt>
cmp    $0x0,%rax
je     117f <isdomain+0x5f>
jmp    116e <isdomain+0x4e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1153 <isdomain+0x33>
jmp    1184 <isdomain+0x64>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2d,%ecx
mov    %al,-0x11(%rbp)
je     11af <isdomain+0x8f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isletdig@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11bf <isdomain+0x9f>
jmp    11d5 <isdomain+0xb5>
jmp    11c4 <isdomain+0xa4>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1184 <isdomain+0x64>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2d,%eax
jne    11f2 <isdomain+0xd2>
movl   $0x0,-0x4(%rbp)
jmp    1242 <isdomain+0x122>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    121f <isdomain+0xff>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <isdomain@plt>
mov    %eax,-0x4(%rbp)
jmp    1242 <isdomain+0x122>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    123b <isdomain+0x11b>
movl   $0x1,-0x4(%rbp)
jmp    1242 <isdomain+0x122>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isdomain>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <isletdig@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1190 <isdomain+0x80>
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%rbx),%edi
call   1030 <isletdig@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1130 <isdomain+0x20>
jmp    1154 <isdomain+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
movzbl -0x1(%rbx),%eax
cmp    $0x2d,%al
je     1150 <isdomain+0x40>
movsbl %al,%edi
call   1030 <isletdig@plt>
test   %rax,%rax
jne    1150 <isdomain+0x40>
cmpb   $0x2d,-0x2(%rbx)
je     1190 <isdomain+0x80>
mov    -0x1(%rbx),%al
cmp    $0x2e,%al
jne    1185 <isdomain+0x75>
movsbl (%rbx),%edi
call   1030 <isletdig@plt>
test   %rax,%rax
jne    1130 <isdomain+0x20>
jmp    1190 <isdomain+0x80>
mov    $0x1,%ebp
test   %al,%al
je     1190 <isdomain+0x80>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isdomain(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8, i8* %4
%6 = call i64 @isletdig(i8 signext %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 0, i32* %2
br label %60
9: ; preds = %1
br label %10
10: ; preds = %16, %9
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = call i64 @isletdig(i8 signext %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
br label %16
16: ; preds = %15
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
br label %10
19: ; preds = %10
br label %20
20: ; preds = %33, %19
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 45
br i1 %24, label %30, label %25
25: ; preds = %20
%26 = load i8*, i8** %3
%27 = load i8, i8* %26
%28 = call i64 @isletdig(i8 signext %27)
%29 = icmp ne i64 %28, 0
br label %30
30: ; preds = %25, %20
%31 = phi i1 [ true, %20 ], [ %29, %25 ]
br i1 %31, label %32, label %36
32: ; preds = %30
br label %33
33: ; preds = %32
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %3
br label %20
36: ; preds = %30
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 -1
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 45
br i1 %41, label %42, label %43
42: ; preds = %36
store i32 0, i32* %2
br label %60
43: ; preds = %36
%44 = load i8*, i8** %3
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 46
br i1 %47, label %48, label %53
48: ; preds = %43
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %3
%51 = load i8*, i8** %3
%52 = call i32 @isdomain(i8* %51)
store i32 %52, i32* %2
br label %60
53: ; preds = %43
%54 = load i8*, i8** %3
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %53
store i32 1, i32* %2
br label %60
59: ; preds = %53
store i32 0, i32* %2
br label %60
60: ; preds = %59, %58, %48, %42, %8
%61 = load i32, i32* %2
ret i32 %61
}

LLVM IR (-O2):
define i32 @isdomain(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i64 @isletdig(i8 signext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %35, label %5
5: ; preds = %1, %11
%6 = phi i8* [ %12, %11 ], [ %0, %1 ]
%7 = load i8, i8* %6
%8 = tail call i64 @isletdig(i8 signext %7)
%9 = icmp eq i64 %8, 0
%10 = getelementptr inbounds i8, i8* %6, i64 1
br i1 %9, label %13, label %11
11: ; preds = %5, %28
%12 = phi i8* [ %10, %5 ], [ %29, %28 ]
br label %5
13: ; preds = %5, %20
%14 = phi i8* [ %21, %20 ], [ %6, %5 ]
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 45
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = tail call i64 @isletdig(i8 signext %15)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %13, %17
%21 = getelementptr inbounds i8, i8* %14, i64 1
br label %13
22: ; preds = %17
%23 = getelementptr inbounds i8, i8* %14, i64 -1
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 45
br i1 %25, label %33, label %26
26: ; preds = %22
%27 = load i8, i8* %14
switch i8 %27, label %35 [
i8 46, label %28
i8 0, label %33
]
28: ; preds = %26
%29 = getelementptr inbounds i8, i8* %14, i64 1
%30 = load i8, i8* %29
%31 = tail call i64 @isletdig(i8 signext %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %11
33: ; preds = %26, %22, %28
%34 = phi i32 [ 1, %26 ], [ 0, %22 ], [ 0, %28 ]
br label %35
35: ; preds = %26, %33, %1
%36 = phi i32 [ 0, %1 ], [ %34, %33 ], [ 0, %26 ]
ret i32 %36
}