signed int fakeimage(char *name, signed int *xres, signed int *yres,
                     unsigned char **imgdata) {
  signed int i;
  signed int imgsize;
  char msgtxt[2048l];
  sprintf(msgtxt, "Error loading image %s.  Faking it using solid gray.", name);
  rt_ui_message(100, msgtxt);
  *xres = 4;
  *yres = 4;
  imgsize = 3 * *xres * *yres;
  void *return_value_malloc$1;
  return_value_malloc$1 = malloc((unsigned long int)imgsize);
  *imgdata = (unsigned char *)return_value_malloc$1;
  i = 0;
  while (!(i >= imgsize)) {
    (*imgdata)[(signed long int)i] = (unsigned char)255;
    i = i + 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<fakeimage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x830(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x830(%rbp),%rsi
mov    $0x64,%edi
mov    $0x0,%al
call   1030 <rt_ui_message@plt>
mov    -0x10(%rbp),%rax
movl   $0x4,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x4,(%rax)
mov    -0x10(%rbp),%rax
imul   $0x3,(%rax),%eax
mov    -0x18(%rbp),%rcx
imul   (%rcx),%eax
mov    %eax,-0x28(%rbp)
movslq -0x28(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x838(%rbp)
mov    -0x838(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
setge  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d9 <fakeimage+0xa9>
jmp    11f6 <fakeimage+0xc6>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movslq -0x24(%rbp),%rcx
movb   $0xff,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c1 <fakeimage+0x91>
xor    %eax,%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fakeimage>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x800,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rdx
lea    0xeae(%rip),%rsi
mov    %rsp,%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    $0x64,%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <rt_ui_message@plt>
movl   $0x4,(%r15)
movl   $0x4,(%r14)
mov    (%r15),%eax
shl    $0x2,%eax
lea    (%rax,%rax,2),%ebp
movslq %ebp,%r14
mov    %r14,%rdi
call   1040 <malloc@plt>
mov    %rax,(%rbx)
test   %r14d,%r14d
jle    11f4 <fakeimage+0xc4>
movb   $0xff,(%rax)
mov    $0x1,%eax
cmp    $0x4,%ebp
je     11dd <fakeimage+0xad>
mov    %ebp,%ecx
add    $0xfffffffffffffffc,%rcx
xor    %eax,%eax
nopl   (%rax)
mov    (%rbx),%rdx
movb   $0xff,0x1(%rdx,%rax,1)
mov    (%rbx),%rdx
movb   $0xff,0x2(%rdx,%rax,1)
mov    (%rbx),%rdx
movb   $0xff,0x3(%rdx,%rax,1)
mov    (%rbx),%rdx
movb   $0xff,0x4(%rdx,%rax,1)
add    $0x4,%rax
cmp    %rax,%rcx
jne    11b0 <fakeimage+0x80>
add    $0x1,%rax
xor    %ecx,%ecx
nop
mov    (%rbx),%rdx
add    %rax,%rdx
movb   $0xff,(%rcx,%rdx,1)
add    $0x1,%rcx
cmp    $0x3,%rcx
jne    11e0 <fakeimage+0xb0>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c"Error loading image %s. Faking it using solid gray.\00"
define i32 @fakeimage(i8* %0, i32* %1, i32* %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
%11 = alloca [2048 x i8]
%12 = alloca i8*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i8** %3, i8*** %8
%13 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%14 = load i8*, i8** %5
%15 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%17 = call i32 (i32, i8*, ...) bitcast (i32 (...)* @rt_ui_message to i32 (i32, i8*, ...)*)(i32 100, i8* %16)
%18 = load i32*, i32** %6
store i32 4, i32* %18
%19 = load i32*, i32** %7
store i32 4, i32* %19
%20 = load i32*, i32** %6
%21 = load i32, i32* %20
%22 = mul nsw i32 3, %21
%23 = load i32*, i32** %7
%24 = load i32, i32* %23
%25 = mul nsw i32 %22, %24
store i32 %25, i32* %10
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = call i8* @malloc(i64 %27)
store i8* %28, i8** %12
%29 = load i8*, i8** %12
%30 = load i8**, i8*** %8
store i8* %29, i8** %30
store i32 0, i32* %9
br label %31
31: ; preds = %36, %4
%32 = load i32, i32* %9
%33 = load i32, i32* %10
%34 = icmp sge i32 %32, %33
%35 = xor i1 %34, true
br i1 %35, label %36, label %44
36: ; preds = %31
%37 = load i8**, i8*** %8
%38 = load i8*, i8** %37
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 -1, i8* %41
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
store i32 %43, i32* %9
br label %31
44: ; preds = %31
ret i32 0
}

LLVM IR (-O2):
@.str = [53 x i8] c"Error loading image %s. Faking it using solid gray.\00"
define i32 @fakeimage(i8* %0, i32* nocapture %1, i32* nocapture writeonly %2, i8** nocapture %3) {
%5 = alloca [2048 x i8]
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%7 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = call i32 (i32, i8*, ...) bitcast (i32 (...)* @rt_ui_message to i32 (i32, i8*, ...)*)(i32 100, i8* %6)
store i32 4, i32* %1
store i32 4, i32* %2
%9 = load i32, i32* %1
%10 = mul i32 %9, 12
%11 = sext i32 %10 to i64
%12 = call i8* @malloc(i64 %11)
store i8* %12, i8** %3
%13 = icmp sgt i32 %10, 0
br i1 %13, label %14, label %46
14: ; preds = %4
store i8 -1, i8* %12
%15 = icmp eq i32 %10, 4
br i1 %15, label %36, label %16
16: ; preds = %14
%17 = zext i32 %10 to i64
%18 = add nsw i64 %17, -4
br label %19
19: ; preds = %19, %16
%20 = phi i64 [ 1, %16 ], [ %33, %19 ]
%21 = phi i64 [ 0, %16 ], [ %34, %19 ]
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 %20
store i8 -1, i8* %23
%24 = add nuw nsw i64 %20, 1
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 %24
store i8 -1, i8* %26
%27 = add nuw nsw i64 %20, 2
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 %27
store i8 -1, i8* %29
%30 = add nuw nsw i64 %20, 3
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 %30
store i8 -1, i8* %32
%33 = add nuw nsw i64 %20, 4
%34 = add i64 %21, 4
%35 = icmp eq i64 %34, %18
br i1 %35, label %36, label %19
36: ; preds = %14, %19
%37 = phi i64 [ 1, %14 ], [ %33, %19 ]
br label %38
38: ; preds = %38, %36
%39 = phi i64 [ %37, %36 ], [ %43, %38 ]
%40 = phi i64 [ 0, %36 ], [ %44, %38 ]
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i64 %39
store i8 -1, i8* %42
%43 = add nuw nsw i64 %39, 1
%44 = add i64 %40, 1
%45 = icmp eq i64 %44, 3
br i1 %45, label %46, label %38
46: ; preds = %38, %4
ret i32 0
}