#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*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
void writeLeInt32(FILE *f, int v) {
  char c = v;
  fwrite(&c, 1, 1, f);
  v /= 256;
  c = v;
  fwrite(&c, 1, 1, f);
  v /= 256;
  c = v;
  fwrite(&c, 1, 1, f);
  v /= 256;
  c = v;
  fwrite(&c, 1, 1, f);
}


x86 assembly (clang, -O0):
<writeLeInt32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0xd(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fwrite@plt>
mov    -0xc(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0xd(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fwrite@plt>
mov    -0xc(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0xd(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fwrite@plt>
mov    -0xc(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0xd(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fwrite@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeLeInt32>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xffffff(%rsi),%r15d
test   %esi,%esi
cmovns %esi,%r15d
lea    0xffff(%rsi),%ebx
test   %esi,%esi
cmovns %esi,%ebx
lea    0xff(%rsi),%ebp
test   %esi,%esi
movsbl %sil,%edi
cmovns %esi,%ebp
mov    %r14,%rsi
call   1030 <fputc@plt>
shr    $0x8,%ebp
movsbl %bpl,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
shr    $0x10,%ebx
movsbl %bl,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
sar    $0x18,%r15d
mov    %r15d,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

LLVM IR (-O0):
define void @writeLeInt32(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = trunc i32 %6 to i8
store i8 %7, i8* %5
%8 = load i32*, i32** %3
%9 = call i32 @fwrite(i8* %5, i32 1, i32 1, i32* %8)
%10 = load i32, i32* %4
%11 = sdiv i32 %10, 256
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = trunc i32 %12 to i8
store i8 %13, i8* %5
%14 = load i32*, i32** %3
%15 = call i32 @fwrite(i8* %5, i32 1, i32 1, i32* %14)
%16 = load i32, i32* %4
%17 = sdiv i32 %16, 256
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = trunc i32 %18 to i8
store i8 %19, i8* %5
%20 = load i32*, i32** %3
%21 = call i32 @fwrite(i8* %5, i32 1, i32 1, i32* %20)
%22 = load i32, i32* %4
%23 = sdiv i32 %22, 256
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = trunc i32 %24 to i8
store i8 %25, i8* %5
%26 = load i32*, i32** %3
%27 = call i32 @fwrite(i8* %5, i32 1, i32 1, i32* %26)
ret void
}

LLVM IR (-O2):
define void @writeLeInt32(i32* nocapture %0, i32 %1) {
%3 = shl i32 %1, 24
%4 = ashr exact i32 %3, 24
%5 = tail call i32 @fputc(i32 %4, i32* %0)
%6 = sdiv i32 %1, 256
%7 = shl i32 %6, 24
%8 = ashr exact i32 %7, 24
%9 = tail call i32 @fputc(i32 %8, i32* %0)
%10 = sdiv i32 %1, 65536
%11 = shl i32 %10, 24
%12 = ashr exact i32 %11, 24
%13 = tail call i32 @fputc(i32 %12, i32* %0)
%14 = sdiv i32 %1, 16777216
%15 = tail call i32 @fputc(i32 %14, i32* %0)
ret void
}