#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_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(unsigned char **, int, int, int /*<<< orphan*/ *);
void png_patch_len(FILE *fi, int pos, int len) {
  unsigned char mylen[4];
  long filepos;
  mylen[0] = len >> 24;
  mylen[1] = len >> 16;
  mylen[2] = len >> 8;
  mylen[3] = len;
  fseek(fi, pos, SEEK_SET);
  fwrite(&mylen, 4, 1, fi);
  fseek(fi, 0, SEEK_END);
}


x86 assembly (clang, -O0):
<png_patch_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x18,%eax
mov    %al,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x10,%eax
mov    %al,-0x13(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x8,%eax
mov    %al,-0x12(%rbp)
mov    -0x10(%rbp),%eax
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
call   1030 <fseek@plt>
lea    -0x14(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fwrite@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e5e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1030 <fseek@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<png_patch_len>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
bswap  %edx
mov    %edx,0xc(%rsp)
mov    0x2ea3(%rip),%rax
mov    (%rax),%edx
call   1030 <fseek@plt>
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <fseek@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
define void @png_patch_len(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [4 x i8]
%8 = alloca i64
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
%10 = ashr i32 %9, 24
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
store i8 %11, i8* %12
%13 = load i32, i32* %6
%14 = ashr i32 %13, 16
%15 = trunc i32 %14 to i8
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 1
store i8 %15, i8* %16
%17 = load i32, i32* %6
%18 = ashr i32 %17, 8
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 2
store i8 %19, i8* %20
%21 = load i32, i32* %6
%22 = trunc i32 %21 to i8
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 3
store i8 %22, i8* %23
%24 = load i32*, i32** %4
%25 = load i32, i32* %5
%26 = load i32, i32* @SEEK_SET
%27 = call i32 @fseek(i32* %24, i32 %25, i32 %26)
%28 = bitcast [4 x i8]* %7 to i8**
%29 = load i32*, i32** %4
%30 = call i32 @fwrite(i8** %28, i32 4, i32 1, i32* %29)
%31 = load i32*, i32** %4
%32 = load i32, i32* @SEEK_END
%33 = call i32 @fseek(i32* %31, i32 0, i32 %32)
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
define void @png_patch_len(i32* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%6 = lshr i32 %2, 24
%7 = trunc i32 %6 to i8
store i8 %7, i8* %5
%8 = lshr i32 %2, 16
%9 = trunc i32 %8 to i8
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
store i8 %9, i8* %10
%11 = lshr i32 %2, 8
%12 = trunc i32 %11 to i8
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
store i8 %12, i8* %13
%14 = trunc i32 %2 to i8
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
store i8 %14, i8* %15
%16 = load i32, i32* @SEEK_SET
%17 = tail call i32 @fseek(i32* %0, i32 %1, i32 %16)
%18 = bitcast [4 x i8]* %4 to i8**
%19 = call i32 @fwrite(i8** %18, i32 4, i32 1, i32* %0)
%20 = load i32, i32* @SEEK_END
%21 = tail call i32 @fseek(i32* %0, i32 0, i32 %20)
ret void
}