#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 *, int, int);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
void prratio(FILE *stream, long int num, long int den) {
  int q;
  if (den > 0) {
    if (num > 214748L)
      q = (int)(num / (den / 10000L));
    else
      q = (int)(10000L * num / den);
  } else
    q = 10000;
  if (q < 0) {
    putc('-', stream);
    q = -q;
  }
  fprintf(stream, "%d.%02d%%", q / 100, q % 100);
}


x86 assembly (clang, -O0):
<prratio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jle    118d <prratio+0x6d>
cmpq   $0x346dc,-0x10(%rbp)
jle    1177 <prratio+0x57>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cqto
idiv   %rcx
mov    %eax,-0x1c(%rbp)
jmp    1188 <prratio+0x68>
imul   $0x2710,-0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
mov    %eax,-0x1c(%rbp)
jmp    1194 <prratio+0x74>
movl   $0x2710,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11b4 <prratio+0x94>
mov    -0x8(%rbp),%rsi
mov    $0x2d,%edi
call   1030 <putc@plt>
xor    %eax,%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x2c(%rbp),%edx
lea    0xe23(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prratio>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rdx,%rdx
jle    1165 <prratio+0x45>
mov    %rdx,%rcx
cmp    $0x346dd,%rsi
jl     116c <prratio+0x4c>
movabs $0x346dc5d63886594b,%rdx
c5 6d 34
mov    %rcx,%rax
mul    %rdx
mov    %rdx,%rcx
shr    $0xb,%rcx
mov    %rsi,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     11c4 <prratio+0xa4>
mov    %rsi,%rax
xor    %edx,%edx
div    %rcx
jmp    1184 <prratio+0x64>
mov    $0x2710,%ebx
jmp    119a <prratio+0x7a>
imul   $0x2710,%rsi,%rax
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     11c8 <prratio+0xa8>
cqto
idiv   %rcx
mov    %rax,%rbx
test   %ebx,%ebx
jns    119a <prratio+0x7a>
mov    $0x2d,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
neg    %ebx
mov    %ebx,%eax
imul   $0x51eb851f,%rax,%rdx
shr    $0x25,%rdx
imul   $0x64,%edx,%eax
sub    %eax,%ebx
lea    0xe4d(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fprintf@plt>
mov    %esi,%eax
jmp    11c8 <prratio+0xa8>
xor    %edx,%edx
div    %ecx
mov    %eax,%ebx
test   %ebx,%ebx
jns    119a <prratio+0x7a>
jmp    118b <prratio+0x6b>

LLVM IR (-O0):
@.str = [10 x i8] c"%d.%02d%%\00"
define void @prratio(i32* %0, i64 %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
store i32* %0, i32** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load i64, i64* %6
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %26
10: ; preds = %3
%11 = load i64, i64* %5
%12 = icmp sgt i64 %11, 214748
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i64, i64* %5
%15 = load i64, i64* %6
%16 = sdiv i64 %15, 10000
%17 = sdiv i64 %14, %16
%18 = trunc i64 %17 to i32
store i32 %18, i32* %7
br label %25
19: ; preds = %10
%20 = load i64, i64* %5
%21 = mul nsw i64 10000, %20
%22 = load i64, i64* %6
%23 = sdiv i64 %21, %22
%24 = trunc i64 %23 to i32
store i32 %24, i32* %7
br label %25
25: ; preds = %19, %13
br label %27
26: ; preds = %3
store i32 10000, i32* %7
br label %27
27: ; preds = %26, %25
%28 = load i32, i32* %7
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32*, i32** %4
%32 = call i32 @putc(i8 signext 45, i32* %31)
%33 = load i32, i32* %7
%34 = sub nsw i32 0, %33
store i32 %34, i32* %7
br label %35
35: ; preds = %30, %27
%36 = load i32*, i32** %4
%37 = load i32, i32* %7
%38 = sdiv i32 %37, 100
%39 = load i32, i32* %7
%40 = srem i32 %39, 100
%41 = call i32 @fprintf(i32* %36, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %38, i32 %40)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%d.%02d%%\00"
define void @prratio(i32* nocapture %0, i64 %1, i64 %2) {
%4 = icmp sgt i64 %2, 0
br i1 %4, label %5, label %20
5: ; preds = %3
%6 = icmp sgt i64 %1, 214748
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = udiv i64 %2, 10000
%9 = udiv i64 %1, %8
br label %13
10: ; preds = %5
%11 = mul nsw i64 %1, 10000
%12 = sdiv i64 %11, %2
br label %13
13: ; preds = %7, %10
%14 = phi i64 [ %9, %7 ], [ %12, %10 ]
%15 = trunc i64 %14 to i32
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = tail call i32 @putc(i8 signext 45, i32* %0)
%19 = sub nsw i32 0, %15
br label %20
20: ; preds = %3, %17, %13
%21 = phi i32 [ %19, %17 ], [ %15, %13 ], [ 10000, %3 ]
%22 = udiv i32 %21, 100
%23 = urem i32 %21, 100
%24 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23)
ret void
}