#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__ isalpha(char);
int /*<<< orphan*/ isdigit(char);
int type(char in[100]) {
  int flag = 0, i = 0;
  while (!isdigit(in[i]))
    i++;
  while (in[i] != '\n') {
    if (isalpha(in[i])) {
      flag = 1;
      break;
    }
    i++;
  }
  return flag;
}


x86 assembly (clang, -O0):
<type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1160 <type+0x40>
jmp    116e <type+0x4e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113a <type+0x1a>
jmp    1173 <type+0x53>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     11bd <type+0x9d>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     11af <type+0x8f>
movl   $0x1,-0xc(%rbp)
jmp    11bd <type+0x9d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1173 <type+0x53>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<type>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0xffffffffffffffff,%rbp
xchg   %ax,%ax
movsbl 0x1(%rbx,%rbp,1),%edi
call   1030 <isdigit@plt>
add    $0x1,%rbp
test   %eax,%eax
je     1130 <type+0x10>
mov    %ebp,%eax
mov    (%rbx,%rax,1),%al
xor    %r14d,%r14d
cmp    $0xa,%al
je     1180 <type+0x60>
mov    %ebp,%ecx
add    %rcx,%rbx
add    $0x1,%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <isalpha@plt>
test   %rax,%rax
jne    117a <type+0x5a>
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0xa,%al
jne    1160 <type+0x40>
jmp    1180 <type+0x60>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @type(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %14, %1
%6 = load i8*, i8** %2
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = call i32 @isdigit(i8 signext %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %17
14: ; preds = %5
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %5
17: ; preds = %5
br label %18
18: ; preds = %35, %17
%19 = load i8*, i8** %2
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 10
br i1 %25, label %26, label %38
26: ; preds = %18
%27 = load i8*, i8** %2
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = call i64 @isalpha(i8 signext %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %26
store i32 1, i32* %3
br label %38
35: ; preds = %26
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %18
38: ; preds = %34, %18
%39 = load i32, i32* %3
ret i32 %39
}

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