#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(char, int /*<<< orphan*/ *);
void BM_WriteLongInt(FILE *fptr, char *s, long n) {
  int i;
  s[0] = (n & 0xff000000) / 16777216;
  s[1] = (n & 0x00ff0000) / 65536;
  s[2] = (n & 0x0000ff00) / 256;
  s[3] = (n & 0x000000ff);
  for (i = 0; i < 4; i++)
    putc(s[i], fptr);
}


x86 assembly (clang, -O0):
<BM_WriteLongInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movabs $0xff000000,%rax
and    -0x18(%rbp),%rax
mov    $0x1000000,%ecx
cqto
idiv   %rcx
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
and    $0xff0000,%rax
mov    $0x10000,%ecx
cqto
idiv   %rcx
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
and    $0xff00,%rax
mov    $0x100,%ecx
cqto
idiv   %rcx
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x18(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11c7 <BM_WriteLongInt+0xb7>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <putc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1198 <BM_WriteLongInt+0x88>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BM_WriteLongInt>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %edx,%eax
bswap  %eax
mov    %eax,(%rsi)
sar    $0x18,%edx
mov    %edx,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
movsbl 0x1(%rbx),%edi
mov    %r14,%rsi
call   1030 <putc@plt>
movsbl 0x2(%rbx),%edi
mov    %r14,%rsi
call   1030 <putc@plt>
movsbl 0x3(%rbx),%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putc@plt>

LLVM IR (-O0):
define void @BM_WriteLongInt(i32* %0, i8* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i64, i64* %6
%9 = and i64 %8, 4278190080
%10 = sdiv i64 %9, 16777216
%11 = trunc i64 %10 to i8
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 %11, i8* %13
%14 = load i64, i64* %6
%15 = and i64 %14, 16711680
%16 = sdiv i64 %15, 65536
%17 = trunc i64 %16 to i8
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 1
store i8 %17, i8* %19
%20 = load i64, i64* %6
%21 = and i64 %20, 65280
%22 = sdiv i64 %21, 256
%23 = trunc i64 %22 to i8
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i64 2
store i8 %23, i8* %25
%26 = load i64, i64* %6
%27 = and i64 %26, 255
%28 = trunc i64 %27 to i8
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i64 3
store i8 %28, i8* %30
store i32 0, i32* %7
br label %31
31: ; preds = %42, %3
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 4
br i1 %33, label %34, label %45
34: ; preds = %31
%35 = load i8*, i8** %5
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = load i32*, i32** %4
%41 = call i32 @putc(i8 signext %39, i32* %40)
br label %42
42: ; preds = %34
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %31
45: ; preds = %31
ret void
}

LLVM IR (-O2):
define void @BM_WriteLongInt(i32* nocapture %0, i8* nocapture %1, i64 %2) {
%4 = lshr i64 %2, 24
%5 = trunc i64 %4 to i8
store i8 %5, i8* %1
%6 = lshr i64 %2, 16
%7 = trunc i64 %6 to i8
%8 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %7, i8* %8
%9 = lshr i64 %2, 8
%10 = trunc i64 %9 to i8
%11 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %10, i8* %11
%12 = trunc i64 %2 to i8
%13 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %12, i8* %13
%14 = tail call i32 @putc(i8 signext %5, i32* %0)
%15 = load i8, i8* %8
%16 = tail call i32 @putc(i8 signext %15, i32* %0)
%17 = load i8, i8* %11
%18 = tail call i32 @putc(i8 signext %17, i32* %0)
%19 = load i8, i8* %13
%20 = tail call i32 @putc(i8 signext %19, i32* %0)
ret void
}