#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 *, char *);
char *strrev(char *);
void tooct(unsigned dec) {
  unsigned i = 0;
  char oct[32];
  do
    oct[i++] = '0' + dec % 8;
  while (dec /= 8);
  oct[i] = '\0';
  printf("= %s in octal.\n", strrev(oct));
}


x86 assembly (clang, -O0):
<tooct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7,%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
mov    %eax,%eax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
shr    $0x3,%eax
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jne    1132 <tooct+0x12>
mov    -0x8(%rbp),%eax
movb   $0x0,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rdi
call   1040 <strrev@plt>
mov    %rax,%rsi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tooct>:
sub    $0x28,%rsp
mov    %rsp,%rax
mov    %edi,%ecx
nopl   0x0(%rax)
mov    %edi,%edx
and    $0x7,%dl
or     $0x30,%dl
mov    %dl,(%rax)
shr    $0x3,%ecx
add    $0x1,%rax
cmp    $0x7,%edi
mov    %ecx,%edi
ja     1130 <tooct+0x10>
movb   $0x0,(%rax)
mov    %rsp,%rdi
call   1040 <strrev@plt>
lea    0xea6(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"= %s in octal.\0A\00"
define void @tooct(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [32 x i8]
store i32 %0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %14, %1
%6 = load i32, i32* %2
%7 = urem i32 %6, 8
%8 = add i32 48, %7
%9 = trunc i32 %8 to i8
%10 = load i32, i32* %3
%11 = add i32 %10, 1
store i32 %11, i32* %3
%12 = zext i32 %10 to i64
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 %12
store i8 %9, i8* %13
br label %14
14: ; preds = %5
%15 = load i32, i32* %2
%16 = udiv i32 %15, 8
store i32 %16, i32* %2
%17 = icmp ne i32 %16, 0
br i1 %17, label %5, label %18
18: ; preds = %14
%19 = load i32, i32* %3
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 %20
store i8 0, i8* %21
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%23 = call i8* @strrev(i8* %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %23)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"= %s in octal.\0A\00"
define void @tooct(i32 %0) {
%2 = alloca [32 x i8]
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %4, %1
%5 = phi i64 [ %10, %4 ], [ 0, %1 ]
%6 = phi i32 [ %12, %4 ], [ %0, %1 ]
%7 = trunc i32 %6 to i8
%8 = and i8 %7, 7
%9 = or i8 %8, 48
%10 = add nuw nsw i64 %5, 1
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 %5
store i8 %9, i8* %11
%12 = lshr i32 %6, 3
%13 = icmp ult i32 %6, 8
br i1 %13, label %14, label %4
14: ; preds = %4
%15 = and i64 %10, 4294967295
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 %15
store i8 0, i8* %16
%17 = call i8* @strrev(i8* %3)
%18 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %17)
ret void
}