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

/* Variables and functions */
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int lseek(int, size_t, int /*<<< orphan*/);
int open(char const *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int write(int, char *, int);
int mk_file(const char *filename, size_t filesize) {
  int status = 0;
  int result, fd;
  if ((filename == NULL) || (*filename == '\0')) {
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 23,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/DEPRECATED_Q2/AUX/mk_file.c");
      };
      status = -1;
      goto BYE;
    };
  }
  if (filesize <= 0) {
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 24,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/DEPRECATED_Q2/AUX/mk_file.c");
      };
      status = -1;
      goto BYE;
    };
  }
  fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600);
  if (fd == -1) {
    fprintf(stderr, "Error opening %s file for writing\n", filename);
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 35,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/DEPRECATED_Q2/AUX/mk_file.c");
      };
      status = -1;
      goto BYE;
    };
  }
  result = lseek(fd, filesize - 1, SEEK_SET);
  if (result == -1) {
    close(fd);
    fprintf(stderr, "Error calling lseek() to 'stretch' file [%s]\n", filename);
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 42,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/DEPRECATED_Q2/AUX/mk_file.c");
      };
      status = -1;
      goto BYE;
    };
  }
  result = write(fd, "", 1);
  close(fd);
  if (result != 1) {
    fprintf(stderr, "Error writing last byte of file \n");
    {
      {
        fprintf(stderr, "Line %3d of File %s \n", 58,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/DEPRECATED_Q2/AUX/mk_file.c");
      };
      status = -1;
      goto BYE;
    };
  }
BYE:
  return (status);
}


