#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputc(unsigned char, int /*<<< orphan*/ *);
scalar_t__ strlen(char *);
int create_dns_file() {
  FILE *f;
  unsigned char buf[200];
  unsigned char *p;
  char *temp;
  int i, len = 0;
  p = buf;
  temp = "HEADER JUNK:";
  len += strlen(temp);
  while (*temp != '\0')
    *p++ = *temp++;
  temp = "LL.MIT.EDU";
  len += strlen(temp);
  while (*temp != '\0')
    *p++ = *temp++;
  *p++ = 0;
  *p++ = 16;
  *p++ = 0;
  *p++ = 1;
  len += 4;
  temp = "BLAH.MIT.EDU";
  len += strlen(temp);
  while (*temp != '\0')
    *p++ = *temp++;
  *p++ = 0;
  *p++ = 16;
  *p++ = 0;
  *p++ = 1;
  *p++ = 0;
  *p++ = 0;
  *p++ = 0;
  *p++ = 255;
  *p++ = 0;
  *p++ = 30;
  *p++ = 255;
  len += 11;
  temp = "This is random junk in the TXT record that will overflow "
         "(*rr)->rr_u.rr_txt";
  len += strlen(temp);
  while (*temp != '\0')
    *p++ = *temp++;
  p = buf;
  for (i = 0; i < len; i++, p++)
    fputc(*p, f);
  fclose(f);
  return len;
}


