#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 fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int WriteUINT(unsigned long int x, FILE *f) {
  unsigned char little[4];
  little[3] = (unsigned char)((x & 0xff000000) >> 24);
  little[2] = (unsigned char)((x & 0x00ff0000) >> 16);
  little[1] = (unsigned char)((x & 0x0000ff00) >> 8);
  little[0] = (unsigned char)((x & 0x000000ff) >> 0);
  return (f && fwrite(little, 4, 1, f) == 1);
}


x86 assembly (clang, -O0):
<WriteUINT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0xff000000,%rax
and    -0x8(%rbp),%rax
shr    $0x18,%rax
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rax
and    $0xff0000,%rax
shr    $0x10,%rax
mov    %al,-0x12(%rbp)
mov    -0x8(%rbp),%rax
and    $0xff00,%rax
shr    $0x8,%rax
mov    %al,-0x13(%rbp)
mov    -0x8(%rbp),%rax
and    $0xff,%rax
shr    $0x0,%rax
mov    %al,-0x14(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x15(%rbp)
je     1198 <WriteUINT+0x88>
lea    -0x14(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fwrite@plt>
cmp    $0x1,%eax
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteUINT>:
push   %rax
mov    %edi,0x4(%rsp)
test   %rsi,%rsi
je     113d <WriteUINT+0x2d>
mov    %rsi,%rcx
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fwrite@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
sete   %al
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @WriteUINT(i64 %0, i32* %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca [4 x i8]
store i64 %0, i64* %3
store i32* %1, i32** %4
%6 = load i64, i64* %3
%7 = and i64 %6, 4278190080
%8 = lshr i64 %7, 24
%9 = trunc i64 %8 to i8
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 3
store i8 %9, i8* %10
%11 = load i64, i64* %3
%12 = and i64 %11, 16711680
%13 = lshr i64 %12, 16
%14 = trunc i64 %13 to i8
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
store i8 %14, i8* %15
%16 = load i64, i64* %3
%17 = and i64 %16, 65280
%18 = lshr i64 %17, 8
%19 = trunc i64 %18 to i8
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 1
store i8 %19, i8* %20
%21 = load i64, i64* %3
%22 = and i64 %21, 255
%23 = lshr i64 %22, 0
%24 = trunc i64 %23 to i8
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
store i8 %24, i8* %25
%26 = load i32*, i32** %4
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %33
28: ; preds = %2
%29 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%30 = load i32*, i32** %4
%31 = call i32 @fwrite(i8* %29, i32 4, i32 1, i32* %30)
%32 = icmp eq i32 %31, 1
br label %33
33: ; preds = %28, %2
%34 = phi i1 [ false, %2 ], [ %32, %28 ]
%35 = zext i1 %34 to i32
ret i32 %35
}

LLVM IR (-O2):
define i32 @WriteUINT(i64 %0, i32* %1) {
%3 = alloca [4 x i8]
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%5 = lshr i64 %0, 24
%6 = trunc i64 %5 to i8
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
store i8 %6, i8* %7
%8 = lshr i64 %0, 16
%9 = trunc i64 %8 to i8
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
store i8 %9, i8* %10
%11 = lshr i64 %0, 8
%12 = trunc i64 %11 to i8
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
store i8 %12, i8* %13
%14 = trunc i64 %0 to i8
store i8 %14, i8* %4
%15 = icmp eq i32* %1, null
br i1 %15, label %20, label %16
16: ; preds = %2
%17 = call i32 @fwrite(i8* %4, i32 4, i32 1, i32* %1)
%18 = icmp eq i32 %17, 1
%19 = zext i1 %18 to i32
br label %20
20: ; preds = %16, %2
%21 = phi i32 [ 0, %2 ], [ %19, %16 ]
ret i32 %21
}