void printDigitsReverseOrder(num1) {
  if (num1 == 0) {
    printf("0");
    return;
  } else {
    if (num1 < 0) {
      printf("-");
      num1 *= -1;
    }
    do {
      printf("%d", num1 % 10);
      num1 /= 10;
    } while (num1 > 0);
  }
  return;
}


x86 assembly (clang, -O0):
<printDigitsReverseOrder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1138 <printDigitsReverseOrder+0x28>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1199 <printDigitsReverseOrder+0x89>
cmpl   $0x0,-0x4(%rbp)
jge    1157 <printDigitsReverseOrder+0x47>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    115c <printDigitsReverseOrder+0x4c>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     115c <printDigitsReverseOrder+0x4c>
jmp    1194 <printDigitsReverseOrder+0x84>
jmp    1199 <printDigitsReverseOrder+0x89>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printDigitsReverseOrder>:
test   %edi,%edi
je     1178 <printDigitsReverseOrder+0x58>
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
jns    1139 <printDigitsReverseOrder+0x19>
mov    $0x2d,%edi
call   1030 <putchar@plt>
neg    %ebx
lea    0xec0(%rip),%r14
movslq %ebx,%r15
imul   $0x66666667,%r15,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x22,%rbx
add    %eax,%ebx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %r15d,%esi
sub    %eax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x9,%r15d
jg     1140 <printDigitsReverseOrder+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0x30,%edi
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"0\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"%d\00"
define void @printDigitsReverseOrder(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %26
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* %2
%13 = mul nsw i32 %12, -1
store i32 %13, i32* %2
br label %14
14: ; preds = %10, %7
br label %15
15: ; preds = %21, %14
%16 = load i32, i32* %2
%17 = srem i32 %16, 10
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %2
%20 = sdiv i32 %19, 10
store i32 %20, i32* %2
br label %21
21: ; preds = %15
%22 = load i32, i32* %2
%23 = icmp sgt i32 %22, 0
br i1 %23, label %15, label %24
24: ; preds = %21
br label %25
25: ; preds = %24
br label %26
26: ; preds = %25, %5
ret void
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
define void @printDigitsReverseOrder(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @putchar(i32 48)
br label %18
5: ; preds = %1
%6 = icmp slt i32 %0, 0
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = tail call i32 @putchar(i32 45)
%9 = sub nsw i32 0, %0
br label %10
10: ; preds = %7, %5
%11 = phi i32 [ %0, %5 ], [ %9, %7 ]
br label %12
12: ; preds = %10, %12
%13 = phi i32 [ %16, %12 ], [ %11, %10 ]
%14 = srem i32 %13, 10
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = sdiv i32 %13, 10
%17 = icmp sgt i32 %13, 9
br i1 %17, label %12, label %18
18: ; preds = %12, %3
ret void
}