#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*/ isOctalDigit(char);
int strlen(char const *);
int checkOctalString(char const *octalString) {
  int i = 0, siz = 0;
  char digit = 0;
  siz = strlen(octalString);
  for (i = 0; i < siz; i++) {
    digit = octalString[i];
    if (!isOctalDigit(digit)) {
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<checkOctalString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    119c <checkOctalString+0x7c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%edi
call   1030 <isOctalDigit@plt>
cmp    $0x0,%eax
jne    1189 <checkOctalString+0x69>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a3 <checkOctalString+0x83>
jmp    118e <checkOctalString+0x6e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1151 <checkOctalString+0x31>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkOctalString>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %eax,%eax
jle    1157 <checkOctalString+0x37>
mov    %eax,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%edi
call   1030 <isOctalDigit@plt>
test   %eax,%eax
je     115b <checkOctalString+0x3b>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <checkOctalString+0x20>
xor    %eax,%eax
jmp    1160 <checkOctalString+0x40>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @checkOctalString(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
store i8 0, i8* %6
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %5
store i32 0, i32* %4
br label %9
9: ; preds = %24, %1
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %27
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
store i8 %18, i8* %6
%19 = load i8, i8* %6
%20 = call i32 @isOctalDigit(i8 signext %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %13
store i32 -1, i32* %2
br label %28
23: ; preds = %13
br label %24
24: ; preds = %23
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %9
27: ; preds = %9
store i32 0, i32* %2
br label %28
28: ; preds = %27, %22
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
define i32 @checkOctalString(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %15
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %8
6: ; preds = %8
%7 = icmp eq i64 %14, %5
br i1 %7, label %15, label %8
8: ; preds = %4, %6
%9 = phi i64 [ 0, %4 ], [ %14, %6 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = tail call i32 @isOctalDigit(i8 signext %11)
%13 = icmp eq i32 %12, 0
%14 = add nuw nsw i64 %9, 1
br i1 %13, label %15, label %6
15: ; preds = %8, %6, %1
%16 = phi i32 [ 0, %1 ], [ 0, %6 ], [ -1, %8 ]
ret i32 %16
}