#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *, char *);
void trdCreate(char *path) {
  char buf[0xa0000];
  memset(buf, 0x00, 0xa0000);
  buf[0x8e2] = 0x01;
  buf[0x8e3] = 0x16;
  buf[0x8e5] = 0xf0;
  buf[0x8e6] = 0x09;
  buf[0x8e7] = 0x10;
  FILE *file = fopen(path, "wb");
  if (!file) {
    printf("Can't write to file '%s'\n", path);
  } else {
    fwrite(buf, 0xa0000, 1, file);
    fclose(file);
  }
}


x86 assembly (clang, -O0):
<trdCreate>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0020,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xa0010(%rbp),%rdi
xor    %esi,%esi
mov    $0xa0000,%edx
call   1050 <memset@plt>
movb   $0x1,-0x9f72e(%rbp)
movb   $0x16,-0x9f72d(%rbp)
movb   $0xf0,-0x9f72b(%rbp)
movb   $0x9,-0x9f72a(%rbp)
movb   $0x10,-0x9f729(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0xa0018(%rbp)
cmpq   $0x0,-0xa0018(%rbp)
jne    11cf <trdCreate+0x7f>
mov    -0x8(%rbp),%rsi
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
jmp    11f8 <trdCreate+0xa8>
lea    -0xa0010(%rbp),%rdi
mov    -0xa0018(%rbp),%rcx
mov    $0xa0000,%esi
mov    $0x1,%edx
call   1070 <fwrite@plt>
mov    -0xa0018(%rbp),%rdi
call   1030 <fclose@plt>
add    $0xa0020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trdCreate>:
push   %r14
push   %rbx
sub    $0xa0008,%rsp
mov    %rdi,%r14
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xa0000,%edx
call   1050 <memset@plt>
movw   $0x1601,0x8e2(%rsp)
movw   $0x9f0,0x8e5(%rsp)
movb   $0x10,0x8e7(%rsp)
10
lea    0xe71(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11be <trdCreate+0x6e>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0xa0000,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    11cd <trdCreate+0x7d>
lea    0xe3e(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
add    $0xa0008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
@.str.1 = [26 x i8] c"Can't write to file '%s'\0A\00"
define void @trdCreate(i8* %0) {
%2 = alloca i8*
%3 = alloca [655360 x i8]
%4 = alloca i32*
store i8* %0, i8** %2
%5 = getelementptr inbounds [655360 x i8], [655360 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 655360)
%7 = getelementptr inbounds [655360 x i8], [655360 x i8]* %3, i64 0, i64 2274
store i8 1, i8* %7
%8 = getelementptr inbounds [655360 x i8], [655360 x i8]* %3, i64 0, i64 2275
store i8 22, i8* %8
%9 = getelementptr inbounds [655360 x i8], [655360 x i8]* %3, i64 0, i64 2277
store i8 -16, i8* %9
%10 = getelementptr inbounds [655360 x i8], [655360 x i8]* %3, i64 0, i64 2278
store i8 9, i8* %10
%11 = getelementptr inbounds [655360 x i8], [655360 x i8]* %3, i64 0, i64 2279
store i8 16, i8* %11
%12 = load i8*, i8** %2
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %4
%14 = load i32*, i32** %4
%15 = icmp ne i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %1
%17 = load i8*, i8** %2
%18 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %25
19: ; preds = %1
%20 = getelementptr inbounds [655360 x i8], [655360 x i8]* %3, i64 0, i64 0
%21 = load i32*, i32** %4
%22 = call i32 @fwrite(i8* %20, i32 655360, i32 1, i32* %21)
%23 = load i32*, i32** %4
%24 = call i32 @fclose(i32* %23)
br label %25
25: ; preds = %19, %16
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
@.str.1 = [26 x i8] c"Can't write to file '%s'\0A\00"
define void @trdCreate(i8* %0) {
%2 = alloca [655360 x i8]
%3 = getelementptr inbounds [655360 x i8], [655360 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 655360)
%5 = getelementptr inbounds [655360 x i8], [655360 x i8]* %2, i64 0, i64 2274
store i8 1, i8* %5
%6 = getelementptr inbounds [655360 x i8], [655360 x i8]* %2, i64 0, i64 2275
store i8 22, i8* %6
%7 = getelementptr inbounds [655360 x i8], [655360 x i8]* %2, i64 0, i64 2277
store i8 -16, i8* %7
%8 = getelementptr inbounds [655360 x i8], [655360 x i8]* %2, i64 0, i64 2278
store i8 9, i8* %8
%9 = getelementptr inbounds [655360 x i8], [655360 x i8]* %2, i64 0, i64 2279
store i8 16, i8* %9
%10 = call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %17
14: ; preds = %1
%15 = call i32 @fwrite(i8* %3, i32 655360, i32 1, i32* %10)
%16 = call i32 @fclose(i32* %10)
br label %17
17: ; preds = %14, %12
ret void
}