#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*/ scanf(char *, int *);
int main(void) {
  int input_number, temp_number, digit_1, digit_2, digit_3, digit_4, digit_5;
  printf("Enter a number between 0 and 32767: ");
  scanf("%5d", &input_number);
  temp_number = input_number;
  digit_5 = temp_number % 8;
  temp_number /= 8;
  digit_4 = temp_number % 8;
  temp_number /= 8;
  digit_3 = temp_number % 8;
  temp_number /= 8;
  digit_2 = temp_number % 8;
  temp_number /= 8;
  digit_1 = temp_number % 8;
  printf("In octal, your number is: %1d%1d%1d%1d%1d\n", digit_1, digit_2,
         digit_3, digit_4, digit_5);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%r9d
lea    0xfff(%r9),%esi
test   %r9d,%r9d
cmovns %r9d,%esi
lea    0x1ff(%r9),%edx
test   %r9d,%r9d
cmovns %r9d,%edx
lea    0x3f(%r9),%ecx
test   %r9d,%r9d
cmovns %r9d,%ecx
lea    0x7(%r9),%r8d
test   %r9d,%r9d
cmovns %r9d,%r8d
mov    %r8d,%eax
and    $0xfffffff8,%eax
sub    %eax,%r9d
sar    $0x3,%r8d
lea    0x7(%r8),%eax
test   %r8d,%r8d
cmovns %r8d,%eax
and    $0xfffffff8,%eax
sub    %eax,%r8d
sar    $0x6,%ecx
lea    0x7(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
and    $0xfffffff8,%eax
sub    %eax,%ecx
sar    $0x9,%edx
lea    0x7(%rdx),%eax
test   %edx,%edx
cmovns %edx,%eax
and    $0xfffffff8,%eax
sub    %eax,%edx
sar    $0xc,%esi
lea    0x7(%rsi),%eax
test   %esi,%esi
cmovns %esi,%eax
and    $0xfffffff8,%eax
sub    %eax,%esi
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Enter a number between 0 and 32767: \00"
@.str.1 = [4 x i8] c"%5d\00"
@.str.2 = [43 x i8] c"In octal, your number is: %1d%1d%1d%1d%1d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = srem i32 %11, 8
store i32 %12, i32* %7
%13 = load i32, i32* %2
%14 = sdiv i32 %13, 8
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = srem i32 %15, 8
store i32 %16, i32* %6
%17 = load i32, i32* %2
%18 = sdiv i32 %17, 8
store i32 %18, i32* %2
%19 = load i32, i32* %2
%20 = srem i32 %19, 8
store i32 %20, i32* %5
%21 = load i32, i32* %2
%22 = sdiv i32 %21, 8
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = srem i32 %23, 8
store i32 %24, i32* %4
%25 = load i32, i32* %2
%26 = sdiv i32 %25, 8
store i32 %26, i32* %2
%27 = load i32, i32* %2
%28 = srem i32 %27, 8
store i32 %28, i32* %3
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %30, i32 %31, i32 %32, i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Enter a number between 0 and 32767: \00"
@.str.1 = [4 x i8] c"%5d\00"
@.str.2 = [43 x i8] c"In octal, your number is: %1d%1d%1d%1d%1d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = srem i32 %5, 8
%7 = sdiv i32 %5, 8
%8 = srem i32 %7, 8
%9 = sdiv i32 %5, 64
%10 = srem i32 %9, 8
%11 = sdiv i32 %5, 512
%12 = srem i32 %11, 8
%13 = sdiv i32 %5, 4096
%14 = srem i32 %13, 8
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %12, i32 %10, i32 %8, i32 %6)
ret i32 0
}