x86 assembly (clang, -O0):
<mk_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1182 <mk_file+0x32>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11b1 <mk_file+0x61>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
mov    $0x17,%edx
lea    0xe78(%rip),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1357 <mk_file+0x207>
cmpq   $0x0,-0x10(%rbp)
ja     11eb <mk_file+0x9b>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
lea    0xe34(%rip),%rsi
mov    $0x18,%edx
lea    0xe3e(%rip),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1357 <mk_file+0x207>
mov    -0x8(%rbp),%rdi
mov    0x2de2(%rip),%rax
mov    (%rax),%esi
mov    0x2df9(%rip),%rax
or     (%rax),%esi
mov    0x2de8(%rip),%rax
or     (%rax),%esi
mov    $0x180,%edx
call   1070 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    126b <mk_file+0x11b>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    0xdb4(%rip),%rsi
mov    $0x23,%edx
lea    0xdbe(%rip),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1357 <mk_file+0x207>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
sub    $0x1,%rsi
mov    0x2d43(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    12e3 <mk_file+0x193>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d0d(%rip),%rax
mov    (%rax),%edi
lea    0xd3c(%rip),%rsi
mov    $0x2a,%edx
lea    0xd46(%rip),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1357 <mk_file+0x207>
mov    -0x1c(%rbp),%edi
lea    0xe33(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
cmpl   $0x1,-0x18(%rbp)
je     1352 <mk_file+0x202>
mov    0x2cb5(%rip),%rax
mov    (%rax),%edi
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
lea    0xccd(%rip),%rsi
mov    $0x3a,%edx
lea    0xcd7(%rip),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1357 <mk_file+0x207>
jmp    1357 <mk_file+0x207>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mk_file>:
push   %rbp
push   %r14
push   %rbx
mov    $0x17,%edx
test   %rdi,%rdi
je     1258 <mk_file+0x108>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1258 <mk_file+0x108>
mov    %rsi,%r14
test   %rsi,%rsi
je     120a <mk_file+0xba>
mov    0x2e57(%rip),%rax
mov    0x2e70(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e5d(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
mov    $0x180,%edx
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     1211 <mk_file+0xc1>
mov    %eax,%ebp
add    $0xffffffffffffffff,%r14
mov    0x2e0c(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <lseek@plt>
cmp    $0xffffffff,%eax
je     1232 <mk_file+0xe2>
lea    0xf54(%rip),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1050 <close@plt>
xor    %eax,%eax
cmp    $0x1,%ebx
je     127b <mk_file+0x12b>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
lea    0xf03(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x3a,%edx
jmp    1258 <mk_file+0x108>
mov    $0x18,%edx
jmp    1258 <mk_file+0x108>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x23,%edx
jmp    1258 <mk_file+0x108>
mov    %ebp,%edi
call   1050 <close@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x2a,%edx
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
lea    0xd98(%rip),%rsi
lea    0xda7(%rip),%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Line %3d of File %s \0A\00"
@.str.1 = [152 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/master/DEPRECATED_Q2/AUX/mk_file.c\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.2 = [35 x i8] c"Error opening %s file for writing\0A\00"
@SEEK_SET = global i32 0
@.str.3 = [46 x i8] c"Error calling lseek() to 'stretch' file [%s]\0A\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [34 x i8] c"Error writing last byte of file \0A\00"
define i32 @mk_file(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
store i32 0, i32* %5
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10, %2
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 23, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %69
18: ; preds = %10
%19 = load i64, i64* %4
%20 = icmp ule i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 24, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %69
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = load i32, i32* @O_RDWR
%27 = load i32, i32* @O_CREAT
%28 = or i32 %26, %27
%29 = load i32, i32* @O_TRUNC
%30 = or i32 %28, %29
%31 = call i32 @open(i8* %25, i32 %30, i32 384)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %40
34: ; preds = %24
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %3
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %69
40: ; preds = %24
%41 = load i32, i32* %7
%42 = load i64, i64* %4
%43 = sub i64 %42, 1
%44 = load i32, i32* @SEEK_SET
%45 = call i32 @lseek(i32 %41, i64 %43, i32 %44)
store i32 %45, i32* %6
%46 = load i32, i32* %6
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %56
48: ; preds = %40
%49 = load i32, i32* %7
%50 = call i32 @close(i32 %49)
%51 = load i32, i32* @stderr
%52 = load i8*, i8** %3
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i8* %52)
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 42, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %69
56: ; preds = %40
%57 = load i32, i32* %7
%58 = call i32 @write(i32 %57, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i32 1)
store i32 %58, i32* %6
%59 = load i32, i32* %7
%60 = call i32 @close(i32 %59)
%61 = load i32, i32* %6
%62 = icmp ne i32 %61, 1
br i1 %62, label %63, label %68
63: ; preds = %56
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 58, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %69
68: ; preds = %56
br label %69
69: ; preds = %68, %63, %48, %34, %21, %15
%70 = load i32, i32* %5
ret i32 %70
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Line %3d of File %s \0A\00"
@.str.1 = [152 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/master/DEPRECATED_Q2/AUX/mk_file.c\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.2 = [35 x i8] c"Error opening %s file for writing\0A\00"
@SEEK_SET = global i32 0
@.str.3 = [46 x i8] c"Error calling lseek() to 'stretch' file [%s]\0A\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [34 x i8] c"Error writing last byte of file \0A\00"
define i32 @mk_file(i8* %0, i64 %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %36, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %36, label %7
7: ; preds = %4
%8 = icmp eq i64 %1, 0
br i1 %8, label %36, label %9
9: ; preds = %7
%10 = load i32, i32* @O_RDWR
%11 = load i32, i32* @O_CREAT
%12 = or i32 %11, %10
%13 = load i32, i32* @O_TRUNC
%14 = or i32 %12, %13
%15 = tail call i32 @open(i8* %0, i32 %14, i32 384)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %9
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %36
20: ; preds = %9
%21 = add i64 %1, -1
%22 = load i32, i32* @SEEK_SET
%23 = tail call i32 @lseek(i32 %15, i64 %21, i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = tail call i32 @close(i32 %15)
%27 = load i32, i32* @stderr
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %36
29: ; preds = %20
%30 = tail call i32 @write(i32 %15, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i32 1)
%31 = tail call i32 @close(i32 %15)
%32 = icmp eq i32 %30, 1
br i1 %32, label %40, label %33
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %7, %2, %4, %17, %25, %33
%37 = phi i32 [ 58, %33 ], [ 42, %25 ], [ 35, %17 ], [ 23, %4 ], [ 23, %2 ], [ 24, %7 ]
%38 = load i32, i32* @stderr
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %37, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %36, %29
%41 = phi i32 [ 0, %29 ], [ -1, %36 ]
ret i32 %41
}