#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*/ reverse(char *);
void dispDecimalInteger(int val) {
  int temp;
  char str[10], ii = 0;
  while (val) {
    temp = val % 10;
    str[ii] = temp + '0';
    val = val / 10;
    ii++;
  }
  str[ii] = '\0';
  reverse(str);
}


x86 assembly (clang, -O0):
<dispDecimalInteger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,-0x13(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1163 <dispDecimalInteger+0x53>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
movsbq -0x13(%rbp),%rax
mov    %cl,-0x12(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x13(%rbp),%al
add    $0x1,%al
mov    %al,-0x13(%rbp)
jmp    111f <dispDecimalInteger+0xf>
movsbq -0x13(%rbp),%rax
movb   $0x0,-0x12(%rbp,%rax,1)
lea    -0x12(%rbp),%rdi
call   1030 <reverse@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dispDecimalInteger>:
sub    $0x18,%rsp
xor    %eax,%eax
test   %edi,%edi
je     115c <dispDecimalInteger+0x4c>
nopw   0x0(%rax,%rax,1)
movslq %edi,%rcx
imul   $0x66666667,%rcx,%rdi
mov    %rdi,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rdi
add    %edx,%edi
lea    (%rdi,%rdi,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ecx,%esi
sub    %edx,%esi
add    $0x30,%sil
movsbq %al,%rax
mov    %sil,0xe(%rsp,%rax,1)
add    $0x1,%al
add    $0x9,%ecx
cmp    $0x12,%ecx
ja     1120 <dispDecimalInteger+0x10>
movsbq %al,%rax
movb   $0x0,0xe(%rsp,%rax,1)
lea    0xe(%rsp),%rdi
call   1030 <reverse@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @dispDecimalInteger(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i8]
%5 = alloca i8
store i32 %0, i32* %2
store i8 0, i8* %5
br label %6
6: ; preds = %9, %1
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32, i32* %2
%11 = srem i32 %10, 10
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 48
%14 = trunc i32 %13 to i8
%15 = load i8, i8* %5
%16 = sext i8 %15 to i64
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %16
store i8 %14, i8* %17
%18 = load i32, i32* %2
%19 = sdiv i32 %18, 10
store i32 %19, i32* %2
%20 = load i8, i8* %5
%21 = add i8 %20, 1
store i8 %21, i8* %5
br label %6
22: ; preds = %6
%23 = load i8, i8* %5
%24 = sext i8 %23 to i64
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %24
store i8 0, i8* %25
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%27 = call i32 @reverse(i8* %26)
ret void
}

LLVM IR (-O2):
define void @dispDecimalInteger(i32 %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32 %0, 0
br i1 %4, label %19, label %5
5: ; preds = %1, %5
%6 = phi i8 [ %14, %5 ], [ 0, %1 ]
%7 = phi i32 [ %13, %5 ], [ %0, %1 ]
%8 = srem i32 %7, 10
%9 = trunc i32 %8 to i8
%10 = add nsw i8 %9, 48
%11 = sext i8 %6 to i64
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %11
store i8 %10, i8* %12
%13 = sdiv i32 %7, 10
%14 = add i8 %6, 1
%15 = add i32 %7, 9
%16 = icmp ult i32 %15, 19
br i1 %16, label %17, label %5
17: ; preds = %5
%18 = sext i8 %14 to i64
br label %19
19: ; preds = %17, %1
%20 = phi i64 [ 0, %1 ], [ %18, %17 ]
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %20
store i8 0, i8* %21
%22 = call i32 @reverse(i8* %3)
ret void
}