x86 assembly (clang, -O0):
<create_dns_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0xe8(%rbp)
lea    -0xd0(%rbp),%rax
mov    %rax,-0xd8(%rbp)
lea    0xea6(%rip),%rax
mov    %rax,-0xe0(%rbp)
mov    -0xe0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
movslq -0xe8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xe8(%rbp)
mov    -0xe0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c6 <create_dns_file+0x96>
mov    -0xe0(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe0(%rbp)
mov    (%rax),%cl
mov    -0xd8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0xd8(%rbp)
mov    %cl,(%rax)
jmp    1180 <create_dns_file+0x50>
lea    0xe40(%rip),%rax
mov    %rax,-0xe0(%rbp)
mov    -0xe0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
movslq -0xe8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xe8(%rbp)
mov    -0xe0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1239 <create_dns_file+0x109>
mov    -0xe0(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe0(%rbp)
mov    (%rax),%cl
mov    -0xd8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0xd8(%rbp)
mov    %cl,(%rax)
jmp    11f3 <create_dns_file+0xc3>
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x0,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x10,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x0,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x1,(%rax)
mov    -0xe8(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xe8(%rbp)
lea    0xd69(%rip),%rax
mov    %rax,-0xe0(%rbp)
mov    -0xe0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
movslq -0xe8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xe8(%rbp)
mov    -0xe0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     131b <create_dns_file+0x1eb>
mov    -0xe0(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe0(%rbp)
mov    (%rax),%cl
mov    -0xd8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0xd8(%rbp)
mov    %cl,(%rax)
jmp    12d5 <create_dns_file+0x1a5>
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x0,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x10,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x0,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x1,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x0,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x0,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x0,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0xff,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x0,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0x1e,(%rax)
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movb   $0xff,(%rax)
mov    -0xe8(%rbp),%eax
add    $0xb,%eax
mov    %eax,-0xe8(%rbp)
lea    0xbec(%rip),%rax
mov    %rax,-0xe0(%rbp)
mov    -0xe0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
movslq -0xe8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xe8(%rbp)
mov    -0xe0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     14a5 <create_dns_file+0x375>
mov    -0xe0(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xe0(%rbp)
mov    (%rax),%cl
mov    -0xd8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0xd8(%rbp)
mov    %cl,(%rax)
jmp    145f <create_dns_file+0x32f>
lea    -0xd0(%rbp),%rax
mov    %rax,-0xd8(%rbp)
movl   $0x0,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
cmp    -0xe8(%rbp),%eax
jge    150a <create_dns_file+0x3da>
mov    -0xd8(%rbp),%rax
mov    (%rax),%al
mov    -0x8(%rbp),%rsi
movzbl %al,%edi
call   1050 <fputc@plt>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
mov    -0xd8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xd8(%rbp)
jmp    14bd <create_dns_file+0x38d>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xe8(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_dns_file>:
push   %rbx
sub    $0xd0,%rsp
movaps 0xed1(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movb   $0xff,0x30(%rsp)
mov    $0x54,%dl
xor    %eax,%eax
lea    0xed5(%rip),%rcx
nopl   0x0(%rax,%rax,1)
mov    %dl,0x31(%rsp,%rax,1)
mov    0x1(%rax,%rcx,1),%edx
mov    %edx,0x32(%rsp,%rax,1)
movzbl 0x5(%rax,%rcx,1),%edx
add    $0x5,%rax
cmp    $0x4b,%rax
jne    1160 <create_dns_file+0x40>
xor    %ebx,%ebx
nopl   (%rax)
movzbl (%rsp,%rbx,1),%edi
call   1040 <fputc@plt>
add    $0x1,%rbx
cmp    $0x7c,%rbx
jne    1180 <create_dns_file+0x60>
call   1030 <fclose@plt>
mov    $0x7c,%eax
add    $0xd0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"HEADER JUNK:\00"
@.str.1 = [11 x i8] c"LL.MIT.EDU\00"
@.str.2 = [13 x i8] c"BLAH.MIT.EDU\00"
@.str.3 = [76 x i8] c"This is random junk in the TXT record that will overflow (*rr)->rr_u.rr_txt\00"
define i32 @create_dns_file() {
%1 = alloca i32*
%2 = alloca [200 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %6
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
store i8* %7, i8** %3
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %4
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = add nsw i64 %11, %9
%13 = trunc i64 %12 to i32
store i32 %13, i32* %6
br label %14
14: ; preds = %19, %0
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %4
%22 = load i8, i8* %20
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %3
store i8 %22, i8* %23
br label %14
25: ; preds = %14
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %4
%26 = load i8*, i8** %4
%27 = call i64 @strlen(i8* %26)
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = add nsw i64 %29, %27
%31 = trunc i64 %30 to i32
store i32 %31, i32* %6
br label %32
32: ; preds = %37, %25
%33 = load i8*, i8** %4
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %32
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %4
%40 = load i8, i8* %38
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %3
store i8 %40, i8* %41
br label %32
43: ; preds = %32
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %3
store i8 0, i8* %44
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %3
store i8 16, i8* %46
%48 = load i8*, i8** %3
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %3
store i8 0, i8* %48
%50 = load i8*, i8** %3
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %3
store i8 1, i8* %50
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 4
store i32 %53, i32* %6
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8** %4
%54 = load i8*, i8** %4
%55 = call i64 @strlen(i8* %54)
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = add nsw i64 %57, %55
%59 = trunc i64 %58 to i32
store i32 %59, i32* %6
br label %60
60: ; preds = %65, %43
%61 = load i8*, i8** %4
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %71
65: ; preds = %60
%66 = load i8*, i8** %4
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %4
%68 = load i8, i8* %66
%69 = load i8*, i8** %3
%70 = getelementptr inbounds i8, i8* %69, i32 1
store i8* %70, i8** %3
store i8 %68, i8* %69
br label %60
71: ; preds = %60
%72 = load i8*, i8** %3
%73 = getelementptr inbounds i8, i8* %72, i32 1
store i8* %73, i8** %3
store i8 0, i8* %72
%74 = load i8*, i8** %3
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %3
store i8 16, i8* %74
%76 = load i8*, i8** %3
%77 = getelementptr inbounds i8, i8* %76, i32 1
store i8* %77, i8** %3
store i8 0, i8* %76
%78 = load i8*, i8** %3
%79 = getelementptr inbounds i8, i8* %78, i32 1
store i8* %79, i8** %3
store i8 1, i8* %78
%80 = load i8*, i8** %3
%81 = getelementptr inbounds i8, i8* %80, i32 1
store i8* %81, i8** %3
store i8 0, i8* %80
%82 = load i8*, i8** %3
%83 = getelementptr inbounds i8, i8* %82, i32 1
store i8* %83, i8** %3
store i8 0, i8* %82
%84 = load i8*, i8** %3
%85 = getelementptr inbounds i8, i8* %84, i32 1
store i8* %85, i8** %3
store i8 0, i8* %84
%86 = load i8*, i8** %3
%87 = getelementptr inbounds i8, i8* %86, i32 1
store i8* %87, i8** %3
store i8 -1, i8* %86
%88 = load i8*, i8** %3
%89 = getelementptr inbounds i8, i8* %88, i32 1
store i8* %89, i8** %3
store i8 0, i8* %88
%90 = load i8*, i8** %3
%91 = getelementptr inbounds i8, i8* %90, i32 1
store i8* %91, i8** %3
store i8 30, i8* %90
%92 = load i8*, i8** %3
%93 = getelementptr inbounds i8, i8* %92, i32 1
store i8* %93, i8** %3
store i8 -1, i8* %92
%94 = load i32, i32* %6
%95 = add nsw i32 %94, 11
store i32 %95, i32* %6
store i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.3, i64 0, i64 0), i8** %4
%96 = load i8*, i8** %4
%97 = call i64 @strlen(i8* %96)
%98 = load i32, i32* %6
%99 = sext i32 %98 to i64
%100 = add nsw i64 %99, %97
%101 = trunc i64 %100 to i32
store i32 %101, i32* %6
br label %102
102: ; preds = %107, %71
%103 = load i8*, i8** %4
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %113
107: ; preds = %102
%108 = load i8*, i8** %4
%109 = getelementptr inbounds i8, i8* %108, i32 1
store i8* %109, i8** %4
%110 = load i8, i8* %108
%111 = load i8*, i8** %3
%112 = getelementptr inbounds i8, i8* %111, i32 1
store i8* %112, i8** %3
store i8 %110, i8* %111
br label %102
113: ; preds = %102
%114 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
store i8* %114, i8** %3
store i32 0, i32* %5
br label %115
115: ; preds = %124, %113
%116 = load i32, i32* %5
%117 = load i32, i32* %6
%118 = icmp slt i32 %116, %117
br i1 %118, label %119, label %129
119: ; preds = %115
%120 = load i8*, i8** %3
%121 = load i8, i8* %120
%122 = load i32*, i32** %1
%123 = call i32 @fputc(i8 zeroext %121, i32* %122)
br label %124
124: ; preds = %119
%125 = load i32, i32* %5
%126 = add nsw i32 %125, 1
store i32 %126, i32* %5
%127 = load i8*, i8** %3
%128 = getelementptr inbounds i8, i8* %127, i32 1
store i8* %128, i8** %3
br label %115
129: ; preds = %115
%130 = load i32*, i32** %1
%131 = call i32 @fclose(i32* %130)
%132 = load i32, i32* %6
ret i32 %132
}

LLVM IR (-O2):
@.str.3 = [76 x i8] c"This is random junk in the TXT record that will overflow (*rr)->rr_u.rr_txt\00"
define i32 @create_dns_file() {
%1 = alloca [200 x i8]
%2 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 16
%4 = bitcast [200 x i8]* %1 to <16 x i8>*
store <16 x i8> <i8 72, i8 69, i8 65, i8 68, i8 69, i8 82, i8 32, i8 74, i8 85, i8 78, i8 75, i8 58, i8 76, i8 76, i8 46, i8 77>, <16 x i8>* %4
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 32
%6 = bitcast i8* %3 to <16 x i8>*
store <16 x i8> <i8 73, i8 84, i8 46, i8 69, i8 68, i8 85, i8 0, i8 16, i8 0, i8 1, i8 66, i8 76, i8 65, i8 72, i8 46, i8 77>, <16 x i8>* %6
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 48
%8 = bitcast i8* %5 to <16 x i8>*
store <16 x i8> <i8 73, i8 84, i8 46, i8 69, i8 68, i8 85, i8 0, i8 16, i8 0, i8 1, i8 0, i8 0, i8 0, i8 -1, i8 0, i8 30>, <16 x i8>* %8
%9 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 49
store i8 -1, i8* %7
br label %10
10: ; preds = %10, %0
%11 = phi i8 [ 84, %0 ], [ %28, %10 ]
%12 = phi i8* [ getelementptr inbounds ([76 x i8], [76 x i8]* @.str.3, i64 0, i64 0), %0 ], [ %26, %10 ]
%13 = phi i8* [ %9, %0 ], [ %27, %10 ]
%14 = getelementptr inbounds i8, i8* %12, i64 1
%15 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %11, i8* %13
%16 = load i8, i8* %14
%17 = getelementptr inbounds i8, i8* %12, i64 2
%18 = getelementptr inbounds i8, i8* %13, i64 2
store i8 %16, i8* %15
%19 = load i8, i8* %17
%20 = getelementptr inbounds i8, i8* %12, i64 3
%21 = getelementptr inbounds i8, i8* %13, i64 3
store i8 %19, i8* %18
%22 = load i8, i8* %20
%23 = getelementptr inbounds i8, i8* %12, i64 4
%24 = getelementptr inbounds i8, i8* %13, i64 4
store i8 %22, i8* %21
%25 = load i8, i8* %23
%26 = getelementptr inbounds i8, i8* %12, i64 5
%27 = getelementptr inbounds i8, i8* %13, i64 5
store i8 %25, i8* %24
%28 = load i8, i8* %26
%29 = icmp eq i8* %26, getelementptr inbounds ([76 x i8], [76 x i8]* @.str.3, i64 0, i64 75)
br i1 %29, label %30, label %10
30: ; preds = %10
%31 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 123
br label %32
32: ; preds = %30, %32
%33 = phi i8* [ %36, %32 ], [ %2, %30 ]
%34 = load i8, i8* %33
%35 = tail call i32 @fputc(i8 zeroext %34, i32* undef)
%36 = getelementptr inbounds i8, i8* %33, i64 1
%37 = icmp eq i8* %33, %31
br i1 %37, label %38, label %32
38: ; preds = %32
%39 = tail call i32 @fclose(i32* undef)
ret i32 124
}