#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 *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int dump_raw(const char *fname, int width, int depth, unsigned char *red_arry,
             unsigned char *green_arry, unsigned char *blue_arry) {
  FILE *fp;
  int i;
  fp = fopen(fname, "w+");
  if (!fp)
    return 0;
  for (i = 0; i < (width * depth); i++) {
    putc((int)(red_arry[i]), fp);
    putc((int)(green_arry[i]), fp);
    putc((int)(blue_arry[i]), fp);
  }
  fclose(fp);
  return 1;
}


x86 assembly (clang, -O0):
<dump_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1179 <dump_raw+0x49>
movl   $0x0,-0x4(%rbp)
jmp    11ef <dump_raw+0xbf>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
cmp    %ecx,%eax
jge    11df <dump_raw+0xaf>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
mov    -0x38(%rbp),%rsi
call   1040 <putc@plt>
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
mov    -0x38(%rbp),%rsi
call   1040 <putc@plt>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
mov    -0x38(%rbp),%rsi
call   1040 <putc@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1180 <dump_raw+0x50>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_raw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
mov    %edx,%ebp
mov    %esi,%r13d
lea    0xeb0(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11af <dump_raw+0x7f>
mov    %rax,%rbx
imul   %r13d,%ebp
test   %ebp,%ebp
jle    11a0 <dump_raw+0x70>
mov    %ebp,%r13d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rbp,1),%edi
mov    %rbx,%rsi
call   1040 <putc@plt>
movzbl (%r15,%rbp,1),%edi
mov    %rbx,%rsi
call   1040 <putc@plt>
movzbl (%r14,%rbp,1),%edi
mov    %rbx,%rsi
call   1040 <putc@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1170 <dump_raw+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
jmp    11b1 <dump_raw+0x81>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"w+\00"
define i32 @dump_raw(i8* %0, i32 %1, i32 %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32*
%15 = alloca i32
store i8* %0, i8** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
%16 = load i8*, i8** %8
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %14
%18 = load i32*, i32** %14
%19 = icmp ne i32* %18, null
br i1 %19, label %21, label %20
20: ; preds = %6
store i32 0, i32* %7
br label %59
21: ; preds = %6
store i32 0, i32* %15
br label %22
22: ; preds = %53, %21
%23 = load i32, i32* %15
%24 = load i32, i32* %9
%25 = load i32, i32* %10
%26 = mul nsw i32 %24, %25
%27 = icmp slt i32 %23, %26
br i1 %27, label %28, label %56
28: ; preds = %22
%29 = load i8*, i8** %11
%30 = load i32, i32* %15
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = load i32*, i32** %14
%36 = call i32 @putc(i32 %34, i32* %35)
%37 = load i8*, i8** %12
%38 = load i32, i32* %15
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = load i32*, i32** %14
%44 = call i32 @putc(i32 %42, i32* %43)
%45 = load i8*, i8** %13
%46 = load i32, i32* %15
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = load i32*, i32** %14
%52 = call i32 @putc(i32 %50, i32* %51)
br label %53
53: ; preds = %28
%54 = load i32, i32* %15
%55 = add nsw i32 %54, 1
store i32 %55, i32* %15
br label %22
56: ; preds = %22
%57 = load i32*, i32** %14
%58 = call i32 @fclose(i32* %57)
store i32 1, i32* %7
br label %59
59: ; preds = %56, %20
%60 = load i32, i32* %7
ret i32 %60
}

LLVM IR (-O2):
@.str = [3 x i8] c"w+\00"
define i32 @dump_raw(i8* nocapture %0, i32 %1, i32 %2, i8* nocapture %3, i8* nocapture %4, i8* nocapture %5) {
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %32, label %9
9: ; preds = %6
%10 = mul i32 %2, %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = zext i32 %10 to i64
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %28, %14 ]
%16 = getelementptr inbounds i8, i8* %3, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = tail call i32 @putc(i32 %18, i32* %7)
%20 = getelementptr inbounds i8, i8* %4, i64 %15
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = tail call i32 @putc(i32 %22, i32* %7)
%24 = getelementptr inbounds i8, i8* %5, i64 %15
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = tail call i32 @putc(i32 %26, i32* %7)
%28 = add nuw nsw i64 %15, 1
%29 = icmp eq i64 %28, %13
br i1 %29, label %30, label %14
30: ; preds = %14, %9
%31 = tail call i32 @fclose(i32* %7)
br label %32
32: ; preds = %6, %30
%33 = phi i32 [ 1, %30 ], [ 0, %6 ]
ret i32 %33
}