#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 const *, char *);
size_t fwrite(char const *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ panic(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ perror(char const *);
void spit_bytes(const char *fname, const char *content, size_t size) {
  FILE *fd = fopen(fname, "w");
  if (fd) {
    if (fwrite(content, 1, size, fd) != size) {
      perror(fname);
      panic(NULL,
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/bjarneh/organice/refs/heads/master/src/"
            "utilz/handy.c",
            174);
    }
    fclose(fd);
  } else {
    perror(fname);
    panic(NULL,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/bjarneh/organice/refs/heads/master/src/"
          "utilz/handy.c",
          181);
  }
}


x86 assembly (clang, -O0):
<spit_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11cf <spit_bytes+0x7f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1070 <fwrite@plt>
cmp    -0x18(%rbp),%rax
je     11c1 <spit_bytes+0x71>
mov    -0x8(%rbp),%rdi
call   1060 <perror@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe4b(%rip),%rsi
mov    $0xae,%edx
call   1040 <panic@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11ed <spit_bytes+0x9d>
mov    -0x8(%rbp),%rdi
call   1060 <perror@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe1f(%rip),%rsi
mov    $0xb5,%edx
call   1040 <panic@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spit_bytes>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
lea    0xe98(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a0 <spit_bytes+0x50>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %rax,%rcx
call   1070 <fwrite@plt>
cmp    %r15,%rax
jne    11c6 <spit_bytes+0x76>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
mov    %r14,%rdi
call   1060 <perror@plt>
lea    0xe53(%rip),%rsi
xor    %edi,%edi
mov    $0xb5,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <panic@plt>
mov    %r14,%rdi
call   1060 <perror@plt>
lea    0xe2d(%rip),%rsi
xor    %edi,%edi
mov    $0xae,%edx
call   1040 <panic@plt>
jmp    118d <spit_bytes+0x3d>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bjarneh/organice/refs/heads/master/src/utilz/handy.c\00"
define void @spit_bytes(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i8*, i8** %4
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %26
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = load i64, i64* %6
%15 = load i32*, i32** %7
%16 = call i64 @fwrite(i8* %13, i32 1, i64 %14, i32* %15)
%17 = load i64, i64* %6
%18 = icmp ne i64 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %12
%20 = load i8*, i8** %4
%21 = call i32 @perror(i8* %20)
%22 = call i32 @panic(i32* null, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 174)
br label %23
23: ; preds = %19, %12
%24 = load i32*, i32** %7
%25 = call i32 @fclose(i32* %24)
br label %30
26: ; preds = %3
%27 = load i8*, i8** %4
%28 = call i32 @perror(i8* %27)
%29 = call i32 @panic(i32* null, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 181)
br label %30
30: ; preds = %26, %23
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bjarneh/organice/refs/heads/master/src/utilz/handy.c\00"
define void @spit_bytes(i8* nocapture %0, i8* nocapture %1, i64 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = tail call i64 @fwrite(i8* %1, i32 1, i64 %2, i32* %4)
%8 = icmp eq i64 %7, %2
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i32 @perror(i8* %0)
%11 = tail call i32 @panic(i32* null, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 174)
br label %12
12: ; preds = %9, %6
%13 = tail call i32 @fclose(i32* %4)
br label %17
14: ; preds = %3
%15 = tail call i32 @perror(i8* %0)
%16 = tail call i32 @panic(i32* null, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 181)
br label %17
17: ; preds = %14, %12
ret void
}