#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 integerPartOfQuotient(int, int);
int integerRemainder(int, int);
int /*<<< orphan*/ printf(char *, int);
void printDigits(int num) {
  int res = 0;
  if (num >= 10000) {
    res = integerPartOfQuotient(num, 10000);
    printf("%d ", res);
    num -= (res * 10000);
  }
  if (num >= 1000) {
    res = integerPartOfQuotient(num, 1000);
    printf("%d ", res);
    num -= (res * 1000);
  }
  if (num >= 100) {
    res = integerPartOfQuotient(num, 100);
    printf("%d ", res);
    num -= (res * 100);
  }
  if (num >= 10) {
    res = integerPartOfQuotient(num, 10);
    printf("%d ", res);
    num -= (res * 10);
  }
  printf("%d ", integerRemainder(num, 10));
}


x86 assembly (clang, -O0):
<printDigits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x2710,-0x4(%rbp)
jl     117d <printDigits+0x4d>
mov    -0x4(%rbp),%edi
mov    $0x2710,%esi
call   1040 <integerPartOfQuotient@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
imul   $0x2710,-0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jl     11b8 <printDigits+0x88>
mov    -0x4(%rbp),%edi
mov    $0x3e8,%esi
call   1040 <integerPartOfQuotient@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
imul   $0x3e8,-0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jl     11ed <printDigits+0xbd>
mov    -0x4(%rbp),%edi
mov    $0x64,%esi
call   1040 <integerPartOfQuotient@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
imul   $0x64,-0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jl     1222 <printDigits+0xf2>
mov    -0x4(%rbp),%edi
mov    $0xa,%esi
call   1040 <integerPartOfQuotient@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xdef(%rip),%rdi
call   1030 <printf@plt>
imul   $0xa,-0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xa,%esi
call   1050 <integerRemainder@plt>
mov    %eax,%esi
lea    0xdc8(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printDigits>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x2710,%edi
jge    1197 <printDigits+0x67>
cmp    $0x3e8,%ebx
jge    11c3 <printDigits+0x93>
cmp    $0x64,%ebx
jge    11f0 <printDigits+0xc0>
cmp    $0xa,%ebx
jl     1177 <printDigits+0x47>
mov    %ebx,%edi
mov    $0xa,%esi
call   1040 <integerPartOfQuotient@plt>
mov    %eax,%ebp
lea    0xe98(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    %ebp,%ebp
lea    0x0(%rbp,%rbp,4),%eax
sub    %eax,%ebx
mov    %ebx,%edi
mov    $0xa,%esi
call   1050 <integerRemainder@plt>
lea    0xe76(%rip),%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>
mov    %ebx,%edi
mov    $0x2710,%esi
call   1040 <integerPartOfQuotient@plt>
mov    %eax,%ebp
lea    0xe54(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
imul   $0xffffd8f0,%ebp,%eax
add    %eax,%ebx
cmp    $0x3e8,%ebx
jl     1145 <printDigits+0x15>
mov    %ebx,%edi
mov    $0x3e8,%esi
call   1040 <integerPartOfQuotient@plt>
mov    %eax,%ebp
lea    0xe28(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
imul   $0xfffffc18,%ebp,%eax
add    %eax,%ebx
cmp    $0x64,%ebx
jl     114e <printDigits+0x1e>
mov    %ebx,%edi
mov    $0x64,%esi
call   1040 <integerPartOfQuotient@plt>
mov    %eax,%ebp
lea    0xdfb(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
imul   $0xffffff9c,%ebp,%eax
add    %eax,%ebx
cmp    $0xa,%ebx
jge    1153 <printDigits+0x23>
jmp    1177 <printDigits+0x47>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @printDigits(i32 %0) {
%2 = icmp sgt i32 %0, 9999
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = tail call i32 @integerPartOfQuotient(i32 %0, i32 10000)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = mul i32 %4, -10000
%7 = add i32 %6, %0
br label %8
8: ; preds = %3, %1
%9 = phi i32 [ %7, %3 ], [ %0, %1 ]
%10 = icmp sgt i32 %9, 999
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = tail call i32 @integerPartOfQuotient(i32 %9, i32 1000)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = mul i32 %12, -1000
%15 = add i32 %14, %9
br label %16
16: ; preds = %11, %8
%17 = phi i32 [ %15, %11 ], [ %9, %8 ]
%18 = icmp sgt i32 %17, 99
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = tail call i32 @integerPartOfQuotient(i32 %17, i32 100)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = mul i32 %20, -100
%23 = add i32 %22, %17
br label %24
24: ; preds = %19, %16
%25 = phi i32 [ %23, %19 ], [ %17, %16 ]
%26 = icmp sgt i32 %25, 9
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = tail call i32 @integerPartOfQuotient(i32 %25, i32 10)
%29 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = mul i32 %28, -10
%31 = add i32 %30, %25
br label %32
32: ; preds = %27, %24
%33 = phi i32 [ %31, %27 ], [ %25, %24 ]
%34 = tail call i32 @integerRemainder(i32 %33, i32 10)
%35 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %34)
ret void
}