#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 */
struct boot_img_hdr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ R_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ ftruncate(int, int);
int /*<<< orphan*/ stderr;
void post_process(struct boot_img_hdr *hdr, int ofd, int pos) {
  if (access("rkcrc", R_OK) == 0) {
    fprintf(stderr, "Rockchip CRCs not supported yet\n");
    exit(1);
  }
  ftruncate(ofd, pos);
}


x86 assembly (clang, -O0):
<post_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
lea    0xe9e(%rip),%rdi
call   1050 <access@plt>
cmp    $0x0,%rax
jne    1190 <post_process+0x50>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <ftruncate@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<post_process>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%ebp
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
lea    0xea9(%rip),%rdi
call   1050 <access@plt>
test   %rax,%rax
je     1170 <post_process+0x30>
mov    %ebp,%edi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ftruncate@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.boot_img_hdr = type { i32 }
@.str = [6 x i8] c"rkcrc\00"
@R_OK = global i32 0
@stderr = global i32 0
@.str.1 = [33 x i8] c"Rockchip CRCs not supported yet\0A\00"
define void @post_process(%struct.boot_img_hdr* %0, i32 %1, i32 %2) {
%4 = alloca %struct.boot_img_hdr*
%5 = alloca i32
%6 = alloca i32
store %struct.boot_img_hdr* %0, %struct.boot_img_hdr** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* @R_OK
%8 = call i64 @access(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %3
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = call i32 @ftruncate(i32 %15, i32 %16)
ret void
}

LLVM IR (-O2):
%struct.boot_img_hdr = type { i32 }
@.str = [6 x i8] c"rkcrc\00"
@R_OK = global i32 0
@stderr = global i32 0
@.str.1 = [33 x i8] c"Rockchip CRCs not supported yet\0A\00"
define void @post_process(%struct.boot_img_hdr* nocapture readnone %0, i32 %1, i32 %2) {
%4 = load i32, i32* @R_OK
%5 = tail call i64 @access(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %3
%12 = tail call i32 @ftruncate(i32 %1, i32 %2)
ret void
}