#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 */
scalar_t__ e(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ printf(char *);
unsigned char *stbi_load_from_file(int /*<<< orphan*/ *, int *, int *, int *,
                                   int);
unsigned char *stbi_load(char const *filename, int *x, int *y, int *comp,
                         int req_comp) {
  FILE *f = fopen(filename, "rb");
  unsigned char *result;
  if (!f) {
    printf("Can't open file\n");
    return ((unsigned char *)(e("can't fopen") ? NULL : NULL));
  }
  result = stbi_load_from_file(f, x, y, comp, req_comp);
  fclose(f);
  return result;
}


x86 assembly (clang, -O0):
<stbi_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11b9 <stbi_load+0x69>
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
lea    0xe76(%rip),%rdi
call   1060 <e@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
cmovne %rax,%rax
mov    %rax,-0x8(%rbp)
jmp    11e7 <stbi_load+0x97>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1050 <stbi_load_from_file@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stbi_load>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     119c <stbi_load+0x4c>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14d,%r8d
call   1050 <stbi_load_from_file@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rax
jmp    11b6 <stbi_load+0x66>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe54(%rip),%rdi
call   1060 <e@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [17 x i8] c"Can't open file\0A\00"
@.str.2 = [12 x i8] c"can't fopen\00"
define i8* @stbi_load(i8* %0, i32* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i8*
store i8* %0, i8** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
%14 = load i8*, i8** %7
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %12
%16 = load i32*, i32** %12
%17 = icmp ne i32* %16, null
br i1 %17, label %24, label %18
18: ; preds = %5
%19 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%20 = call i64 @e(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i8* null, i8* null
store i8* %23, i8** %6
br label %34
24: ; preds = %5
%25 = load i32*, i32** %12
%26 = load i32*, i32** %8
%27 = load i32*, i32** %9
%28 = load i32*, i32** %10
%29 = load i32, i32* %11
%30 = call i8* @stbi_load_from_file(i32* %25, i32* %26, i32* %27, i32* %28, i32 %29)
store i8* %30, i8** %13
%31 = load i32*, i32** %12
%32 = call i32 @fclose(i32* %31)
%33 = load i8*, i8** %13
store i8* %33, i8** %6
br label %34
34: ; preds = %24, %18
%35 = load i8*, i8** %6
ret i8* %35
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.2 = [12 x i8] c"can't fopen\00"
@str = [16 x i8] c"Can't open file\00"
define i8* @stbi_load(i8* nocapture %0, i32* %1, i32* %2, i32* %3, i32 %4) {
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%10 = tail call i64 @e(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %14
11: ; preds = %5
%12 = tail call i8* @stbi_load_from_file(i32* %6, i32* %1, i32* %2, i32* %3, i32 %4)
%13 = tail call i32 @fclose(i32* %6)
br label %14
14: ; preds = %11, %8
%15 = phi i8* [ %12, %11 ], [ null, %8 ]
ret i8* %15
}