#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 */
int /*<<< orphan*/ file_get_contents(char const *, char **, long *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int load_icc_from_memory(char *, long, char **);
int load_icc(const char *path, char **error) {
  char *icc = NULL;
  long length = 0;
  int ret = 0;
  file_get_contents(path, &icc, &length, NULL);
  if (icc) {
    ret = load_icc_from_memory(icc, length, error);
    free(icc);
  }
  return ret;
}


x86 assembly (clang, -O0):
<load_icc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <file_get_contents@plt>
cmpq   $0x0,-0x18(%rbp)
je     1194 <load_icc+0x64>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1050 <load_icc_from_memory@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_icc>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
xor    %ebx,%ebx
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %ecx,%ecx
call   1040 <file_get_contents@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     1182 <load_icc+0x52>
mov    0x10(%rsp),%rsi
mov    %r14,%rdx
call   1050 <load_icc_from_memory@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @load_icc(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %3
store i8** %1, i8*** %4
store i8* null, i8** %5
store i64 0, i64* %6
store i32 0, i32* %7
%8 = load i8*, i8** %3
%9 = call i32 @file_get_contents(i8* %8, i8** %5, i64* %6, i32* null)
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = load i64, i64* %6
%15 = load i8**, i8*** %4
%16 = call i32 @load_icc_from_memory(i8* %13, i64 %14, i8** %15)
store i32 %16, i32* %7
%17 = load i8*, i8** %5
%18 = call i32 @free(i8* %17)
br label %19
19: ; preds = %12, %2
%20 = load i32, i32* %7
ret i32 %20
}

LLVM IR (-O2):
define i32 @load_icc(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = call i32 @file_get_contents(i8* %0, i8** %3, i64* %4, i32* null)
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load i64, i64* %4
%12 = call i32 @load_icc_from_memory(i8* %8, i64 %11, i8** %1)
%13 = load i8*, i8** %3
%14 = call i32 @free(i8* %13)
br label %15
15: ; preds = %10, %2
%16 = phi i32 [ %12, %10 ], [ 0, %2 ]
ret i32 %16
}