#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 uint32_t;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ exit(int);
scalar_t__ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stdout;
size_t write_le_uint32(uint32_t v) {
  size_t count;
  for (count = 0; count < 4; count++) {
    if (fputc(v & 0xff, stdout) == EOF) {
      perror("write_le_uint32 fputc");
      exit(1);
    }
    v >>= 8;
  }
  return count;
}


x86 assembly (clang, -O0):
<write_le_uint32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x4,-0x10(%rbp)
jae    11a5 <write_le_uint32+0x75>
mov    -0x4(%rbp),%edi
and    $0xff,%edi
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
call   1030 <fputc@plt>
mov    0x2e7c(%rip),%rcx
cmp    (%rcx),%rax
jne    118b <write_le_uint32+0x5b>
lea    0xe84(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1143 <write_le_uint32+0x13>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_le_uint32>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
movzbl %bl,%edi
mov    0x2e97(%rip),%r14
mov    (%r14),%esi
call   1030 <fputc@plt>
mov    0x2e98(%rip),%r15
cmp    (%r15),%rax
je     1197 <write_le_uint32+0x67>
movzbl %bh,%edi
mov    (%r14),%esi
call   1030 <fputc@plt>
cmp    (%r15),%rax
je     1197 <write_le_uint32+0x67>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%edi
mov    (%r14),%esi
call   1030 <fputc@plt>
cmp    (%r15),%rax
je     1197 <write_le_uint32+0x67>
shr    $0x18,%ebx
mov    (%r14),%esi
mov    %ebx,%edi
call   1030 <fputc@plt>
cmp    (%r15),%rax
je     1197 <write_le_uint32+0x67>
mov    $0x4,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe62(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@EOF = global i64 0
@.str = [22 x i8] c"write_le_uint32 fputc\00"
define i64 @write_le_uint32(i32 %0) {
%2 = alloca i32
%3 = alloca i64
store i32 %0, i32* %2
store i64 0, i64* %3
br label %4
4: ; preds = %20, %1
%5 = load i64, i64* %3
%6 = icmp ult i64 %5, 4
br i1 %6, label %7, label %23
7: ; preds = %4
%8 = load i32, i32* %2
%9 = and i32 %8, 255
%10 = load i32, i32* @stdout
%11 = call i64 @fputc(i32 %9, i32 %10)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %17
14: ; preds = %7
%15 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %7
%18 = load i32, i32* %2
%19 = ashr i32 %18, 8
store i32 %19, i32* %2
br label %20
20: ; preds = %17
%21 = load i64, i64* %3
%22 = add i64 %21, 1
store i64 %22, i64* %3
br label %4
23: ; preds = %4
%24 = load i64, i64* %3
ret i64 %24
}

LLVM IR (-O2):
@stdout = global i32 0
@EOF = global i64 0
@.str = [22 x i8] c"write_le_uint32 fputc\00"
define i64 @write_le_uint32(i32 %0) {
%2 = and i32 %0, 255
%3 = load i32, i32* @stdout
%4 = tail call i64 @fputc(i32 %2, i32 %3)
%5 = load i64, i64* @EOF
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %10
7: ; preds = %24, %17, %10, %1
%8 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = lshr i32 %0, 8
%12 = and i32 %11, 255
%13 = load i32, i32* @stdout
%14 = tail call i64 @fputc(i32 %12, i32 %13)
%15 = load i64, i64* @EOF
%16 = icmp eq i64 %14, %15
br i1 %16, label %7, label %17
17: ; preds = %10
%18 = lshr i32 %0, 16
%19 = and i32 %18, 255
%20 = load i32, i32* @stdout
%21 = tail call i64 @fputc(i32 %19, i32 %20)
%22 = load i64, i64* @EOF
%23 = icmp eq i64 %21, %22
br i1 %23, label %7, label %24
24: ; preds = %17
%25 = lshr i32 %0, 24
%26 = load i32, i32* @stdout
%27 = tail call i64 @fputc(i32 %25, i32 %26)
%28 = load i64, i64* @EOF
%29 = icmp eq i64 %27, %28
br i1 %29, label %7, label %30
30: ; preds = %24
ret i64 4
}