#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 */
scalar_t__ isdigit(char);
int good_num(char *p) {
  int i;
  for (i = 0; *p; p++, i++) {
    if (isdigit(*p))
      ;
    else
      return (0);
  }
  return ((i > 0) && (i <= 2));
}


x86 assembly (clang, -O0):
<good_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1176 <good_num+0x66>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     114b <good_num+0x3b>
jmp    1157 <good_num+0x47>
movl   $0x0,-0x4(%rbp)
jmp    119a <good_num+0x8a>
jmp    115c <good_num+0x4c>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <good_num+0x13>
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x15(%rbp)
jle    118f <good_num+0x7f>
cmpl   $0x2,-0x14(%rbp)
setle  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<good_num>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     114d <good_num+0x3d>
mov    %rdi,%rbx
add    $0x1,%rbx
mov    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     115c <good_num+0x4c>
movzbl (%rbx),%eax
add    $0x1,%ebp
add    $0x1,%rbx
test   %al,%al
jne    1130 <good_num+0x20>
jmp    1152 <good_num+0x42>
mov    $0xffffffff,%ebp
xor    %eax,%eax
cmp    $0x2,%ebp
setb   %al
jmp    115e <good_num+0x4e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @good_num(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %17, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = call i64 @isdigit(i8 signext %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
br label %16
15: ; preds = %9
store i32 0, i32* %2
br label %31
16: ; preds = %14
br label %17
17: ; preds = %16
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %5
22: ; preds = %5
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* %4
%27 = icmp sle i32 %26, 2
br label %28
28: ; preds = %25, %22
%29 = phi i1 [ false, %22 ], [ %27, %25 ]
%30 = zext i1 %29 to i32
store i32 %30, i32* %2
br label %31
31: ; preds = %28, %15
%32 = load i32, i32* %2
ret i32 %32
}

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