#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*/ putc(int, int /*<<< orphan*/ *);
void writeSection(FILE *file, unsigned long num, unsigned long size) {
  putc((int)(num & 0xFF), file);
  putc((int)((num >> 8) & 0xFF), file);
  putc((int)((num >> 16) & 0xFF), file);
  putc((int)((num >> 24) & 0xFF), file);
  putc((int)(size & 0xFF), file);
  putc((int)((size >> 8) & 0xFF), file);
  putc((int)((size >> 16) & 0xFF), file);
  putc((int)((size >> 24) & 0xFF), file);
}


x86 assembly (clang, -O0):
<writeSection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0xff,%rax
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x10(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x10(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x10(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x18(%rbp),%rax
and    $0xff,%rax
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x18(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x18(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x18(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeSection>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
movzbl %bl,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
movzbl %bh,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
shr    $0x18,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
mov    %r15,%rbx
movzbl %bl,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
movzbl %bh,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
shr    $0x18,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putc@plt>

LLVM IR (-O0):
define void @writeSection(i32* %0, i64 %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
store i32* %0, i32** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%7 = load i64, i64* %5
%8 = and i64 %7, 255
%9 = trunc i64 %8 to i32
%10 = load i32*, i32** %4
%11 = call i32 @putc(i32 %9, i32* %10)
%12 = load i64, i64* %5
%13 = lshr i64 %12, 8
%14 = and i64 %13, 255
%15 = trunc i64 %14 to i32
%16 = load i32*, i32** %4
%17 = call i32 @putc(i32 %15, i32* %16)
%18 = load i64, i64* %5
%19 = lshr i64 %18, 16
%20 = and i64 %19, 255
%21 = trunc i64 %20 to i32
%22 = load i32*, i32** %4
%23 = call i32 @putc(i32 %21, i32* %22)
%24 = load i64, i64* %5
%25 = lshr i64 %24, 24
%26 = and i64 %25, 255
%27 = trunc i64 %26 to i32
%28 = load i32*, i32** %4
%29 = call i32 @putc(i32 %27, i32* %28)
%30 = load i64, i64* %6
%31 = and i64 %30, 255
%32 = trunc i64 %31 to i32
%33 = load i32*, i32** %4
%34 = call i32 @putc(i32 %32, i32* %33)
%35 = load i64, i64* %6
%36 = lshr i64 %35, 8
%37 = and i64 %36, 255
%38 = trunc i64 %37 to i32
%39 = load i32*, i32** %4
%40 = call i32 @putc(i32 %38, i32* %39)
%41 = load i64, i64* %6
%42 = lshr i64 %41, 16
%43 = and i64 %42, 255
%44 = trunc i64 %43 to i32
%45 = load i32*, i32** %4
%46 = call i32 @putc(i32 %44, i32* %45)
%47 = load i64, i64* %6
%48 = lshr i64 %47, 24
%49 = and i64 %48, 255
%50 = trunc i64 %49 to i32
%51 = load i32*, i32** %4
%52 = call i32 @putc(i32 %50, i32* %51)
ret void
}

LLVM IR (-O2):
define void @writeSection(i32* nocapture %0, i64 %1, i64 %2) {
%4 = trunc i64 %1 to i32
%5 = and i32 %4, 255
%6 = tail call i32 @putc(i32 %5, i32* %0)
%7 = lshr i32 %4, 8
%8 = and i32 %7, 255
%9 = tail call i32 @putc(i32 %8, i32* %0)
%10 = lshr i32 %4, 16
%11 = and i32 %10, 255
%12 = tail call i32 @putc(i32 %11, i32* %0)
%13 = lshr i32 %4, 24
%14 = tail call i32 @putc(i32 %13, i32* %0)
%15 = trunc i64 %2 to i32
%16 = and i32 %15, 255
%17 = tail call i32 @putc(i32 %16, i32* %0)
%18 = lshr i32 %15, 8
%19 = and i32 %18, 255
%20 = tail call i32 @putc(i32 %19, i32* %0)
%21 = lshr i32 %15, 16
%22 = and i32 %21, 255
%23 = tail call i32 @putc(i32 %22, i32* %0)
%24 = lshr i32 %15, 24
%25 = tail call i32 @putc(i32 %24, i32* %0)
ret void
}