#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*/ uint8_t;
typedef int uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ putc(int /*<<< orphan*/, int /*<<< orphan*/ *);
void fwriteulong(uint32_t ul, FILE *fd) {
  putc((uint8_t)(ul & 0xff), fd);
  ul = ul >> 8;
  putc((uint8_t)(ul & 0xff), fd);
  ul = ul >> 8;
  putc((uint8_t)(ul & 0xff), fd);
  ul = ul >> 8;
  putc((uint8_t)(ul & 0xff), fd);
  ul = ul >> 8;
}


x86 assembly (clang, -O0):
<fwriteulong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x4(%rbp)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fwriteulong>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
movzbl %bl,%edi
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
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putc@plt>

LLVM IR (-O0):
define void @fwriteulong(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
%5 = load i32, i32* %3
%6 = and i32 %5, 255
%7 = load i32*, i32** %4
%8 = call i32 @putc(i32 %6, i32* %7)
%9 = load i32, i32* %3
%10 = ashr i32 %9, 8
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = and i32 %11, 255
%13 = load i32*, i32** %4
%14 = call i32 @putc(i32 %12, i32* %13)
%15 = load i32, i32* %3
%16 = ashr i32 %15, 8
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = and i32 %17, 255
%19 = load i32*, i32** %4
%20 = call i32 @putc(i32 %18, i32* %19)
%21 = load i32, i32* %3
%22 = ashr i32 %21, 8
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = and i32 %23, 255
%25 = load i32*, i32** %4
%26 = call i32 @putc(i32 %24, i32* %25)
%27 = load i32, i32* %3
%28 = ashr i32 %27, 8
store i32 %28, i32* %3
ret void
}

LLVM IR (-O2):
define void @fwriteulong(i32 %0, i32* nocapture %1) {
%3 = and i32 %0, 255
%4 = tail call i32 @putc(i32 %3, i32* %1)
%5 = lshr i32 %0, 8
%6 = and i32 %5, 255
%7 = tail call i32 @putc(i32 %6, i32* %1)
%8 = lshr i32 %0, 16
%9 = and i32 %8, 255
%10 = tail call i32 @putc(i32 %9, i32* %1)
%11 = lshr i32 %0, 24
%12 = tail call i32 @putc(i32 %11, i32* %1)
ret void
}