#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 *, unsigned char);
unsigned long strtoul(char *, char **, int);
void print_oct(const char **msg) {
  char buf[5];
  char *end;
  unsigned long n;
  unsigned char c;
  int i;
  int max;
  if (!(((**msg) >= '0' && (**msg) <= '7') ? 1 : 0))
    return;
  max = (**msg == '0') ? 4 : 3;
  for (i = 0; (((**msg) >= '0' && (**msg) <= '7') ? 1 : 0) && i < max;
       ++*msg, ++i)
    buf[i] = **msg;
  buf[i] = 0;
  --*msg;
  n = strtoul(buf, &end, 8);
  printf("%c", (c = n));
}


x86 assembly (clang, -O0):
<print_oct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     1161 <print_oct+0x41>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x37,%eax
jg     1161 <print_oct+0x41>
mov    $0x1,%al
test   $0x1,%al
jne    1175 <print_oct+0x55>
jmp    1170 <print_oct+0x50>
xor    %eax,%eax
test   $0x1,%al
jne    1175 <print_oct+0x55>
jmp    1170 <print_oct+0x50>
jmp    1272 <print_oct+0x152>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edx
mov    $0x3,%eax
mov    $0x4,%ecx
cmp    $0x30,%edx
cmove  %ecx,%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     11d4 <print_oct+0xb4>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x37,%eax
jg     11d4 <print_oct+0xb4>
xor    %eax,%eax
mov    $0x1,%cl
test   $0x1,%cl
mov    %al,-0x2d(%rbp)
jne    11e6 <print_oct+0xc6>
jmp    11f2 <print_oct+0xd2>
xor    %eax,%eax
test   $0x1,%al
mov    %al,-0x2d(%rbp)
jne    11e6 <print_oct+0xc6>
jmp    11f2 <print_oct+0xd2>
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
setl   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    1202 <print_oct+0xe2>
jmp    122f <print_oct+0x10f>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0xd(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1199 <print_oct+0x79>
movslq -0x28(%rbp),%rax
movb   $0x0,-0xd(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,(%rax)
lea    -0xd(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   1040 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %al,-0x21(%rbp)
lea    0xd96(%rip),%rdi
movzbl %al,%esi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_oct>:
sub    $0x18,%rsp
mov    (%rdi),%rax
mov    (%rax),%cl
mov    %ecx,%edx
and    $0xf8,%dl
cmp    $0x30,%dl
jne    11e7 <print_oct+0xc7>
mov    %cl,0xb(%rsp)
lea    0x1(%rax),%rsi
mov    %rsi,(%rdi)
mov    0x1(%rax),%r8b
mov    %r8d,%edx
and    $0xf8,%dl
mov    $0x1,%r11d
cmp    $0x30,%dl
jne    11b8 <print_oct+0x98>
mov    %r8b,0xc(%rsp)
lea    0x2(%rax),%r8
mov    %r8,(%rdi)
mov    0x2(%rax),%r9b
mov    %r9d,%edx
and    $0xf8,%dl
mov    $0x2,%r11d
cmp    $0x30,%dl
jne    11bb <print_oct+0x9b>
mov    %r9b,0xd(%rsp)
lea    0x3(%rax),%r9
mov    %r9,(%rdi)
mov    0x3(%rax),%r10b
mov    %r10d,%edx
and    $0xf8,%dl
mov    $0x3,%r11d
mov    %r8,%rsi
cmp    $0x30,%dl
jne    11bb <print_oct+0x9b>
cmp    $0x30,%cl
jne    11bb <print_oct+0x9b>
mov    %r10b,0xe(%rsp)
add    $0x4,%rax
mov    %rax,(%rdi)
mov    $0x4,%r11d
mov    %r9,%rsi
jmp    11bb <print_oct+0x9b>
mov    %rax,%rsi
movb   $0x0,0xb(%rsp,%r11,1)
mov    %rsi,(%rdi)
lea    0xb(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x8,%edx
call   1040 <strtoul@plt>
movzbl %al,%esi
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @print_oct(i8** %0) {
%2 = alloca i8**
%3 = alloca [5 x i8]
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i8** %0, i8*** %2
%9 = load i8**, i8*** %2
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp sge i32 %12, 48
br i1 %13, label %14, label %21
14: ; preds = %1
%15 = load i8**, i8*** %2
%16 = load i8*, i8** %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp sle i32 %18, 55
br i1 %19, label %20, label %21
20: ; preds = %14
br i1 true, label %23, label %22
21: ; preds = %14, %1
br i1 false, label %23, label %22
22: ; preds = %21, %20
br label %76
23: ; preds = %21, %20
%24 = load i8**, i8*** %2
%25 = load i8*, i8** %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 48
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 4, i32 3
store i32 %30, i32* %8
store i32 0, i32* %7
br label %31
31: ; preds = %58, %23
%32 = load i8**, i8*** %2
%33 = load i8*, i8** %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp sge i32 %35, 48
br i1 %36, label %37, label %44
37: ; preds = %31
%38 = load i8**, i8*** %2
%39 = load i8*, i8** %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp sle i32 %41, 55
br i1 %42, label %43, label %44
43: ; preds = %37
br i1 true, label %45, label %49
44: ; preds = %37, %31
br i1 false, label %45, label %49
45: ; preds = %44, %43
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = icmp slt i32 %46, %47
br label %49
49: ; preds = %45, %44, %43
%50 = phi i1 [ false, %44 ], [ false, %43 ], [ %48, %45 ]
br i1 %50, label %51, label %64
51: ; preds = %49
%52 = load i8**, i8*** %2
%53 = load i8*, i8** %52
%54 = load i8, i8* %53
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %56
store i8 %54, i8* %57
br label %58
58: ; preds = %51
%59 = load i8**, i8*** %2
%60 = load i8*, i8** %59
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %59
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 1
store i32 %63, i32* %7
br label %31
64: ; preds = %49
%65 = load i32, i32* %7
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %66
store i8 0, i8* %67
%68 = load i8**, i8*** %2
%69 = load i8*, i8** %68
%70 = getelementptr inbounds i8, i8* %69, i32 -1
store i8* %70, i8** %68
%71 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%72 = call i64 @strtoul(i8* %71, i8** %4, i32 8)
store i64 %72, i64* %5
%73 = load i64, i64* %5
%74 = trunc i64 %73 to i8
store i8 %74, i8* %6
%75 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %74)
br label %76
76: ; preds = %64, %22
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @print_oct(i8** nocapture %0) {
%2 = alloca [5 x i8]
%3 = alloca i8*
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = bitcast i8** %3 to i8*
%6 = load i8*, i8** %0
%7 = load i8, i8* %6
%8 = and i8 %7, -8
%9 = icmp eq i8 %8, 48
br i1 %9, label %10, label %40
10: ; preds = %1
%11 = icmp eq i8 %7, 48
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
store i8 %7, i8* %12
%13 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %13, i8** %0
%14 = load i8, i8* %13
%15 = and i8 %14, -8
%16 = icmp eq i8 %15, 48
br i1 %16, label %17, label %33
17: ; preds = %10
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 1
store i8 %14, i8* %18
%19 = getelementptr inbounds i8, i8* %6, i64 2
store i8* %19, i8** %0
%20 = load i8, i8* %19
%21 = and i8 %20, -8
%22 = icmp eq i8 %21, 48
br i1 %22, label %23, label %33
23: ; preds = %17
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 2
store i8 %20, i8* %24
%25 = getelementptr inbounds i8, i8* %6, i64 3
store i8* %25, i8** %0
%26 = load i8, i8* %25
%27 = and i8 %26, -8
%28 = icmp eq i8 %27, 48
%29 = select i1 %28, i1 %11, i1 false
br i1 %29, label %30, label %33
30: ; preds = %23
%31 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 3
store i8 %26, i8* %31
%32 = getelementptr inbounds i8, i8* %6, i64 4
store i8* %32, i8** %0
br label %33
33: ; preds = %30, %23, %17, %10
%34 = phi i8* [ %6, %10 ], [ %13, %17 ], [ %19, %23 ], [ %25, %30 ]
%35 = phi i64 [ 1, %10 ], [ 2, %17 ], [ 3, %23 ], [ 4, %30 ]
%36 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %35
store i8 0, i8* %36
store i8* %34, i8** %0
%37 = call i64 @strtoul(i8* %4, i8** %3, i32 8)
%38 = trunc i64 %37 to i8
%39 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %38)
br label %40
40: ; preds = %1, %33
ret void
}