#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*/ fprintf(int /*<<< orphan*/ *, char *, char const *,
                           long long, long long);
void fprint_satoshi2btc(FILE *f, long long satoshi) {
  const char *neg = "";
  long long decimal;
  long long whole;
  if (satoshi < 0) {
    satoshi = -satoshi;
    neg = "-";
  }
  whole = satoshi / 100000000;
  decimal = satoshi % 100000000;
  fprintf(f, "%s%lld.%08lld", neg, whole, decimal);
}


x86 assembly (clang, -O0):
<fprint_satoshi2btc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    114b <fprint_satoshi2btc+0x3b>
xor    %eax,%eax
sub    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0xeb9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x5f5e100,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x5f5e100,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe7c(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_satoshi2btc>:
test   %rsi,%rsi
lea    0xee6(%rip),%rax
lea    0xee0(%rip),%r9
cmovs  %rax,%r9
mov    %rsi,%r8
neg    %r8
cmovs  %rsi,%r8
movabs $0xabcc77118461cefd,%rcx
77 cc ab
mov    %r8,%rax
mul    %rcx
mov    %rdx,%rcx
shr    $0x1a,%rcx
imul   $0x5f5e100,%rcx,%rax
sub    %rax,%r8
lea    0xeab(%rip),%rsi
mov    %r9,%rdx
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [14 x i8] c"%s%lld.%08lld\00"
define void @fprint_satoshi2btc(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i32* %0, i32** %3
store i64 %1, i64* %4
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %5
%8 = load i64, i64* %4
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i64, i64* %4
%12 = sub nsw i64 0, %11
store i64 %12, i64* %4
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %13
13: ; preds = %10, %2
%14 = load i64, i64* %4
%15 = sdiv i64 %14, 100000000
store i64 %15, i64* %7
%16 = load i64, i64* %4
%17 = srem i64 %16, 100000000
store i64 %17, i64* %6
%18 = load i32*, i32** %3
%19 = load i8*, i8** %5
%20 = load i64, i64* %7
%21 = load i64, i64* %6
%22 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %19, i64 %20, i64 %21)
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [14 x i8] c"%s%lld.%08lld\00"
define void @fprint_satoshi2btc(i32* nocapture %0, i64 %1) {
%3 = icmp slt i64 %1, 0
%4 = sub nsw i64 0, %1
%5 = select i1 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
%6 = select i1 %3, i64 %4, i64 %1
%7 = udiv i64 %6, 100000000
%8 = urem i64 %6, 100000000
%9 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %5, i64 %7, i64 %8)
ret void
}