#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 */
int /*<<< orphan*/ SEEK_SET;
scalar_t__ WriteUint32(long, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
bool WriteIcnsFileMetadata(FILE *file) {
  long size = ftell(file);
  return size >= 0 && fseek(file, 4L, SEEK_SET) == 0 && WriteUint32(size, file);
}


x86 assembly (clang, -O0):
<WriteIcnsFileMetadata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <ftell@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jl     1199 <WriteIcnsFileMetadata+0x69>
mov    -0x8(%rbp),%rdi
mov    0x2e7c(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%esi
call   1050 <fseek@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
jne    1199 <WriteIcnsFileMetadata+0x69>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <WriteUint32@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteIcnsFileMetadata>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <ftell@plt>
xor    %ebp,%ebp
test   %rax,%rax
js     1175 <WriteIcnsFileMetadata+0x45>
mov    %rax,%r14
mov    0x2e93(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%esi
mov    %rbx,%rdi
call   1050 <fseek@plt>
test   %rax,%rax
jne    1175 <WriteIcnsFileMetadata+0x45>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <WriteUint32@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @WriteIcnsFileMetadata(i32* %0) {
%2 = alloca i32*
%3 = alloca i64
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i64 @ftell(i32* %4)
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = icmp sge i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %1
%9 = load i32*, i32** %2
%10 = load i32, i32* @SEEK_SET
%11 = call i64 @fseek(i32* %9, i64 4, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i64, i64* %3
%15 = load i32*, i32** %2
%16 = call i64 @WriteUint32(i64 %14, i32* %15)
%17 = icmp ne i64 %16, 0
br label %18
18: ; preds = %13, %8, %1
%19 = phi i1 [ false, %8 ], [ false, %1 ], [ %17, %13 ]
%20 = zext i1 %19 to i32
ret i32 %20
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @WriteIcnsFileMetadata(i32* %0) {
%2 = tail call i64 @ftell(i32* %0)
%3 = icmp sgt i64 %2, -1
br i1 %3, label %4, label %12
4: ; preds = %1
%5 = load i32, i32* @SEEK_SET
%6 = tail call i64 @fseek(i32* %0, i64 4, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = tail call i64 @WriteUint32(i64 %2, i32* %0)
%10 = icmp ne i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %8, %4, %1
%13 = phi i32 [ 0, %4 ], [ 0, %1 ], [ %11, %8 ]
ret i32 %13
}