#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*/ strncpy(char *, char *, int);
int genTLD(unsigned short rand, char *TLD) {
  unsigned char lobyte = (rand & 0xff);
  if ((rand % 6) == 0) {
    strncpy(TLD, ".ru", 4);
  } else if ((rand % 5) == 0) {
    strncpy(TLD, ".biz", 5);
  } else if ((lobyte & 3) == 00) {
    strncpy(TLD, ".info", 6);
  } else if ((rand % 3) == 0) {
    strncpy(TLD, ".org", 5);
  } else if ((lobyte & 1) == 0) {
    strncpy(TLD, ".net", 5);
  } else {
    strncpy(TLD, ".com", 5);
  }
  return 1;
}


x86 assembly (clang, -O0):
<genTLD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
movzwl -0x2(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x11(%rbp)
movzwl -0x2(%rbp),%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    115e <genTLD+0x4e>
mov    -0x10(%rbp),%rdi
lea    0xeb1(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
jmp    1239 <genTLD+0x129>
movzwl -0x2(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118d <genTLD+0x7d>
mov    -0x10(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
jmp    1234 <genTLD+0x124>
movzbl -0x11(%rbp),%eax
and    $0x3,%eax
cmp    $0x0,%eax
jne    11b7 <genTLD+0xa7>
mov    -0x10(%rbp),%rdi
lea    0xe61(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncpy@plt>
jmp    122f <genTLD+0x11f>
movzwl -0x2(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e6 <genTLD+0xd6>
mov    -0x10(%rbp),%rdi
lea    0xe38(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
jmp    122a <genTLD+0x11a>
movzbl -0x11(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1210 <genTLD+0x100>
mov    -0x10(%rbp),%rdi
lea    0xe13(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
jmp    1225 <genTLD+0x115>
mov    -0x10(%rbp),%rdi
lea    0xdfe(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
jmp    122a <genTLD+0x11a>
jmp    122f <genTLD+0x11f>
jmp    1234 <genTLD+0x124>
jmp    1239 <genTLD+0x129>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genTLD>:
push   %rax
imul   $0xffffaaab,%edi,%eax
ror    %ax
movzwl %ax,%eax
cmp    $0x2aaa,%eax
jbe    1159 <genTLD+0x49>
imul   $0xffffcccd,%edi,%eax
movzwl %ax,%eax
cmp    $0x3333,%eax
jbe    116d <genTLD+0x5d>
test   $0x3,%dil
je     1176 <genTLD+0x66>
imul   $0xffffaaab,%edi,%eax
movzwl %ax,%eax
cmp    $0x5555,%eax
jbe    118a <genTLD+0x7a>
test   $0x1,%dil
jne    1193 <genTLD+0x83>
lea    0xebd(%rip),%rax
jmp    119a <genTLD+0x8a>
lea    0xea0(%rip),%rax
mov    %rsi,%rdi
mov    %rax,%rsi
mov    $0x4,%edx
jmp    11a5 <genTLD+0x95>
lea    0xe90(%rip),%rax
jmp    119a <genTLD+0x8a>
lea    0xe8c(%rip),%rax
mov    %rsi,%rdi
mov    %rax,%rsi
mov    $0x6,%edx
jmp    11a5 <genTLD+0x95>
lea    0xe7e(%rip),%rax
jmp    119a <genTLD+0x8a>
lea    0xe7f(%rip),%rax
mov    %rsi,%rdi
mov    %rax,%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c".ru\00"
@.str.1 = [5 x i8] c".biz\00"
@.str.2 = [6 x i8] c".info\00"
@.str.3 = [5 x i8] c".org\00"
@.str.4 = [5 x i8] c".net\00"
@.str.5 = [5 x i8] c".com\00"
define i32 @genTLD(i16 zeroext %0, i8* %1) {
%3 = alloca i16
%4 = alloca i8*
%5 = alloca i8
store i16 %0, i16* %3
store i8* %1, i8** %4
%6 = load i16, i16* %3
%7 = zext i16 %6 to i32
%8 = and i32 %7, 255
%9 = trunc i32 %8 to i8
store i8 %9, i8* %5
%10 = load i16, i16* %3
%11 = zext i16 %10 to i32
%12 = srem i32 %11, 6
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = call i32 @strncpy(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
br label %56
17: ; preds = %2
%18 = load i16, i16* %3
%19 = zext i16 %18 to i32
%20 = srem i32 %19, 5
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i8*, i8** %4
%24 = call i32 @strncpy(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 5)
br label %55
25: ; preds = %17
%26 = load i8, i8* %5
%27 = zext i8 %26 to i32
%28 = and i32 %27, 3
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = call i32 @strncpy(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 6)
br label %54
33: ; preds = %25
%34 = load i16, i16* %3
%35 = zext i16 %34 to i32
%36 = srem i32 %35, 3
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i8*, i8** %4
%40 = call i32 @strncpy(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 5)
br label %53
41: ; preds = %33
%42 = load i8, i8* %5
%43 = zext i8 %42 to i32
%44 = and i32 %43, 1
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %41
%47 = load i8*, i8** %4
%48 = call i32 @strncpy(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 5)
br label %52
49: ; preds = %41
%50 = load i8*, i8** %4
%51 = call i32 @strncpy(i8* %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 5)
br label %52
52: ; preds = %49, %46
br label %53
53: ; preds = %52, %38
br label %54
54: ; preds = %53, %30
br label %55
55: ; preds = %54, %22
br label %56
56: ; preds = %55, %14
ret i32 1
}

LLVM IR (-O2):
@.str = [4 x i8] c".ru\00"
@.str.1 = [5 x i8] c".biz\00"
@.str.2 = [6 x i8] c".info\00"
@.str.3 = [5 x i8] c".org\00"
@.str.4 = [5 x i8] c".net\00"
@.str.5 = [5 x i8] c".com\00"
define i32 @genTLD(i16 zeroext %0, i8* %1) {
%3 = urem i16 %0, 6
%4 = icmp eq i16 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @strncpy(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
br label %31
7: ; preds = %2
%8 = urem i16 %0, 5
%9 = icmp eq i16 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @strncpy(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 5)
br label %31
12: ; preds = %7
%13 = and i16 %0, 255
%14 = zext i16 %13 to i32
%15 = and i32 %14, 3
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @strncpy(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 6)
br label %31
19: ; preds = %12
%20 = urem i16 %0, 3
%21 = icmp eq i16 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @strncpy(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 5)
br label %31
24: ; preds = %19
%25 = and i32 %14, 1
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = tail call i32 @strncpy(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 5)
br label %31
29: ; preds = %24
%30 = tail call i32 @strncpy(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 5)
br label %31
31: ; preds = %10, %22, %29, %27, %17, %5
ret i32 1
}