#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int);
void printval(int i) {
  int tth, th, h, t, d;
  if (i > 99999) {
    printf("Error - printval outofbounds\n");
    return;
  }
  tth = 0;
  th = 0;
  h = (i - ((tth * 10000) + (th * 1000))) / 100;
  t = (i - ((tth * 10000) + (th * 1000) + (h * 100))) / 10;
  d = (i - ((tth * 10000) + (th * 1000) + (h * 100) + (t * 10)));
  putchar(h + '0');
  putchar(t + '0');
  putchar(d + '0');
}


x86 assembly (clang, -O0):
<printval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1869f,-0x4(%rbp)
jle    1149 <printval+0x29>
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
jmp    11e2 <printval+0xc2>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
imul   $0x2710,-0x8(%rbp),%ecx
imul   $0x3e8,-0xc(%rbp),%edx
add    %edx,%ecx
sub    %ecx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
imul   $0x2710,-0x8(%rbp),%ecx
imul   $0x3e8,-0xc(%rbp),%edx
add    %edx,%ecx
imul   $0x64,-0x10(%rbp),%edx
add    %edx,%ecx
sub    %ecx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
imul   $0x2710,-0x8(%rbp),%ecx
imul   $0x3e8,-0xc(%rbp),%edx
add    %edx,%ecx
imul   $0x64,-0x10(%rbp),%edx
add    %edx,%ecx
imul   $0xa,-0x14(%rbp),%edx
add    %edx,%ecx
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
add    $0x30,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%edi
add    $0x30,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%edi
add    $0x30,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printval>:
cmp    $0x186a0,%edi
jl     1134 <printval+0x14>
lea    0xed1(%rip),%rdi
jmp    1040 <puts@plt>
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movslq %edi,%rax
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
lea    (%rax,%rcx,1),%edx
imul   $0x64,%edx,%edx
sub    %edx,%edi
movslq %edi,%r14
imul   $0x66666667,%r14,%rbx
mov    %rbx,%r15
shr    $0x3f,%r15
sar    $0x22,%rbx
lea    (%rbx,%r15,1),%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%ebp
lea    (%rax,%rcx,1),%edi
add    $0x30,%edi
call   1030 <putchar@plt>
lea    (%rbx,%r15,1),%edi
add    $0x30,%edi
call   1030 <putchar@plt>
sub    %ebp,%r14d
add    $0x30,%r14d
mov    %r14d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Error - printval outofbounds\0A\00"
define void @printval(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %2
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 99999
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %54
12: ; preds = %1
store i32 0, i32* %3
store i32 0, i32* %4
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = mul nsw i32 %14, 10000
%16 = load i32, i32* %4
%17 = mul nsw i32 %16, 1000
%18 = add nsw i32 %15, %17
%19 = sub nsw i32 %13, %18
%20 = sdiv i32 %19, 100
store i32 %20, i32* %5
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = mul nsw i32 %22, 10000
%24 = load i32, i32* %4
%25 = mul nsw i32 %24, 1000
%26 = add nsw i32 %23, %25
%27 = load i32, i32* %5
%28 = mul nsw i32 %27, 100
%29 = add nsw i32 %26, %28
%30 = sub nsw i32 %21, %29
%31 = sdiv i32 %30, 10
store i32 %31, i32* %6
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = mul nsw i32 %33, 10000
%35 = load i32, i32* %4
%36 = mul nsw i32 %35, 1000
%37 = add nsw i32 %34, %36
%38 = load i32, i32* %5
%39 = mul nsw i32 %38, 100
%40 = add nsw i32 %37, %39
%41 = load i32, i32* %6
%42 = mul nsw i32 %41, 10
%43 = add nsw i32 %40, %42
%44 = sub nsw i32 %32, %43
store i32 %44, i32* %7
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 48
%47 = call i32 @putchar(i32 %46)
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 48
%50 = call i32 @putchar(i32 %49)
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 48
%53 = call i32 @putchar(i32 %52)
br label %54
54: ; preds = %12, %10
ret void
}

LLVM IR (-O2):
@str = [29 x i8] c"Error - printval outofbounds\00"
define void @printval(i32 %0) {
%2 = icmp sgt i32 %0, 99999
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %19
5: ; preds = %1
%6 = sdiv i32 %0, 100
%7 = mul nsw i32 %6, 100
%8 = srem i32 %0, 100
%9 = sdiv i32 %8, 10
%10 = mul nsw i32 %9, -10
%11 = add nsw i32 %6, 48
%12 = tail call i32 @putchar(i32 %11)
%13 = add nsw i32 %9, 48
%14 = tail call i32 @putchar(i32 %13)
%15 = add nsw i32 %0, 48
%16 = sub i32 %15, %7
%17 = add i32 %16, %10
%18 = tail call i32 @putchar(i32 %17)
br label %19
19: ; preds = %5, %3
ret void
}