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

/* Variables and functions */
scalar_t__ file_exists(char *);
int /*<<< orphan*/ free(unsigned char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(void *, char, int);
int /*<<< orphan*/ write_png_file(char *, int, int, unsigned char *);
void save_icon(char *filename, int resolution) {
  unsigned char *buffer;
  if (file_exists(filename) != 0)
    return;
  buffer = (unsigned char *)malloc(resolution * resolution * 3);
  memset((void *)buffer, '\255', resolution * resolution * 3);
  write_png_file(filename, resolution, resolution, buffer);
  free(buffer);
}


x86 assembly (clang, -O0):
<save_icon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <file_exists@plt>
cmp    $0x0,%rax
je     1177 <save_icon+0x27>
jmp    11be <save_icon+0x6e>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   $0x3,%eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   $0x3,%eax,%edx
mov    $0xffffffad,%esi
call   1050 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1070 <write_png_file@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_icon>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1040 <file_exists@plt>
test   %rax,%rax
je     1171 <save_icon+0x21>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%eax
imul   %eax,%eax
lea    (%rax,%rax,2),%r14d
mov    %r14d,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0xffffffad,%esi
mov    %r14d,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    %r15,%rcx
call   1070 <write_png_file@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @save_icon(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = call i64 @file_exists(i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
br label %30
10: ; preds = %2
%11 = load i32, i32* %4
%12 = load i32, i32* %4
%13 = mul nsw i32 %11, %12
%14 = mul nsw i32 %13, 3
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = load i32, i32* %4
%19 = load i32, i32* %4
%20 = mul nsw i32 %18, %19
%21 = mul nsw i32 %20, 3
%22 = call i32 @memset(i8* %17, i8 signext -83, i32 %21)
%23 = load i8*, i8** %3
%24 = load i32, i32* %4
%25 = load i32, i32* %4
%26 = load i8*, i8** %5
%27 = call i32 @write_png_file(i8* %23, i32 %24, i32 %25, i8* %26)
%28 = load i8*, i8** %5
%29 = call i32 @free(i8* %28)
br label %30
30: ; preds = %10, %9
ret void
}

LLVM IR (-O2):
define void @save_icon(i8* %0, i32 %1) {
%3 = tail call i64 @file_exists(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = mul i32 %1, 3
%7 = mul i32 %6, %1
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i8*
%10 = tail call i32 @memset(i8* %9, i8 signext -83, i32 %7)
%11 = tail call i32 @write_png_file(i8* %0, i32 %1, i32 %1, i8* %9)
%12 = tail call i32 @free(i8* %9)
br label %13
13: ; preds = %2, %5
ret void
}