#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;
int /*<<< orphan*/ errorcheck(int /*<<< orphan*/);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(unsigned int *, int, int, int /*<<< orphan*/ *);
void patchheaders(FILE *fp, unsigned int samples) {
  unsigned int tmp32;
  errorcheck(fseek(fp, 4, SEEK_SET));
  tmp32 = samples * 2 + 36;
  errorcheck(fwrite(&tmp32, 4, 1, fp));
  errorcheck(fseek(fp, 40, SEEK_SET));
  tmp32 = samples * 2;
  errorcheck(fwrite(&tmp32, 4, 1, fp));
}


x86 assembly (clang, -O0):
<patchheaders>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e96(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%esi
call   1030 <fseek@plt>
mov    %eax,%edi
call   1040 <errorcheck@plt>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
add    $0x24,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0x10(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    %eax,%edi
call   1040 <errorcheck@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
mov    $0x28,%esi
call   1030 <fseek@plt>
mov    %eax,%edi
call   1040 <errorcheck@plt>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0x10(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    %eax,%edi
call   1040 <errorcheck@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<patchheaders>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
mov    0x2e9d(%rip),%r15
mov    (%r15),%edx
mov    $0x4,%esi
call   1030 <fseek@plt>
mov    %eax,%edi
call   1040 <errorcheck@plt>
mov    %ebx,%ebp
add    %ebx,%ebp
lea    (%rbx,%rbx,1),%eax
add    $0x24,%eax
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
mov    %eax,%edi
call   1040 <errorcheck@plt>
mov    (%r15),%edx
mov    %r14,%rdi
mov    $0x28,%esi
call   1030 <fseek@plt>
mov    %eax,%edi
call   1040 <errorcheck@plt>
mov    %ebp,0x4(%rsp)
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <errorcheck@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
define void @patchheaders(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = load i32, i32* @SEEK_SET
%8 = call i32 @fseek(i32* %6, i32 4, i32 %7)
%9 = call i32 @errorcheck(i32 %8)
%10 = load i32, i32* %4
%11 = mul i32 %10, 2
%12 = add i32 %11, 36
store i32 %12, i32* %5
%13 = load i32*, i32** %3
%14 = call i32 @fwrite(i32* %5, i32 4, i32 1, i32* %13)
%15 = call i32 @errorcheck(i32 %14)
%16 = load i32*, i32** %3
%17 = load i32, i32* @SEEK_SET
%18 = call i32 @fseek(i32* %16, i32 40, i32 %17)
%19 = call i32 @errorcheck(i32 %18)
%20 = load i32, i32* %4
%21 = mul i32 %20, 2
store i32 %21, i32* %5
%22 = load i32*, i32** %3
%23 = call i32 @fwrite(i32* %5, i32 4, i32 1, i32* %22)
%24 = call i32 @errorcheck(i32 %23)
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define void @patchheaders(i32* nocapture %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i32, i32* @SEEK_SET
%6 = tail call i32 @fseek(i32* %0, i32 4, i32 %5)
%7 = tail call i32 @errorcheck(i32 %6)
%8 = shl i32 %1, 1
%9 = add i32 %8, 36
store i32 %9, i32* %3
%10 = call i32 @fwrite(i32* %3, i32 4, i32 1, i32* %0)
%11 = tail call i32 @errorcheck(i32 %10)
%12 = load i32, i32* @SEEK_SET
%13 = tail call i32 @fseek(i32* %0, i32 40, i32 %12)
%14 = tail call i32 @errorcheck(i32 %13)
store i32 %8, i32* %3
%15 = call i32 @fwrite(i32* %3, i32 4, i32 1, i32* %0)
%16 = tail call i32 @errorcheck(i32 %15)
ret void
}