#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 */
typedef int /*<<< orphan*/ bannedDomains;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int filterTLDs(char domain[]) {
  char *cpoint;
  char *bannedDomains[] = {"ch", "ru", "be", "cz", "hr", "it", "pl", "de"};
  int nrOfbannedDomains = (sizeof(bannedDomains) / sizeof(char *));
  int i;
  if ((cpoint = strchr(domain, '.')) == NULL) {
    printf("bad domain\n");
    return 1;
  }
  ++cpoint;
  for (i = 0; i < nrOfbannedDomains; i++) {
    if (strcmp(bannedDomains[i], cpoint) == 0) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<filterTLDs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
lea    0x2c89(%rip),%rsi
mov    $0x40,%edx
call   1060 <memcpy@plt>
movl   $0x8,-0x64(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    119c <filterTLDs+0x5c>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fd <filterTLDs+0xbd>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    11f6 <filterTLDs+0xb6>
movslq -0x68(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11e3 <filterTLDs+0xa3>
movl   $0x1,-0x4(%rbp)
jmp    11fd <filterTLDs+0xbd>
jmp    11e8 <filterTLDs+0xa8>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11af <filterTLDs+0x6f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filterTLDs>:
push   %rbp
push   %rbx
push   %rax
mov    $0x2e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1200 <filterTLDs+0xd0>
mov    %rax,%rbx
add    $0x1,%rbx
lea    0xeac(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1211 <filterTLDs+0xe1>
lea    0xe92(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1211 <filterTLDs+0xe1>
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1211 <filterTLDs+0xe1>
lea    0xe6c(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1211 <filterTLDs+0xe1>
lea    0xe5b(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1211 <filterTLDs+0xe1>
lea    0xe4a(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1211 <filterTLDs+0xe1>
lea    0xe39(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1211 <filterTLDs+0xe1>
lea    0xe28(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
jmp    1211 <filterTLDs+0xe1>
lea    0xe11(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"ch\00"
@.str.1 = [3 x i8] c"ru\00"
@.str.2 = [3 x i8] c"be\00"
@.str.3 = [3 x i8] c"cz\00"
@.str.4 = [3 x i8] c"hr\00"
@.str.5 = [3 x i8] c"it\00"
@.str.6 = [3 x i8] c"pl\00"
@.str.7 = [3 x i8] c"de\00"
@__const.filterTLDs.bannedDomains = [8 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0)]
@.str.8 = [12 x i8] c"bad domain\0A\00"
define i32 @filterTLDs(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [8 x i8*]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
%8 = bitcast [8 x i8*]* %5 to i8*
store i32 8, i32* %6
%9 = load i8*, i8** %3
%10 = call i8* @strchr(i8* %9, i8 signext 46)
store i8* %10, i8** %4
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %2
br label %35
14: ; preds = %1
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
store i32 0, i32* %7
br label %17
17: ; preds = %31, %14
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %34
21: ; preds = %17
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [8 x i8*], [8 x i8*]* %5, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = load i8*, i8** %4
%27 = call i64 @strcmp(i8* %25, i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %21
store i32 1, i32* %2
br label %35
30: ; preds = %21
br label %31
31: ; preds = %30
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %17
34: ; preds = %17
store i32 0, i32* %2
br label %35
35: ; preds = %34, %29, %12
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@.str = [3 x i8] c"ch\00"
@.str.1 = [3 x i8] c"ru\00"
@.str.2 = [3 x i8] c"be\00"
@.str.3 = [3 x i8] c"cz\00"
@.str.4 = [3 x i8] c"hr\00"
@.str.5 = [3 x i8] c"it\00"
@.str.6 = [3 x i8] c"pl\00"
@.str.7 = [3 x i8] c"de\00"
@str = [11 x i8] c"bad domain\00"
define i32 @filterTLDs(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %32
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %2, i64 1
%8 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %32, label %10
10: ; preds = %6
%11 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%12 = icmp eq i64 %11, 0
br i1 %12, label %32, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%15 = icmp eq i64 %14, 0
br i1 %15, label %32, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%18 = icmp eq i64 %17, 0
br i1 %18, label %32, label %19
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%21 = icmp eq i64 %20, 0
br i1 %21, label %32, label %22
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %7)
%24 = icmp eq i64 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %22
%26 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %7)
%27 = icmp eq i64 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %7)
%30 = icmp eq i64 %29, 0
%31 = zext i1 %30 to i32
br label %32
32: ; preds = %28, %6, %10, %13, %16, %19, %22, %25, %4
%33 = phi i32 [ 1, %4 ], [ 1, %6 ], [ 1, %10 ], [ 1, %13 ], [ 1, %16 ], [ 1, %19 ], [ 1, %22 ], [ 1, %25 ], [ %31, %28 ]
ret i32 %33
}