#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*/ ReadFile(char *);
int /*<<< orphan*/ chomp(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
char *strchr(char *, char);
char *strdup(char *);
char *strtok(char *, char *);
int query_domain(char domainname[56]) {
  char domain_file[60];
  char *tld;
  char *domain;
  char *tmp;
  chomp(domainname);
  tmp = strdup(domainname);
  tld = strchr(domainname, '.');
  domain = strtok(tmp, ".");
  printf("%s_%s.txt\n", tld + 1, domain);
  sprintf(domain_file, "%s_%s.txt", tld + 1, domain);
  if (!ReadFile(domain_file)) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<query_domain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <chomp@plt>
mov    -0x10(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,-0x58(%rbp)
mov    -0x68(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x60(%rbp)
mov    -0x58(%rbp),%rsi
add    $0x1,%rsi
mov    -0x60(%rbp),%rdx
lea    0xe37(%rip),%rdi
call   1050 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rdx
add    $0x1,%rdx
mov    -0x60(%rbp),%rcx
lea    0xe26(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x50(%rbp),%rdi
call   1030 <ReadFile@plt>
cmp    $0x0,%eax
jne    120a <query_domain+0x9a>
movl   $0x0,-0x4(%rbp)
jmp    1211 <query_domain+0xa1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<query_domain>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
call   1060 <chomp@plt>
mov    %rbx,%rdi
call   1090 <strdup@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,%rbx
lea    0xe5d(%rip),%rsi
mov    %r14,%rdi
call   1070 <strtok@plt>
mov    %rax,%r14
add    $0x1,%rbx
lea    0xe49(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1050 <printf@plt>
lea    0xe42(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1080 <sprintf@plt>
mov    %r15,%rdi
call   1030 <ReadFile@plt>
xor    %ecx,%ecx
test   %eax,%eax
setne  %cl
mov    %ecx,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [11 x i8] c"%s_%s.txt\0A\00"
@.str.2 = [10 x i8] c"%s_%s.txt\00"
define i32 @query_domain(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [60 x i8]
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @chomp(i8* %8)
%10 = load i8*, i8** %3
%11 = call i8* @strdup(i8* %10)
store i8* %11, i8** %7
%12 = load i8*, i8** %3
%13 = call i8* @strchr(i8* %12, i8 signext 46)
store i8* %13, i8** %5
%14 = load i8*, i8** %7
%15 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %6
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8*, i8** %6
%19 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %18)
%20 = getelementptr inbounds [60 x i8], [60 x i8]* %4, i64 0, i64 0
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8*, i8** %6
%24 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %22, i8* %23)
%25 = getelementptr inbounds [60 x i8], [60 x i8]* %4, i64 0, i64 0
%26 = call i32 @ReadFile(i8* %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %1
store i32 0, i32* %2
br label %30
29: ; preds = %1
store i32 1, i32* %2
br label %30
30: ; preds = %29, %28
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [11 x i8] c"%s_%s.txt\0A\00"
@.str.2 = [10 x i8] c"%s_%s.txt\00"
define i32 @query_domain(i8* %0) {
%2 = alloca [60 x i8]
%3 = getelementptr inbounds [60 x i8], [60 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @chomp(i8* %0)
%5 = tail call i8* @strdup(i8* %0)
%6 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 46)
%7 = tail call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds i8, i8* %6, i64 1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* %7)
%10 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %7)
%11 = call i32 @ReadFile(i8* %3)
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i32
ret i32 %13
}